View source: R/smith_waterman.R
smith_waterman_pairwise | R Documentation |
Utility function to perform all pairwise combinations of alignments between text.
smith_waterman_pairwise(a, b, FUN = identity, ...)
a |
a data.frame with columns doc_id and text. Or a character vector where the names of the character vector respresent a doc_id and the character vector corresponds to the text. |
b |
a data.frame with columns doc_id and text. Or a character vector where the names of the character vector respresent a doc_id and the character vector corresponds to the text. |
FUN |
a function to apply on an object of class |
... |
other arguments passed on to |
a list of pairwise Smith-Waterman comparisons after which the FUN argument is applied on all of these pairwise alignments.
The output of the result of FUN is enriched by adding a list element
a_doc_id and b_doc_id which correspond to the doc_id's provided in a
and b
and which can be used
in order to identify the match.
smith_waterman
x <- data.frame(doc_id = c(1, 2),
text = c("This is some text", "Another set of texts."),
stringsAsFactors = FALSE)
y <- data.frame(doc_id = c(1, 2, 3),
text = c("were as some thing", "else, another set", NA_character_),
stringsAsFactors = FALSE)
alignments <- smith_waterman_pairwise(x, y)
alignments
alignments <- smith_waterman_pairwise(x, y, FUN = as.data.frame)
do.call(rbind, alignments)
alignments <- smith_waterman_pairwise(x, y,
FUN = function(x) list(sim = x$similarity))
do.call(rbind, alignments)
x <- c("1" = "This is some text", "2" = "Another set of texts.")
y <- c("1" = "were as some thing", "2" = "else, another set", "3" = NA_character_)
alignments <- smith_waterman_pairwise(x, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.