View source: R/pairwise_compare.R
pairwise_compare | R Documentation |
Given a TextReuseCorpus
containing documents of class
TextReuseTextDocument
, this function applies a comparison
function to every pairing of documents, and returns a matrix with the
comparison scores.
pairwise_compare(corpus, f, ..., directional = FALSE, progress = interactive())
corpus |
A |
f |
The function to apply to |
... |
Additional arguments passed to |
directional |
Some comparison functions are commutative, so that
|
progress |
Display a progress bar while comparing documents. |
A square matrix with dimensions equal to the length of the corpus,
and row and column names set by the names of the documents in the corpus. A
value of NA
in the matrix indicates that a comparison was not made.
In cases of directional comparisons, then the comparison reported is
f(row, column)
.
See these document comparison functions,
jaccard_similarity
, ratio_of_matches
.
dir <- system.file("extdata/legal", package = "textreuse")
corpus <- TextReuseCorpus(dir = dir)
names(corpus) <- filenames(names(corpus))
# A non-directional comparison
pairwise_compare(corpus, jaccard_similarity)
# A directional comparison
pairwise_compare(corpus, ratio_of_matches, directional = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.