View source: R/3_1_textSimilarity.R
textSimilarityNorm | R Documentation |
Compute the semantic similarity between a text variable and a word norm (i.e., a text represented by one word embedding that represent a construct).
textSimilarityNorm(x, y, method = "cosine", center = TRUE, scale = FALSE)
x |
Word embeddings from textEmbed. |
y |
Word embedding from textEmbed (from only one text). |
method |
(character) 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"). |
center |
(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. |
scale |
(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. |
A vector comprising semantic similarity scores.
see textSimilarity
## Not run:
library(dplyr)
library(tibble)
harmonynorm <- c("harmony peace ")
satisfactionnorm <- c("satisfaction achievement")
norms <- tibble::tibble(harmonynorm, satisfactionnorm)
word_embeddings <- word_embeddings_4$texts
word_embeddings_wordnorm <- textEmbed(norms)
similarity_scores <- textSimilarityNorm(
word_embeddings$harmonytext,
word_embeddings_wordnorm$harmonynorm
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.