Shard Detail

hunspell v0.6.0

Crystal bindings for Hunspell.
crystal hunspell bindings wrapper

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development


hunspell:
  github: mamantoha/crystal-hunspell

Readme

crystal-hunspell

Build Status GitHub release License

Crystal bindings for Hunspell.

Installation

Before installing crystal-hunspell ensure you have hunspell already installed:

  1. Add the dependency to your shard.yml:

    dependencies:
      hunspell:
        github: mamantoha/crystal-hunspell
    
  2. Run shards install

Usage

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")

Check if a word is valid:

hunspell.spellcheck("crystal")
# => true

hunspell.spellcheck("cristal")
# => false

Find the stems of a word:

hunsell.stem("fishing")
# => ["fishing", "fish"]

Suggest alternate spellings for a word:

hunspell.suggest("arbitrage")
# => ["arbitrage", "arbitrages", "arbitrager", "arbitraged", "arbitrate"]

Ensure to close Hunspell instance after using.

hunspell.close

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

  1. Fork it (https://github.com/mamantoha/crystal-hunspell/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors