import { OverridableAffData } from "./aff/index"; export type { AffData, Flag, Flags, FlagSet, OverridableAffData } from "./aff"; export type { LookupResult } from "./lookup"; export interface EspellsInitOpts { /** Source of a `.aff` affix file. */ aff: string | Uint8Array; /** A source for a single or array of `.dic` files. */ dic: string | Uint8Array | (string | Uint8Array)[]; /** * An object that allows for overriding certain properties in the `.aff` data. * * @see {@link OverridableAffData} * @see {@link AffData} */ override?: OverridableAffData; } /** * Espells spellchecker. Instances of this class are fully instantiated * when created and do not need any special init functions called. */ export declare class Espells { /** The {@link Aff} instance for the spellchecker. */ private aff; /** The {@link Dic} instance for the spellchecker. */ private dic; /** The {@link Lookup} instance for the spellchecker. */ private lookuper; /** The {@link Suggest} instance for the spellchecker. */ private suggester; constructor({ aff, dic, override }: EspellsInitOpts); /** * Creates an {@link ESpells} instance from URL strings rather than raw * sources. Uses fetch, assumes the given URL can be decoded into a * string of text. */ static fromURL(opts: { aff: string; dic: string | string[]; } & EspellsInitOpts): Promise; /** * Adds a dictionary (or array of dictionaries) to the current instance. * * @param dic - The dictionary (or dictionaries) to add. */ addDictionary(dic: string | Uint8Array | (string | Uint8Array)[]): void; /** Adds a word to the spellchecker's dictionary. */ add(stem: string): void; /** Removes a word from the spellchecker's dictionary. */ remove(stem: string): void; /** * Determines if a word meets three different criteria: * * - If the word is spelled correctly * - If the word has been marked as forbidden * - If the word has been marked as `WARN` * * These are the `correct`, `forbidden`, and `warn` properties of the * returned object, respectively. * * @param word - The word to check. * @param caseSensitive - If true, the spellchecker will consider the * capitalization of the word given. Defaults to true. */ lookup(word: string, caseSensitive?: boolean): import("./lookup").LookupResult; /** * Returns suggestions for a word, even if it isn't misspelled. * * @param word - The word to get the suggestions of. * @param max - The maximum number of suggestions to return. Defaults to 8. */ suggest(word: string, max?: number): string[]; /** * Returns the stems for a word, which are all of the potential "base * forms" of a word, which will have various suffixes or prefixes * attached to that base to make the given word. * * If the word given is misspelled, the array of stems returned will just be empty. * * @param word - The word to get the stems of. * @param caseSensitive - If true, the spellchecker will consider the * capitalization of the word given. Defaults to true. */ stems(word: string, caseSensitive?: boolean): string[]; /** * Returns the "morphological data" for a word. This data is basically * just a map of keys and values, representing some sort of metadata * attached to a stem. e.g. a potential key-value could be `is:gendered` * (for some languages), which could be checked like: * * ```ts * const gendered = * espells.data("word").get("is")?.has("gendered") ?? false * ``` * * The reason for there being a `Set` assigned to a key is because you * could have multiple values under the `"is"` key, like `is:x`, `is:y`, etc. * * It should also be noted that this function takes care to get every * stem of the word, and then merge the morphological data for every * stem, which is what is finally returned. If you want to take more care * than that, and get only the data attached to a specific stem, you * could use the {@link Espells.stems} function first, and use one of the * stems it returns. * * The last detail to mention is that if the word is misspelled, the map * returned will just be empty. * * @param word - The word to get the data of. * @param caseSensitive - If true, the spellchecker will consider the * capitalization of the word given. Defaults to true. */ data(word: string, caseSensitive?: boolean): Map>; }