write.word2vec: Save a word2vec model to disk

Description Usage Arguments Value See Also Examples

View source: R/word2vec.R

Description

Save a word2vec model as a binary file to disk or as a text file

Usage

1
write.word2vec(x, file, type = c("bin", "txt"), encoding = "UTF-8")

Arguments

x

an object of class w2v or w2v_trained as returned by word2vec

file

the path to the file where to store the model

type

either 'bin' or 'txt' to write respectively the file as binary or as a text file. Defaults to 'bin'.

encoding

encoding to use when writing a file with type 'txt' to disk. Defaults to 'UTF-8'

Value

a logical indicating if the save process succeeded

See Also

word2vec

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
path  <- system.file(package = "word2vec", "models", "example.bin")
model <- read.word2vec(path)


## Save the model to hard disk as a binary file
path <- "mymodel.bin"

write.word2vec(model, file = path)



## Save the model to hard disk as a text file (uses package udpipe)
library(udpipe)
path <- "mymodel.txt"

write.word2vec(model, file = path, type = "txt")

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