Installing hunspell on MacOS
Hunspell is a spell checker library written in C++. It also has bindings for other languages. This guide covers installation of python library on MacOS.
Requirements
Installation
- Install hunspell library and tools
brew install hunspell
-
Download dictionaries from http://wordlist.aspell.net/dicts/ and put them to
/Library/Spelling/
. -
Check that
hunspell
is able to load them:
$ hunspell -D
LOADED DICTIONARY:
/Library/Spelling/en_US.aff
/Library/Spelling/en_US.dic
- Install python bindings
export C_INCLUDE_PATH=/usr/local/include/hunspell
sudo ln -sf /usr/local/lib/libhunspell-1.4.a /usr/local/lib/libhunspell.a
pip install hunspell
- Verify that it works
>>> import hunspell
>>> hobj = hunspell.HunSpell('/Library/Spelling/en_US.dic', '/Library/Spelling/en_US.aff')
>>> hobj.suggest('spookie')
['spookier', 'spookiness', 'spook', 'cookie', 'bookie', 'Spokane', 'spoken']
Reference
hunspell
home page - https://github.com/blatinier/pyhunspellpyhunspell
- https://github.com/blatinier/pyhunspell