Careylq/spell/src/spell does not have a README file

    SpellError

    The error raised when a dictionary cannot be built.

    It wraps whichever parser failed, so the caller keeps the original line number and message.
    impl Show for SpellError

    SpellError::output

    fn SpellError::output(self : SpellError, logger : &Logger) -> Unit

    SpellError::to_string

    fn SpellError::to_string(self : SpellError) -> String

    Dictionary

    pub struct Dictionary {
    entries : Map[String, Array[Array[String]]]
    prefix_rules : Array[SpellRule]
    suffix_rules : Array[SpellRule]
    forbiddenword : String?
    keepcase : String?
    needaffix : String?
    onlyincompound : String?
    circumfix : String?
    compound_flag : String?
    compound_begin : String?
    compound_end : String?
    compound_middle : String?
    compound_permit : String?
    compound_forbid : String?
    forceucase : String?
    compound_rules : Array[String]
    check_compound_pattern : Array[String]
    check_compound_dup : Bool
    check_compound_triple : Bool
    check_compound_simplified_triple : Bool
    check_compound_case : Bool
    compound_word_max : Int
    compound_syllable_max : Int
    compound_syllable_vowels : String
    check_compound_rep : Bool
    blocked_compounds : Map[String, Bool]
    compound_min : Int
    word_chars : String
    try_chars : String
    keyboard : String
    replacements : Array[
    Replacement
    ]
    suggestion_replacements : Array[
    Replacement
    ]
    map_groups : Array[String]
    phone_rules : Array[
    PhoneRule
    ]
    phonet : PhonetTable
    iconv : Array[
    Conversion
    ]
    oconv : Array[
    Conversion
    ]
    nosuggest : String?
    ignore_chars : Array[Char]
    check_sharps : Bool
    complex_prefixes : Bool
    break_patterns : Array[String]
    encoding : String
    flag_type :
    FlagType

    turkic : Bool
    rule_count : Int
    }

    A parsed, indexed dictionary that can judge words.

    Build one with Dictionary::from_text. Parsing and indexing happen once, so check is cheap enough to call for every word of a document.

    The type is opaque: the index representation is an implementation detail and may change. Use the accessors below to inspect the loaded file.

    Dictionary::apply_oconv

    fn Dictionary::apply_oconv(self : Dictionary, text : String) -> String

    Apply the .aff OCONV output-conversion table to text.

    Hunspell only ever converts output with this table — the spell-checking judgement is unaffected — so the suggestion engine calls this on each suggestion it is about to return.

    Dictionary::check

    fn Dictionary::check(self : Dictionary, word : String) -> Bool

    Is word correct according to this dictionary?

    The .aff ICONV input conversions are applied to word first, then IGNORE characters are removed, exactly as they were removed from the dictionary's entries when it was built. (Conversion comes first so that a rule may map a character onto one that IGNORE then drops; the nepali suite needs precisely that.) ICONV is never applied to dictionary entries — see conversion.mbt for the probe that establishes it.

    The word is then classified by capitalisation. Exact-case forms are looked up directly, then through the affix rules, then through the compounds; Capitalised and ALL CAPS words additionally accept their folded forms, except that KEEPCASE entries only ever match their exact case.

    When . is declared in WORDCHARS, a failed word that ends in . is retried with its trailing dots removed, which is how abbreviations such as etc. are accepted.

    A line holding several whitespace-separated words is correct when every word on it is correct on its own (check_word_group).

    An empty word is never correct (the CLI skips empty input lines entirely).

    Dictionary::encoding

    fn Dictionary::encoding(self : Dictionary) -> String

    The SET encoding declared by the .aff file, or "" when absent.

    Dictionary::entry_count

    fn Dictionary::entry_count(self : Dictionary) -> Int

    How many distinct words the word list holds.

    Dictionary::flag_type

    The FLAG mode declared by the .aff file (SingleChar when absent).

    Dictionary::from_text

    fn Dictionary::from_text(aff_text : String, dic_text : String) -> Dictionary raise SpellError

    Parse .aff and .dic text and build an indexed dictionary.

    Raises SpellError when either file is malformed. A leading UTF-8 BOM (U+FEFF) on either text is ignored, because real dictionaries sometimes carry one.

    The .dic flags are decoded with the .aff file's FLAG mode; when the .aff declares an AF alias table the .dic holds alias numbers, so the numbers are resolved to the same strings that PFX/SFX rule flags were resolved to.

    Dictionary::is_no_suggest

    fn Dictionary::is_no_suggest(self : Dictionary, word : String) -> Bool

    Is word itself marked NOSUGGEST, so that it must never be offered as a suggestion? Only a direct .dic entry is considered.

    Dictionary::keyboard

    fn Dictionary::keyboard(self : Dictionary) -> String

    The KEY keyboard layout, or "" when the .aff file had none.

    Rows are separated by |; the suggestion engine uses adjacency on this layout to rank candidates.

    Dictionary::map_groups

    fn Dictionary::map_groups(self : Dictionary) -> Array[String]

    The MAP groups verbatim, in source order; empty when the .aff file has none. Each entry is one MAP body line, e.g. uü or ß(ss).

    Dictionary::phone_rules

    The PHONE rules in source order; empty when the .aff file has none.

    Dictionary::phonetic_key

    fn Dictionary::phonetic_key(self : Dictionary, word : String) -> String

    The phonetic key of word under the dictionary's PHONE table, or "" when the table is absent (no PHONE line in the .aff file).

    Dictionary::phonetic_words

    fn Dictionary::phonetic_words(self : Dictionary, word : String) -> Array[String]

    The dictionary words whose phonetic key equals that of word, in dictionary order. Empty when the .aff file has no PHONE table.

    Dictionary::replacements

    The REP replacement pairs, in source order.

    _ stands for a space, exactly as it does in the file; the suggestion engine is what interprets it.

    Dictionary::rule_count

    fn Dictionary::rule_count(self : Dictionary) -> Int

    How many PFX/SFX rule lines the .aff file declared.

    Dictionary::suggestion_replacements

    The full suggestion replacement table: REP followed by the rules derived from the .dic ph: fields, in source order.

    Dictionary::try_chars

    fn Dictionary::try_chars(self : Dictionary) -> String

    The TRY characters the .aff file declared, or "" when it had none.

    The suggestion engine substitutes and inserts only these characters (falling back to a plain ASCII alphabet when the list is empty).

    Dictionary::word_chars

    fn Dictionary::word_chars(self : Dictionary) -> String

    The WORDCHARS characters the .aff file declared, or "" when it had none.

    PhonetRule

    pub struct PhonetRule {
    base : Array[Char]
    class_chars : Array[Char]
    has_class : Bool
    dashes : Int
    follow : Bool
    start_anchor : Bool
    end_anchor : Bool
    priority : Int
    replacement : String
    }

    One parsed PHONE rule. This is an implementation detail of the index (Dictionary is opaque), so a caller never constructs one.

    PhonetTable

    pub struct PhonetTable {
    by_initial : Map[Char, Array[PhonetRule]]
    index : Map[String, Array[String]]
    }

    The phonetic table of a dictionary: the rules grouped by their first character (so a lookup at one position only tests plausible rules) and the key -> words index built once at load time.

    SpellRule

    pub struct SpellRule {
    rule :
    AffixRule

    cont_flags : Array[String]
    }

    A PFX/SFX rule as the judgement engine needs it: the rule with the continuation-flag list cut off its add text, plus that list as flags.

    SFX A 0 s/123 . adds s and gives the derived form the flags 1, 2 and 3; chaining a second affix through those flags is what cont_flags enables.

    The type is an implementation detail of the index (Dictionary is opaque), so it is never constructed by a caller.