@dcoffey/espells
Version:
Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.
132 lines (131 loc) • 4.18 kB
TypeScript
export declare const CONSTANTS: {
/**
* A record of deprecated names that map to their proper name. Used in
* the {@link Aff} `.aff` parser.
*/
readonly SYNONYMS: Record<string, string>;
/**
* `RegExp` used to split a string of flags in "long" format, i.e. each
* flag is two characters.
*/
readonly FLAG_LONG_REGEX: RegExp;
/**
* `RegExp` used to parse phoneme table rules.
*
* Groups:
*
* 1. Letters
* 2. Optional
* 3. Lookahead
* 4. Flags
* 5. Priority
*/
readonly PHONET_RULE_REGEX: RegExp;
/**
* `RegExp` used by the {@link Dic} `.dic` parser to determine if a line
* should be skipped.
*/
readonly DIC_SKIP_REGEX: RegExp;
/**
* `RegExp` used to split a `.dic` "word" into its various components. Groups:
*
* 1. Stem
* 2. Flags
* 3. Data (not split here, see {@link CONSTANTS.SPLIT_DATA_REGEX})
*/
readonly SPLIT_WORD_REGEX: RegExp;
/**
* `RegExp` used to split a `.dic` word data key-value. Groups:
*
* 1. Key
* 2. Value
*/
readonly SPLIT_DATA_REGEX: RegExp;
/** Maximum number of {@link PhonetTable} suggestions per list of suggestions. */
readonly MAX_PHONET_SUGGESTIONS: 2;
/**
* Maximum number of suggestions generated when yielding permutations of
* a misspelling.
*/
readonly MAX_SUGGESTIONS: 15;
/** Maximum number of permutations generated per permutation type. */
readonly MAX_PERMUTATIONS: 500;
/** Maximum number of ngram "roots" (most similar words to a misspelling). */
readonly NGRAM_MAX_ROOTS: 100;
/** Maximum number of ngram guesses that can be processed. */
readonly NGRAM_MAX_GUESSES: 200;
/**
* Maximum number of {@link PhonetTable} "roots" (most similar words to a
* misspelling).
*/
readonly PHONET_MAX_ROOTS: 100;
/**
* Maximum distance a character can be moved from its original position
* when making permutations of a word.
*/
readonly MAX_CHAR_DISTANCE: 4;
/** `RegExp` used to split a string `RegExp`. Used in the {@link re} function. */
readonly SPLIT_REGEX_REGEX: RegExp;
/** `RegExp` used to split an {@link Affix} condition. */
readonly SPLIT_CONDITION_REGEX: RegExp;
/**
* The default set of `RegExp`s used when breaking apart multiple words
* from a single string with {@link breakWord}.
*/
readonly DEFAULT_BREAK: Set<RegExp>;
/** `RegExp` used to match a line that is just a number. Used in the `.dic` parser. */
readonly NUMBER_REGEX: RegExp;
/** `RegExp` used to split a line based on whitespace. */
readonly SPLIT_LINE_REGEX: RegExp;
};
export declare const decoder: TextDecoder;
/** The various capitalization types a word can have. */
export declare enum CapType {
/** All lowercase. */
NO = 0,
/** Titlecase. */
INIT = 1,
/** All uppercase. */
ALL = 2,
/** Mixed capitalization. */
HUH = 3,
/** Mixed capitalization, first letter is capitalized. */
HUHINIT = 4
}
/** The various positions a word in a compound word could be in. */
export declare enum CompoundPos {
/** The compound segment is at the beginning of the word. */
BEGIN = 0,
/** The compound segment is somewhere in the middle of the word. */
MIDDLE = 1,
/** The compound segment is at the end of the word. */
END = 2
}
/** Kinds of suggestions, based on how they were attained. */
export declare enum SuggestionKind {
CASE = 0,
FORCEUCASE = 1,
UPPERCASE = 2,
REPLCHARS = 3,
SPACEWORD = 4,
MAPCHARS = 5,
SWAPCHAR = 6,
LONGSWAPCHAR = 7,
BADCHARKEY = 8,
EXTRACHAR = 9,
FORGOTCHAR = 10,
MOVECHAR = 11,
BADCHAR = 12,
DOUBLETWOCHARS = 13,
TWOWORDS = 14,
DASHES = 15,
NGRAM = 16,
PHONET = 17
}
/**
* Types of "edits" to a misspelling that, if they result in a correct
* word, mean that their resultant suggestion is almost certainly what the
* misspelling was supposed to be and thus further suggestions shouldn't be
* generated.
*/
export declare const GOOD_EDITS: SuggestionKind[];