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"
# \dontshow{
path <- tempfile(pattern = "w2v", fileext = ".bin")
# }
write.word2vec(model, file = path)
# \dontshow{
file.remove(path)
# }
if(require(udpipe)){
## Save the model to hard disk as a text file (uses package udpipe)
library(udpipe)
path <- "mymodel.txt"
# \dontshow{
path <- tempfile(pattern = "w2v", fileext = ".txt")
# }
write.word2vec(model, file = path, type = "txt")
# \dontshow{
file.remove(path)
# }
} # End of main if statement running only if the required packages are installed
Run the code above in your browser using DataLab