Return whether a specific word is in the vocabulary.

in_vocabulary(model, word)

# S3 method for wordvectors
in_vocabulary(model, word)

# S3 method for wordclusters
in_vocabulary(model, word)

Arguments

model

A model as returned by word_vectors or word_clusters.

word

The word to extract.

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)

# check if James I is mentioned
in_vocabulary(model, "james")
# }