analogy.Rd
Compute the analogy similarity between two lists of words. The positions
and the similarity values of the top n
similar words will be returned.
For example: "king - man + woman =~ queen"
analogy(model, pos, neg, n = 5L) # S3 method for wordvectors analogy(model, pos, neg, n = 5L) analogy_words(model, pos, neg, n = 5L) # S3 method for wordvectors analogy_words(model, pos, neg, n = 5L)
model | A model as returned by |
---|---|
pos, neg | Positive and negative words. |
n | Number of neightbours to return. |
# 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) # "king - man + woman =~ queen" analogy_words(model, pos = list("king"), neg = list("malcolme"), 8L) # }