@dcoffey/espells
Version:
Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.
80 lines (79 loc) • 3.45 kB
TypeScript
import type { CharacterMap } from "./aff/index.js";
import type { RepPattern } from "./aff/rep-pattern.js";
/**
* Uses a {@link Aff}'s {@link RepPattern} table to yield replaced
* permutations of a word.
*
* @param word - The word to yield the replaced forms of.
* @param reps - The set of {@link RepPattern}s to use.
*/
export declare function replchars(word: string, reps: Set<RepPattern>): Generator<string | string[], void, unknown>;
/**
* Uses an {@link Aff}'s `MAP` table to recursively replace characters in a
* word. This yields every permutation of this action for every character.
*
* @param word - The word to yield the mapped forms of.
* @param map - The map to use.
*/
export declare function mapchars(word: string, map: CharacterMap): Generator<string, void, undefined>;
/**
* Yields the permutations of a word with adjacent characters within it
* swapped. For short words, specifically 4-5 letters, doubleswaps will be
* yielded as well.
*/
export declare function swapchar(word: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word where non-adjacent characters are
* swapped, with a maximum distance of four characters.
*/
export declare function longswapchar(word: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word where characters are swapped with
* characters adjacent to it, but as found on a keyboard layout, not in the
* word itself. Additionally, variations on single character capitalization
* will be yielded.
*
* @param word - The word to yield the permutations of.
* @param layout - The layout string, with rows of the keyboard separated
* by `|` pipe characters.
*/
export declare function badcharkey(word: string, layout: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word where a character has been removed
* from every position.
*/
export declare function extrachar(word: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word with a character inserted in every
* position, using a `TRY` string for determining which characters should
* be inserted.
*
* @param word - The word to yield of the permutations of.
* @param trystring - A string of characters which will be iterated through
* when inserting new characters.
*/
export declare function forgotchar(word: string, trystring: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word where a character has been moved 2, 3,
* or 4 positions backwards or forwards.
*/
export declare function movechar(word: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word where a character has been replaced by
* one of the characters found in the `TRY` string.
*
* @param word - The word to yield the permutations of.
* @param trystring - A string of characters which will be iterated through
* when replacing characters.
*/
export declare function badchar(word: string, trystring: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word where any repeated slice of two
* characters has been removed. e.g. `vacacation` to `vacation`.
*/
export declare function doubletwochars(word: string): Generator<string, void, unknown>;
/**
* Yields the permutations of a word where it has been split with a space
* in every position.
*/
export declare function twowords(word: string): Generator<string[], void, unknown>;