
Last chance! 50% off unlimited learning
Sale ends in
Compute the semantic similarity between two text variables.
textSimilarity(x, y, method = "cosine", center = TRUE, scale = FALSE)
A vector comprising semantic similarity scores.
Word embeddings from textEmbed.
Word embeddings from textEmbed.
Character string describing type of measure to be computed. Default is "cosine" (see also "spearmen", "pearson" as well as measures from textDistance() (which here is computed as 1 - textDistance) including "euclidean", "maximum", "manhattan", "canberra", "binary" and "minkowski").
(boolean; from base::scale) If center is TRUE then centering is done by subtracting the column means (omitting NAs) of x from their corresponding columns, and if center is FALSE, no centering is done.
(boolean; from base::scale) If scale is TRUE then scaling is done by dividing the (centered) columns of x by their standard deviations if center is TRUE, and the root mean square otherwise.
see textDistance
, textSimilarityNorm
library(dplyr)
similarity_scores <- textSimilarity(
x = word_embeddings_4$texts$harmonytext,
y = word_embeddings_4$texts$satisfactiontext
)
comment(similarity_scores)
Run the code above in your browser using DataLab