Skip to content

Instantly share code, notes, and snippets.

@drvenabili
Created February 26, 2019 08:05
Show Gist options
  • Save drvenabili/05b8f18d49cc8dd43f8cd49e2c3752b3 to your computer and use it in GitHub Desktop.
Save drvenabili/05b8f18d49cc8dd43f8cd49e2c3752b3 to your computer and use it in GitHub Desktop.
cloud-user@dhh17:/scratch/work/simon/finnish_newspapers/models$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gensim
>>> model = gensim.models.Word2Vec.load("model_fi_1880.bin")
>>> model.wv.most_similar("kirjasto")
[('lukusali', 0.8510360717773438), ('lirjasto', 0.8264331817626953), ('tirjasto', 0.7902065515518188), ('lainakirjasto', 0.7628928422927856), ('luknsali', 0.7343387603759766), ('lulusali', 0.7339579463005066), ('lutusali', 0.7185679078102112), ('kansankirjasto', 0.7182174324989319), ('lukutupa', 0.6950151920318604), ('kirjast', 0.6868242621421814)]
>>> exit()
cloud-user@dhh17:/scratch/work/simon/finnish_newspapers/models$ R
R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
> library(wordVectors)
> model = read.vectors("model_fi_1880.bin")
Filename ends with .bin, so reading in binary format
Error in if (nrows < rows) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In read.binary.vectors(filename, ...) : NAs introduced by coercion
2: In read.binary.vectors(filename, ...) : NAs introduced by coercion
> model %>% closest_to("kirjasto")
Error in eval(lhs, parent, parent) : object 'model' not found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment