@dcoffey/espells
Version:
Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.
65 lines (64 loc) • 2.26 kB
TypeScript
import type { Word } from "../dic/word.js";
export declare class NgramSuggestionBuilder {
/** The misspelling that suggestions are being built for. */
private misspelling;
/** A set of already known suggestions that should be skipped. */
private known;
/**
* Sets the similarity factor.
*
* - `5`: The default value.
* - `0`: Fewer ngram suggestions, but always at least one.
* - `10`: Maximum value, yields `MAXNGRAMSUGS` number of suggestions.
*/
private maxDiff;
/**
* If true, all bad ngram suggestions will be removed, rather than
* keeping at least one.
*/
private onlyMaxDiff;
/**
* Produces less suggestions if true, so that phonetic suggestion
* system isn't skipped due to a large amount of ngram suggestions.
*/
private hasPhonetic;
/** The "root" scores for potential suggestions for a misspelling. */
private roots;
constructor(
/** The misspelling that suggestions are being built for. */
misspelling: string,
/** A set of already known suggestions that should be skipped. */
known: Set<string>,
/**
* Sets the similarity factor.
*
* - `5`: The default value.
* - `0`: Fewer ngram suggestions, but always at least one.
* - `10`: Maximum value, yields `MAXNGRAMSUGS` number of suggestions.
*/
maxDiff: number,
/**
* If true, all bad ngram suggestions will be removed, rather than
* keeping at least one.
*/
onlyMaxDiff?: boolean,
/**
* Produces less suggestions if true, so that phonetic suggestion
* system isn't skipped due to a large amount of ngram suggestions.
*/
hasPhonetic?: boolean);
/**
* Steps the builder forward by providing another {@link Word} to process.
*
* @param word - The {@link Word} to process.
*/
step(word: Word): void;
/** Finishes the builder and yields the resulting suggestions (as strings). */
finish(): Generator<string, void, unknown>;
/**
* Filters out terrible guesses based on their score or if they were already known.
*
* @param guesses - A list of tuples, containing a score and guess, in that order.
*/
private filterGuesses;
}