cos_sim2_vectors: Calculate the cosine similarity of a set of word vectors to...

View source: R/cos_sim2_vectors.R

cos_sim2_vectorsR Documentation

Calculate the cosine similarity of a set of word vectors to inspect resulting terms

Description

A wrapper for faster customized inspection of glove models fitted with text2vec package.

Usage

cos_sim2_vectors(v_add, v_substract = NULL, n = 10, word_vector_set)

Arguments

v_add

Names of word vectors to be added during calculation.

v_substract

Names of word vectors to be substracted during calculation.

n

Number of resulting vector entries to show, which provide information on the resulting terms, i.e, names of the items.

word_vector_set

The full set of word vectors to be used for calculation.

Value

The resulting cosine similarity vector whose names are terms.

Examples

#in the following just a syntax example without data (hence, cannot be run)
#for details on fitting glove models please refer to documentation of text2vec
# wv_main = glove$fit_transform(tcm,...)
# wv_context = glove$components
# word_vectors = wv_main + t(wv_context)
# cos_sim2_vectors(c("renewable", "energy"),
#                  v_substract = "large",
#                  n = 20, word_vector_set = word_vectors)

manuelbickel/textility documentation built on Nov. 25, 2022, 9:07 p.m.