How to use the cspell-trie-lib.CompoundWordsMethod.JOIN_WORDS function in cspell-trie-lib

To help you get started, we’ve selected a few cspell-trie-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github streetsidesoftware / cspell / packages / cspell-lib / src / SpellingDictionary / SpellingDictionary.ts View on Github external
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)
        );
    }