Return the cosine similarity value between two words word1 and word2.

similarity(model, word1, word2)

# S3 method for wordvectors
similarity(model, word1, word2)

Arguments

model

A model as returned by word_vectors.

word1, word2

Words to compare.

Examples

# NOT RUN {
# setup word2vec Julia dependency
setup_word2vec()

# sample corpus
data("macbeth", package = "word2vec.r")

# train model
model_path <- word2vec(macbeth)

# get word vectors
model <- word_vectors(model_path)

# similarity b/w macbeth and wife
similarity(model, "macbeth", "king")
# }