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")

Arguments

x

Word embeddings from textEmbed.

y

Word embedding from textEmbed (from only one text).

method

Character string describing type of measure to be computed. Default is "cosine" (see also measures from textDistance() (which here is computed as 1 - textDistance) including "euclidean", "maximum", "manhattan", "canberra", "binary" and "minkowski").

Value

A vector comprising semantic similarity scores.

Examples

if (FALSE) {
library(dplyr)
library(tibble)
harmonynorm <- c("harmony peace ")
satisfactionnorm <- c("satisfaction achievement")

norms <- tibble::tibble(harmonynorm, satisfactionnorm)
word_embeddings <- word_embeddings_4
word_embeddings_wordnorm <- textEmbed(norms)
similarity_scores <- textSimilarityNorm(
  word_embeddings$harmonytext,
  word_embeddings_wordnorm$harmonynorm
)
}