@dcoffey/espells
Version:
Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.
102 lines (101 loc) • 3.7 kB
TypeScript
import type { Reader } from "../reader.js";
import { Casing } from "./casing.js";
import { CompoundPattern } from "./compound-pattern.js";
import { CompoundRule } from "./compound-rule.js";
import { ConvTable } from "./conv-table.js";
import { PhonetTable } from "./phonet-table.js";
import { RepPattern } from "./rep-pattern.js";
import type { AffData, CharacterMap, Flag, Flags, FlagSet, OverridableAffData, PrefixIndex, PrefixMap, SuffixIndex, SuffixMap } from "./types.js";
export type { Flag, CharacterMap, PrefixMap, SuffixMap, PrefixIndex, SuffixIndex, Flags, FlagSet, AffData, OverridableAffData };
/** A resolved and parsed representation of the data found in a Hunspell `.aff` file. */
export declare class Aff implements AffData {
SET: string;
FLAG: "short" | "long" | "numeric" | "UTF-8";
LANG?: string;
WORDCHARS?: string;
IGNORE?: Set<string>;
CHECKSHARPS: boolean;
FORBIDDENWORD?: string;
KEY: string;
TRY: string;
NOSUGGEST?: Flag;
KEEPCASE?: Flag;
REP: Set<RepPattern>;
MAP: CharacterMap;
NOSPLITSUGS: boolean;
PHONE?: PhonetTable;
MAXCPDSUGS: number;
MAXNGRAMSUGS: number;
MAXDIFF: number;
ONLYMAXDIFF: boolean;
PFX: PrefixMap;
SFX: SuffixMap;
NEEDAFFIX?: Flag;
CIRCUMFIX?: Flag;
COMPLEXPREFIXES: boolean;
FULLSTRIP: boolean;
BREAK: Set<RegExp>;
COMPOUNDRULE: Set<CompoundRule>;
COMPOUNDMIN: number;
COMPOUNDWORDMAX?: number;
COMPOUNDFLAG?: Flag;
COMPOUNDBEGIN?: Flag;
COMPOUNDMIDDLE?: Flag;
COMPOUNDEND?: Flag;
ONLYINCOMPOUND?: Flag;
COMPOUNDPERMITFLAG?: Flag;
COMPOUNDFORBIDFLAG?: Flag;
FORCEUCASE?: Flag;
CHECKCOMPOUNDCASE: boolean;
CHECKCOMPOUNDDUP: boolean;
CHECKCOMPOUNDREP: boolean;
CHECKCOMPOUNDTRIPLE: boolean;
CHECKCOMPOUNDPATTERN: Set<CompoundPattern>;
SIMPLIFIEDTRIPLE: boolean;
COMPOUNDSYLLABLE?: [number, string];
COMPOUNDMORESUFFIXES: boolean;
COMPOUNDROOT?: Flag;
ICONV?: ConvTable;
OCONV?: ConvTable;
AF: Flags[];
AM: Set<string>[];
WARN?: Flag;
FORBIDWARN: boolean;
SYLLABLENUM?: string;
SUBSTANDARD?: Flag;
/**
* The {@link Casing} instance for this data. Usually just a normal
* {@link Casing} instance, but it may also be {@link GermanCasing},
* {@link TurkicCasing}, or something else entirely depending on configuration.
*/
casing: Casing;
/** An index, more specifically a {@link Trie}, of {@link Prefix}es. */
prefixesIndex: PrefixIndex;
/** An index, more specifically a {@link Trie}, of {@link Suffix}es. */
suffixesIndex: SuffixIndex;
/**
* @param reader - The {@link Reader} instance to parse with.
* @param override - An optional object which allows for overriding
* whatever {@link AffData} that was parsed with something else.
*/
constructor(reader: Reader, override?: OverridableAffData);
/** Parses a string and returns the first {@link Flag} found. */
parseFlag(flag: string): Flag;
/** Parses a string and returns the {@link Flags} found. */
parseFlags(flags: string | string[]): Flags;
/**
* Utility for handling special cases involving the `CHECKSHARPS`
* directive. Returns false if the directive itself is disabled, but
* otherwise will determine if the given word contains a `ß`.
*
* @param word - The word to check.
*/
isSharps(word: string): boolean;
/**
* Utility for applying the {@link Aff.IGNORE} transformation to a string.
* Does nothing if the `IGNORE` directive isn't present.
*
* @param str - The string to transform.
*/
ignore(str: string): string;
}