Reproduction of examples in official documentation.

library(gensimr)

path <- datapath('poincare_hypernyms_large.tsv')
poincare <- model_poincare(path)
poincare$train(epochs = 50L)
#> None

# What is the distance between the words 'mammal' and 'carnivore'?
poincare$kv$distance('mammal.n.01', 'carnivore.n.01')
#> 2.974229880333912

# Check the distances between a word and a list of other words.
poincare$kv$distances('mammal.n.01', list('carnivore.n.01', 'dog.n.01'))
#> [2.97422988 2.83007402]

# Check the distances between a word and every other word in the vocab.
all_distances <- poincare$kv$distances('mammal.n.01')

# Which words are most similar to 'kangaroo'?
poincare$kv$most_similar('kangaroo.n.01', topn = 2L)
#> [('kangaroo.n.01', 0.0), ('marsupial.n.01', 0.26524229460827725)]

# What is the similarity between the words 'mammal' and 'carnivore'?
poincare$kv$similarity('mammal.n.01', 'carnivore.n.01')
#> 0.25162107631176606

# Representation of 'kangaroo'
poincare$kv$word_vec('kangaroo.n.01')
#> [ 0.08848269 -0.00626555 -0.01501241 -0.02924922 -0.11259114  0.19180451
#>  -0.03631974  0.09506738  0.03395604  0.01425819  0.10300249 -0.04973628
#>   0.07015916  0.17102938 -0.08365731 -0.31951016  0.04548739  0.07437066
#>   0.13810178  0.25001197  0.1626546   0.00792985  0.08908213  0.01353233
#>  -0.09036873  0.08215076 -0.13413783  0.02152943 -0.02785171 -0.14719753
#>   0.01169892  0.17637299 -0.21157818  0.03861878 -0.15771474  0.16389603
#>   0.00734713 -0.00599655  0.1919349   0.07090435  0.05993279 -0.0356585
#>  -0.09663103 -0.0588996   0.07985177 -0.03774824 -0.26093403 -0.2194412
#>   0.02344243  0.09542624]