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

  • Homebrew - package manager for MacOS
  • pip - package manager for Python

Installation

  • Install hunspell library and tools
brew install hunspell
$ 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