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
.
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 theLOADED 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
python -c 'import enchant;print(*enchant.list_dicts(), sep="\n")'
. – don_crissti Feb 28 '15 at 17:21