Skip to main content

suggest-complete-word

Documentation / tokenize/suggest-complete-word

Topics​

suggestNextWordCompletions()​

function suggestNextWordCompletions(query: string, options?: object): Promise<any[]>;

Defined in: tokenize/suggest-complete-word.js:33

Autocomplete Topic Phrase Completions​

Completes the query with the most likely next words for phrases. If typing 2+ letters of a word, returns all possible words matching those few letters.

Parameters​

ParameterTypeDescription

query

string

The input query which can be pertial words or phrases.

options?

{ limitMaxResults: number; numberOfLastWordsToCheck: number; phrasesModel: any; }

options.limitMaxResults?

number

default=10 - The maximum number of autocomplete suggestions to return.

options.numberOfLastWordsToCheck?

number

default=5 - The number of last words in the query to check for phrase completions.

options.phrasesModel?

any

A custom phrases model to use for autocomplete suggestions.

Returns​

Promise<any[]>

An array of autocomplete suggestions, each containing either a 'phrase' or 'word' property.

Examples​

// Basic usage
const suggestions = await suggestNextWordCompletions("self att");
// Possible output: [{ phrase: "self attention" }, { phrase: "self attract" }, { phrase: "self attack" }]
// Using options
const customModel = await import("./custom-phrases-model.json");
const suggestions = await suggestNextWordCompletions("artificial int", {
phrasesModel: customModel,
limitMaxResults: 5,
numberOfLastWordsToCheck: 3
});
// Possible output: [{ phrase: "artificial intelligence" }, { phrase: "artificial interpretation" }]

Author​

ai-research-agent (2024)