Learn R Programming

text (version 0.9.90)

textSimilarityNorm: 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).

Description

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

Usage

textSimilarityNorm(x, y, method = "cosine")

Value

A vector comprising semantic similarity scores.

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

See Also

see textSimilarity and textSimilarityTest

Examples

Run this code
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
)
}

Run the code above in your browser using DataLab