analogy: Analogy

Description Usage Arguments Examples

View source: R/wordvectors.R

Description

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"

Usage

1
2
3
4
5
6
7
8
9
analogy(model, pos, neg, n = 5L)

## S3 method for class 'wordvectors'
analogy(model, pos, neg, n = 5L)

analogy_words(model, pos, neg, n = 5L)

## S3 method for class 'wordvectors'
analogy_words(model, pos, neg, n = 5L)

Arguments

model

A model as returned by word_vectors.

pos, neg

Positive and negative words.

n

Number of neightbours to return.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## 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)

## End(Not run)

news-r/word2vec.r documentation built on Nov. 4, 2019, 9:41 p.m.