hunspell
Version, currently 0.8.09 versions
github.com/mamantoha/crystal-hunspell
Crystal bindings for Hunspell.
Installation
# Add this to your shard.yml
dependencies:
hunspell:
github: mamantoha/crystal-hunspell
version: ~> 0.8.0Then run:
shards installshard.yml
- Crystal
>= 1.0.0- License
- MIT
- Author
- Anton Maminov
Dependencies
Development Dependencies
- crystal_lib*github: crystal-lang/crystal_libdev
README
crystal-hunspell
Crystal bindings for Hunspell.
Installation
Before installing crystal-hunspell ensure you have hunspell already installed:
-
Add the dependency to your
shard.yml:dependencies: hunspell: github: mamantoha/crystal-hunspell -
Run
shards install
Usage
The library has been tested with Hunspell version 1.7.2.
require "hunspell"
Open a dictionary:
hunspell = Hunspell.new("/usr/share/hunspell/en_US.aff", "/usr/share/hunspell/en_US.dic")
or
hunspell = Hunspell.new("en_US")
Ensure to close Hunspell instance after using.
hunspell.close
Below are some simple examples for how to use the repository.
Spelling
It's a simple task to ask if a particular word is in the dictionary.
hunspell.spell?("correct")
# => true
hunspell.spell?("incorect")
# => false
This will only ever return true or false, and won't give suggestions about why it might be wrong. It also depends on your choice of dictionary.
Suggestions
If you want to get a suggestion from Hunspell, it can provide a corrected label given a basestring input.
hunspell.suggest("arbitrage")
# => ["arbitrage", "arbitrages", "arbitrager", "arbitraged", "arbitrate"]
Suffix Match
hunspell.suffix_suggest("do")
# => ["doing", "doth", "doer", "dos", "do's", "doings", "doers"]
Stemming
The module can also stem words, providing the stems for pluralization and other inflections.
hunsell.stem("fishing")
# => ["fishing", "fish"]
Analyze
Like stemming but return morphological analysis of the input instead.
hunspell.analyze("permanently")
# => [" st:permanent fl:Y"]
Bulk Requests
You can also request bulk actions against Hunspell. Currently suggest, suffix_suggest, stem, and analyze are bulk requestable.
hunspell.bulk_suggest(["correct", "incorect"])
# => {"correct" => ["correct", "corrects", "cor rect", "cor-rect"],
# "incorect" => ["incorrect", "correction", "corrector", "injector", "correct"]}
hunspell.bulk_suffix_suggest(["cat", "do"])
# => {"cat" => ["cats", "cat's"],
# "do" => ["doing", "doth", "doer", "dos", "do's", "doings", "doers"]}
hunspell.bulk_stem(["stems", "currencies"])
# => {"stems" => ["stem"], "currencies" => ["currency"]}
hunspell.bulk_analyze(["dog", "permanently"])
# => {"dog" => [" st:dog"], "permanently" => [" st:permanent fl:Y"]}
Development
sudo apt install libclang-dev libhunspell-dev
Generate new bindings for Hunspell
crystal ./lib/crystal_lib/src/main.cr src/hunspell/lib_hunspell.cr.in > src/hunspell/lib_hunspell.cr
Contributing
- Fork it (https://github.com/mamantoha/crystal-hunspell/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Anton Maminov - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.8.0- Tagged
- May 15, 2024
- Commit
4ebd715027a5- Crystal
>= 1.0.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/mamantoha/crystal-hunspell
Metadata
- Created
- Aug 13, 2026
- Updated
- Nov 20, 2026
- Synced
- Nov 20, 2026
- Versions
- 9