Description Usage Arguments Value Examples
View source: R/paragraph2vec.R
Read a binary paragraph2vec model from disk
1 |
file |
the path to the model file |
an object of class paragraph2vec which is a list with elements
model: a Rcpp pointer to the model
model_path: the path to the model on disk
dim: the dimension of the embedding matrix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library(tokenizers.bpe)
data(belgium_parliament, package = "tokenizers.bpe")
x <- subset(belgium_parliament, language %in% "french")
x <- subset(x, nchar(text) > 0 & txt_count_words(text) < 1000)
model <- paragraph2vec(x = x, type = "PV-DM", dim = 100, iter = 20)
model <- paragraph2vec(x = x, type = "PV-DBOW", dim = 100, iter = 20)
path <- "mymodel.bin"
write.paragraph2vec(model, file = path)
model <- read.paragraph2vec(file = path)
vocab <- summary(model, type = "vocabulary", which = "docs")
vocab <- summary(model, type = "vocabulary", which = "words")
embedding <- as.matrix(model, which = "docs")
embedding <- as.matrix(model, which = "words")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.