get_word_ids: Retrieve word IDs

Description Usage Arguments Value Examples

View source: R/API.R

Description

Get ID of words in the dictionary

Usage

1
get_word_ids(model, words)

Arguments

model

fastText model

words

character containing words to retrieve IDs

Value

numeric of ids

Examples

1
2
3
4
5
6
7
8
9
library(fastrtext)
model_test_path <- system.file("extdata", "model_unsupervised_test.bin", package = "fastrtext")
model <- load_model(model_test_path)
ids <- get_word_ids(model, c("this", "is", "a", "test"))

# print positions
print(ids)
# retrieve words in the dictionary using the positions retrieved
print(get_dictionary(model)[ids])

Example output

[1]  18   9   7 120
[1] "this" "is"   "a"    "test"

fastrtext documentation built on Oct. 30, 2019, 11:32 a.m.