From hunspell man page:
...
When in the -a mode, hunspell will also accept lines of single
words prefixed with any of '*', '&', '@', '+', '-', '~', '#',
'!', '%', '`', or '^'. A line starting with '*' tells hunspell
to insert the word into the user's dictionary (similar to the I
command).
...
I tried something like: echo "* my_word" | hunspell -a
but the word is not in my dictionary as parsing sample file again shows it as misspelled word
How does this work, how can I add custom word?
Or with Aspell, or any "common" program that writes to compatible dictionaries read by Hunspell/Aspell?
Best Answer
I think instead of
(similar to the I command)
it should be(similar to the A command)
:Let's check the
man
page again:So, when in
-a mode
,hunspell
session ends after reading and processing the last line of input. Furthermore,Prefixing a single word line with
*
(note there should be no space between word and prefix) will add that word to the user's dictionary but only for the currenthunspell
session, since, as per theman
page, only a line prefixed with#
will cause the personal dictionary to be saved (the on-disk file, that is). Hence runningdoes absolutely nothing.
hunspell
adds goosfraba to the dictionary for this session then exits (no other lines to process). You have to add a second line prefixed with#
in order to save the recently added word(s):Let's see:
::spell-checking goosfraba:
& =
Word
is not in the dictionary, there is one near miss: goofball.::adding goosfraba to the dictionary then spell-checking during the same
hunspell
session (two lines):* =
Word
is in the dictionary.::spell-checking goosfraba again (new
hunspell
session):& = Again,
word
is not in the dictionary (nothing was saved during the previous session)::adding goosfraba to the dictionary and saving during the same
hunspell
session (two lines):::spell-checking goosfraba again (new
hunspell
session):* =
Word
is in the dictionary.