Compute the cosine similarity between word vectors for selected words.
similarity(
x,
targets,
layer = c("words", "documents"),
mode = c("character", "numeric")
)a matrix of cosine similarity scores when mode = "numeric" or of
words sorted in descending order by the similarity scores when mode = "character".
When words is a named numeric vector, word (or document) vectors are weighted and summed
before computing similarity scores.
a textmodel_wordvector object.
words or documents for which similarity is computed.
the layer based on which similarity is computed. This must be "documents"
when targets are document names.
specify the type of resulting object.
probability()