@dcoffey/espells
Version:
Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.
54 lines (53 loc) • 1.85 kB
TypeScript
import type { Prefix, Suffix } from "../aff/affix.js";
import type { Word } from "../dic/word.js";
import { LKWord } from "./lk-word.js";
export interface AffixFormOpts {
/** Outermost prefix. */
prefix?: Prefix;
/** Outermost suffix. */
suffix?: Suffix;
/** Innermost prefix. */
prefix2?: Prefix;
/** Innermost suffix. */
suffix2?: Suffix;
/** The word as found in the spellchecker's dictionary. */
inDictionary?: Word;
}
/**
* Represents a hypothesis of how a word may be represented as a
* {@link Prefix}, stem, and {@link Suffix}. A word always has a full text
* and stem, but may optionally have up to two prefixes and suffixes.
* Instances with no actual affixes are valid, as well.
*/
export declare class AffixForm {
/** The full text of the word. */
text: string;
/** The hypothesized stem of the word. */
stem: string;
/** Outermost prefix. */
prefix?: Prefix;
/** Outermost suffix. */
suffix?: Suffix;
/** Innermost prefix. */
prefix2?: Prefix;
/** Innermost suffix. */
suffix2?: Suffix;
/** The word as found in the spellchecker's dictionary. */
inDictionary?: Word;
constructor(text: string | LKWord, stem?: string, { prefix, suffix, prefix2, suffix2, inDictionary }?: AffixFormOpts);
/**
* Returns a new {@link AffixForm}, cloned from this current instance, but
* with any properties given replaced.
*/
replace(opts: {
text?: string | LKWord;
stem?: string;
} & AffixFormOpts): AffixForm;
/** True if the form has any affixes. */
get hasAffixes(): boolean;
/** The complete set of flags this form has. */
get flags(): Set<string>;
/** Returns every {@link Prefix} and {@link Suffix} this form has. */
affixes(): (Prefix | Suffix)[];
has(flag: string): boolean;
}