ft_nn: Nearest Neighbors

Description Usage Arguments Value Author(s) Examples

View source: R/core.R

Description

Given a vector words, this function returns the nearest neighbors in the vector space. Users may select a different language for the nearest neighbors than is used in the input embedding.

Usage

1
ft_nn(words, lang = "en", lang_out = lang, nn = 10L)

Arguments

words

a character vector of the words for which an embedding should be returned

lang

the two letter language code specifying the language to use for the embedding of the inputs

lang_out

the two letter language code specifying the language to use for the embedding of the outputs.

nn

positive integer. The number of nearest neighbors to return in the output.

Value

A matrix with nn columns and one row for each input word. Rows associated with input words not found in the embedding are set to NA.

Author(s)

Taylor B. Arnold, taylor.arnold@acm.org

Examples

1
2
3
ft_load_model(lang = "en")
ft_load_model(lang = "fr")
ft_nn(c("the", "and", "I"), lang = "en", lang_out = "fr", nn = 5)

statsmaths/fasttextM documentation built on April 2, 2020, 5:33 p.m.