Ferrolex 0.4, a spell checker for Rust
Your dictionaries. A Rust spell checker.Hunspell’s dictionaries, read by an independent engine.
Editors, linters and CI checks all need to know whether a word is spelled right, and what was probably meant when it is not. Open dictionaries for many languages come in the Hunspell format: a word list plus a file of spelling rules. Ferrolex is a Rust library and command-line tool that reads those dictionaries, checks words and suggests corrections, without linking the Hunspell C++ library. It is alpha: the interfaces may still change, and its compatibility is measured locale by locale.
- 18LibreOffice dictionaries in the reviewed catalog
- 11 of 12tested locales that pass their strict import and word checks
- Samesuggestions in the same order on every machine
- Rust 1.94+MIT or Apache-2.0, alpha
A dictionary is a word list and its rules.
A spell checker does not store every word a language can form. English alone has walk, walks, walked and walking; German and Hungarian build far more forms from one word. A Hunspell dictionary comes as two files instead: a word list, in which each word carries a few letters that name the rules it takes, and a rules file that says what those rules add or remove.
The LibreOffice English dictionary stores 49,568 words and reaches many more through its rules. To check a word, Ferrolex looks for a stored word and a rule that leads from it to the spelling in front of it. Choose a word below to see the path it found, or why it found none.
- Verdict
- Accepted
- Stored word
rewrite- Rule
- The suffix rule removes e and adds ing at the end.
- Capitals
- Matched as written.
Real output of ferrolex-hunspell 0.4.0, with the LibreOffice English dictionary (en_US.aff and en_US.dic, 49,568 stored words) at upstream commit f2ff990. The explanation API is marked experimental.
Check the words. Get the same suggestions every time.
Your tool hands over the words it wants checked. Ferrolex says which ones the dictionary accepts and suggests corrections for the rest, in the same order on every machine.
Suggestions are ranked by how few changes they need, weighed with the dictionary’s own hints about likely typos, then alphabetically. Nothing depends on the machine or the operating system, so a test that expects a suggestion today still finds it tomorrow and in CI.
Ferrolex does not split text into words; the editor, linter or CI check that calls it knows its format and decides what counts as a word. Switch between the two languages below to see what the released engine answers for a short sentence in each.
Thecorrecteditorcorrectrecievednot in the dictionaryreceived1receded2receive2receiver2receives2recited2relieve2reliever2
Stopped at the comparison budget; these are the best found until then.
acorrectmesagenot in the dictionarymenage1message1Meade2Mesa2Mesa's2Mesabi2Osage2Presage2
Stopped at the comparison budget; these are the best found until then.
aboutcorrectspelingnot in the dictionaryspelling1Peking2Sterling2dueling2feeling2fueling2heeling2keeling2
Stopped at the comparison budget; these are the best found until then.
incorrectPariscorrect
Real output of ferrolex-hunspell and ferrolex-suggest 0.4.0 with the LibreOffice English dictionary and the default limits. The number beside a suggestion is its edit distance. The program that wrote these results runs every check twice and stops if the two answers differ.
Every search has a budget, and says when it ran out.
A large dictionary holds hundreds of thousands of words. Ferrolex caps the work a suggestion may take and reports whether the search finished.
An editor checks as you type, so one misspelling must not stall it. Ferrolex never expands a whole dictionary in advance and stops at the limits you set. Its answer then carries a plain statement: complete, or stopped at a named limit with the best suggestions found until then.
Below, the same misspelling, recieved, is searched under three budgets. The default budget stops before it has seen every candidate and says so; a larger one finishes the search. You choose which is right for your tool.
- Dictionary words it may look at
- 100,000
- Letter comparisons it may make
- 1,000,000
- Most edits a suggestion may need
- 2
- Most suggestions it returns
- 8
received1receded2receive2receiver2receives2recited2relieve2reliever2
Stopped at the comparison budget; these are the best found until then.
Real output of ferrolex-suggest 0.4.0 with the LibreOffice English dictionary. The larger budget allows 20 times the letter comparisons of the default, finishes the search, and returns the same eight suggestions.
Choose the data you ship.
Ferrolex bundles no dictionary. A reviewed catalog names 18 LibreOffice dictionaries, each pinned to its exact bytes, and installs one only when you ask.
Dictionaries are data with their own authors and licenses, and a product that ships one has to know which version it ships. Ferrolex keeps that choice with you: it never downloads or updates a dictionary while it checks, and every file it installs must match the digest recorded in the catalog.
- Installed on request
ferrolex dictionary installdownloads a pair into a folder you name and refuses any file whose bytes differ from the catalog.- A license for each language
- Every entry names its reviewed license and links the upstream notice. The English dictionary is GPL-2.0-only, for example; the engine itself stays MIT or Apache-2.0.
- Compiled for shipping
- Compile a word list or a Hunspell pair into one file, then validate that file before you load it.
- Your own words
- Layer a project word list over any dictionary. The command line picks up .ferrolex/words.txt on its own.
Measured locale by locale.
Ferrolex is alpha. Instead of claiming Hunspell compatibility in general, the project tests each dictionary it supports and publishes the result.
For every locale in the test set, the exact upstream dictionary is imported strictly and a reviewed list of word forms is checked against it. CI repeats this on relevant changes and before every release. 11 of the 12 locales pass; Hungarian is in progress.
Passing these checks is not full Hunspell parity. German shows the gap: the dictionary imports, and ordinary words and their forms work, but in Ferrolex 0.4.0 compound words such as Wörterbuch are not recognized from this dictionary yet, as the first example above shows.
- English (United States)
en_USReady - German (Germany)
de_DEReady - Spanish (Spain)
es_ESReady - French (France)
fr_FRReady - Italian (Italy)
it_ITReady - Portuguese (Brazil)
pt_BRReady - Portuguese (Portugal)
pt_PTReady - Dutch (Netherlands)
nl_NLReady - Hungarian (Hungary)
hu_HUIn progress - Arabic
arReady - Turkish (Türkiye)
tr_TRReady - Polish (Poland)
pl_PLReady
From the status the repository generates for its README. Every locale, its source and its known limits
Where it sits among spell checkers.
Several libraries read Hunspell dictionaries. Ferrolex is an independent Rust engine with bounded, repeatable suggestions, compiled dictionaries and a digest-pinned catalog.
- Hunspell
- The C++ library and command-line tool that defined the format, used by LibreOffice, Firefox and Chrome. Ferrolex checks its own accept and reject decisions against it.
- nspell
- A JavaScript spell checker for Hunspell dictionaries that covers much of Hunspell’s core, for browsers and Node.js.
- Spellbook
- A Rust library compatible with the Hunspell dictionary format, from the team behind the Helix editor.
Many more spell checkers exist, from Aspell to those built into operating systems. An overview of the field
A focused engine. Your tool around it.
Ferrolex is a spell checker. It checks spelling in prose and in code, and gives the same suggestions every time. For editors, linters, and CI checks. It owns the dictionaries, the checks and the suggestions; your tool knows its own format and decides which words to check.
- Rust library and command line
- Import dictionaries, check words, explain a verdict, suggest corrections and compile dictionaries, from Rust or from the ferrolex command.
- Not on crates.io yet
- Releases are tagged on GitHub. Install the command line from the repository:
cargo install --locked --git https://github.com/sebastian-software/ferrolex ferrolex-cli - Node.js
- A binding is built and tested with every release, but it is not published to npm yet. C, Python and editor integrations are prototypes.
- Not included
- Splitting documents or source code into words, and editor protocols. Format-aware tools extract the words and call Ferrolex.
Hunspell set the dictionary standard. Ferrolex reads those dictionaries with its own engine, written in Rust. It is one of the Ferramenta engines, made by Sebastian Software in Mainz, Germany.
Start with the words you have.
Check a plain word list first, then install the Hunspell dictionary your users write in. Both work from the command line and from Rust.
GitHub repositoryDocumentationChangelogIntegration and support