model_fasttext: Fasttext Model

Description Usage Arguments Examples

View source: R/models.R

Description

Train word embeddings from a training corpus with the additional ability to obtain word vectors for out-of-vocabulary words.

Usage

1
2
3

Arguments

...

Any option, from the official documentation.

file

Path to a saved model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
docs <- prepare_documents(corpus)

# fit model
ft <- model_fasttext(size = 4L, window = 3L, min_count = 1L)

# build vocabulary
ft$build_vocab(sentences = unname(docs))

# train
ft$train(sentences = unname(docs), total_examples = length(docs), epochs = 10L)

# most similar
ft$wv$most_similar(positive = c('computer', 'human'), negative = c('interface'))

# odd one out
ft$wv$doesnt_match(c("human", "computer", "interface", "tree"))

# similarity score
ft$wv$similarity('computer', 'human')

news-r/gensimr documentation built on Jan. 9, 2021, 5:55 a.m.