fastrtext (version 0.3.3)

get_nn: Get nearest neighbour vectors

Description

Find the k words with the smallest distance. First execution can be slow because of precomputation. Search is done linearly, if your model is big you may want to use an approximate neighbour algorithm from other R packages (like RcppAnnoy).

Usage

get_nn(model, word, k)

Arguments

model

trained fastText model. Null if train a new model.

word

reference word

k

integer defining the number of results to return

Value

numeric with distances with names as words

Examples

Run this code
# NOT RUN {
library(fastrtext)
model_test_path <- system.file("extdata", "model_unsupervised_test.bin", package = "fastrtext")
model <- load_model(model_test_path)
get_nn(model, "time", 10)

# }

Run the code above in your browser using DataLab