as.matrix.word2vec: Get the word vectors of a word2vec model

Description Usage Arguments Value See Also Examples

View source: R/word2vec.R

Description

Get the word vectors of a word2vec model as a dense matrix.

Usage

1
2
## S3 method for class 'word2vec'
as.matrix(x, encoding = "UTF-8", ...)

Arguments

x

a word2vec model as returned by word2vec or read.word2vec

encoding

set the encoding of the row names to the specified encoding. Defaults to 'UTF-8'.

...

not used

Value

a matrix with the word vectors where the rownames are the words from the model vocabulary

See Also

word2vec, read.word2vec

Examples

1
2
3
4
path  <- system.file(package = "word2vec", "models", "example.bin")
model <- read.word2vec(path)

embedding <- as.matrix(model)

word2vec documentation built on July 2, 2021, 5:07 p.m.