Skip to contents

Given a TextReuseTextDocument or a TextReuseCorpus, this function recomputes either the hashes or the minhashes with the function specified. This implies that you have retained the tokens with the keep_tokens = TRUE parameter.

Usage

rehash(x, func, type = c("hashes", "minhashes"))

Arguments

x

A TextReuseTextDocument or TextReuseCorpus.

func

A function to either hash the tokens or to generate the minhash signature. See hash_string, minhash_generator.

type

Recompute the hashes or minhashes?

Value

The modified TextReuseTextDocument or

TextReuseCorpus.

Examples

dir <- system.file("extdata/legal", package = "textreuse")
minhash1 <- minhash_generator(seed = 1)
corpus <- TextReuseCorpus(dir = dir, minhash_func = minhash1, keep_tokens = TRUE)
head(minhashes(corpus[[1]]))
#> [1] -2141167369 -2128627439 -2140592417 -2146987985 -2140770936 -2140967962
minhash2 <- minhash_generator(seed = 2)
corpus <- rehash(corpus, minhash2, type = "minhashes")
head(minhashes(corpus[[2]]))
#> [1] -2142714781 -2118109766 -2116833340 -2101247603 -2129415149 -2129964212