4

Is there some way to list all available dictionaries in hunspell? Something like aspell dump dicts. printf | hunspell -D prints too much junk, and I want to query hunspell itself, not do something like find /usr/share/myspell/dicts/ -name '*.dic' | cut -d '/' -f 6 | cut -d '.' -f 1 | sort.

  • You could look into pyenchant, e.g. a basic example: python -c 'import enchant;print(*enchant.list_dicts(), sep="\n")'. – don_crissti Feb 28 '15 at 17:21
3

How about this:

LANG=C </dev/null hunspell -D|&sed -n '/AVAILABLE DICTIONARIES/,/LOADED DICTIONARIES/p'|awk -F / '/\// { print $NF }'|sort -u

This drops the hunspell search path from the output and lists only available dictionary names. If you want to remove hyphenation dictionaires you can add |grep -v hyph...

  • Nice, but this gets a bit kludgy if you want it to be reliable: It needs an echo | at the start to terminate the input stream, it should handle the case of no dictionaries (Is there a heading in that case?) or a single dictionary (Is that heading singular?), and it needs to stop before the LOADED DICTIONARY line if it exists (or EOF if it doesn't). – l0b0 Mar 1 '15 at 9:37
  • Looking at the source code, there always is an "AVAILABLE DICTIONARIES" heading even if no dictionaries are installed, and it doesn't change for a single dictionary; but it is locale-dependent. I'll update my answer accordingly (and with < /dev/null to handle the input stream). – Stephen Kitt Mar 1 '15 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.