Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public suggest(
word: string,
numSuggestions?: number,
compoundMethod: CompoundWordsMethod = CompoundWordsMethod.SEPARATE_WORDS,
numChanges?: number
): SuggestionResult[] {
word = this.mapWord(word);
const wordLc = word.toLowerCase();
compoundMethod = this.options.useCompounds ? CompoundWordsMethod.JOIN_WORDS : compoundMethod;
const numSugs = numSuggestions || defaultSuggestions;
const suggestions = this.trie.suggestWithCost(word, numSugs, compoundMethod, numChanges);
if (word === wordLc) {
return suggestions;
}
return mergeSuggestions(
numSugs,
suggestions,
this.trie.suggestWithCost(wordLc, numSugs, compoundMethod, numChanges)
);
}