@dcoffey/espells
Version:
Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.
98 lines (97 loc) • 4.12 kB
TypeScript
import type { Aff } from "../aff/index.js";
import type { Dic } from "../dic/index.js";
import type { Lookup } from "../lookup/index.js";
import { Suggestion } from "./suggestion.js";
export declare class Suggest {
/** {@link Aff} data used. */
private aff;
/** {@link Dic} data used. */
private dic;
/** {@link Lookup} instance used filtering and verifying suggestions. */
private lookup;
/**
* A set of {@link Word} instances that have been filtered from the
* {@link Dic} data. Any words that are marked with flags that make said
* word unsuitable for being a standalone word are filtered out.
*/
private ngramWords;
/** If true, suggestions consisting of multiple words split with dashes are allowed. */
private dashes;
/**
* @param aff - {@link Aff} data to use.
* @param dic - {@link Dic} data to use.
* @param lookup - {@link Lookup} instance to use for filtering and
* verifying suggestions.
*/
constructor(aff: Aff, dic: Dic, lookup: Lookup);
/**
* Yields {@link Suggestion} instances for the given word, even if it is
* spelled correctly.
*
* @param word - The word to get the suggestions for.
*/
suggestions(word: string): Iterable<Suggestion>;
/**
* Yields various correct {@link Suggestion} instances that were found by
* transforming the given word using various simple "edit" functions.
* e.g. this may involve breaking the word apart at various points,
* shifting characters around, removing characters, etc.
*
* @param word - The word to apply the "edits" transformations to.
* @param handle - The {@link Handler} instance to yield every {@link Suggestion} to.
* @param limit - The maximum number of correct {@link Suggestion}
* instances to yield.
* @param compounds - If provided, false will yield only suggestions
* found from {@link AffixForm}s, and true will yield only suggestions
* found from {@link CompoundForm}s.
*/
private edits;
/**
* Filters {@link Suggestion} and {@link MultiWordSuggestion} instances.
* This process involves splitting out the {@link MultiWordSuggestion}
* instances into a few forms, and making sure that every
* {@link Suggestion} that will be yielded is correct.
*
* @param suggestions - The iterator that should have its resultant
* suggestions filtered.
* @param compounds - If provided, false will yield only suggestions
* found from {@link AffixForm}s, and true will yield only suggestions
* found from {@link CompoundForm}s.
*/
private filter;
/**
* Base function that a {@link Handler} can be made from.
*
* @param word - The word to compare the given {@link Suggestion} to.
* @param captype - The {@link CapType} of the word.
* @param handled - The set of already handled words and stems.
* @param suggestion - The {@link Suggestion} to handle.
* @param checkInclusion - If true, the {@link Suggestion} text will be
* checked for if it can be found in its entirety inside of any the
* previously handled suggestions. Not just in the set, but if it can
* be found even as a substring. Defaults to false.
*/
private handle;
/**
* Yields every permutation (as {@link Suggestion} or
* {@link MultiWordSuggestion} instances) of a word processed through
* *many* different simple transformation functions.
*
* @param word - The word to yield the permutations of.
*/
private permutations;
/**
* Helper for checking if a word is correct using some preconfigured
* settings specific to the {@link Suggest} class.
*/
private correct;
/**
* Helper for yielding {@link Suggestion} instances from a iterator that
* yields strings.
*/
private pmtFrom;
/** Returns a preconfigured {@link NgramSuggestionBuilder}. */
private ngramBuilder;
/** Yields a preconfigured {@link PhonetSuggestionBuilder}. */
private phonetBuilder;
}