write.word2vec {word2vec}R Documentation

Save a word2vec model to disk

Description

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

Usage

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

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")



[Package word2vec version 0.4.0 Index]