spellkit 0.3.0

Bindings to your friendly neighborhood spellchecker.
Documentation

spellkit

CI

Native spell checking with a small Rust API.

This project is based on euclio/spellbound (last upstream commit 2020).

Platform API
macOS NSSpellChecker
Windows ISpellChecker
*nix hunspell

Example

use spellkit::Checker;

fn main() -> Result<(), spellkit::Error> {
    let checker = Checker::new()?;
    // Or: Checker::with_locale("en-US")?;

    for err in checker.check("I beleeve I can fly") {
        println!("{} @ {}..{}", err.text(), err.start(), err.end());
        for suggestion in checker.suggest(err.text()) {
            println!("{suggestion}");
        }
    }
    Ok(())
}

Checker::new() defaults to English (en_US / en_GB on Linux, en-US on Windows). Use with_locale for another language. Locales may be written as en_US or en-US.

Unknown or unsupported locales behave differently by platform:

  • Linux: missing dictionary / unknown locale → Error::Unavailable
  • macOS: empty locale → Error::Unavailable; unknown tags may still create a checker (system fallback)
  • Windows: unsupported language tag → Error::Unavailable

Threading

macOS serializes access to the shared NSSpellChecker. Do not assume Checker is Send / Sync across platforms.

Linux

Needs a hunspell dictionary on disk (default search includes /usr/share/hunspell). Example:

  • Arch: pacman -S hunspell hunspell-en_us
  • Debian/Ubuntu: apt install libhunspell-dev hunspell-en-us

Without a dictionary, Checker::new() returns Error::Unavailable.

License

MIT OR Apache-2.0

Credits

Originally by Andy Russell. Maintained as spellkit by Robert Mongold.