Return the cluster number for a word in the vocabulary.

get_cluster(model, word)

# S3 method for wordclusters
get_cluster(model, word)

Arguments

model

A model as returned by word_clusters.

word

Word to retrieve the cluster.

Examples

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

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

# train model
model_path <- word2clusters(macbeth, classes = 50L)

# get word clusters
model <- word_clusters(model_path)

# get cluster
get_cluster(model, "king")
get_cluster(model, "macbeth")
# }