write.word2vec: Save a word2vec model to disk

View source: R/word2vec.R

write.word2vecR 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")



word2vec documentation built on Oct. 8, 2023, 1:07 a.m.