hunspell:从命令行将单词添加到字典中

zet*_*tah 6 spell-checking hunspell

hunspell 手册页

...
    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).
...
Run Code Online (Sandbox Code Playgroud)

我尝试过类似的事情:echo "* my_word" | hunspell -a但是这个词不在我的字典中,因为解析示例文件再次将其显示为拼写错误的词

这是如何工作的,如何添加自定义单词?
或者使用 Aspell,或者任何写入 Hunspell/Aspell 读取的兼容词典的“通用”程序?

don*_*sti 5

我认为而不是(similar to the I command)它应该是(similar to the A command)

A

Accept the word for the rest of this hunspell session. 
Run Code Online (Sandbox Code Playgroud)

让我们man再次检查页面:

The -a option is intended to be used from other programs through a pipe.
In this mode, hunspell prints a one-line version identification message,
and then begins reading lines of input.
Run Code Online (Sandbox Code Playgroud)

因此,当 in 时-a modehunspell会话在读取和处理最后一行输入后结束。此外,

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)[........] A line prefixed with '#' will cause the
personal dictionary to be saved.
Run Code Online (Sandbox Code Playgroud)

为单个单词行*添加前缀(注意单词和前缀之间不应有空格)将将该单词添加到用户的字典中,但仅适用于当前hunspell会话,因为根据man页面,只有前缀为 的行#才会导致个人字典要保存(即磁盘文件)。因此运行

echo "*goosfraba" | hunspell -a
Run Code Online (Sandbox Code Playgroud)

什么都不做。hunspellgoosfraba添加到此会话的字典中,然后退出(无需处理其他行)。您必须添加以 为前缀的第二行以#保存最近添加的单词:

A

Accept the word for the rest of this hunspell session. 
Run Code Online (Sandbox Code Playgroud)

让我们来看看:

::拼写检查goosfraba

echo -e "goosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
& goosfraba 1 0: goofball
Run Code Online (Sandbox Code Playgroud)

& =Word不在字典里,有一个差点错过:goofball

::将 goosfraba 添加到字典中,然后在同一hunspell会话中进行拼写检查(两行):

echo -e "*goosfraba\ngoosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
*
Run Code Online (Sandbox Code Playgroud)

* =Word在字典里。

::再次对goosfraba 进行拼写检查(新hunspell会话):

echo -e "goosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
& goosfraba 1 0: goofball
Run Code Online (Sandbox Code Playgroud)

& = 同样,word不在字典中(在上一个会话期间没有保存任何内容)

::将 goosfraba 添加到字典并在同一hunspell会话期间保存(两行):

echo -e "*goosfraba\n#" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
Run Code Online (Sandbox Code Playgroud)

::再次对goosfraba 进行拼写检查(新hunspell会话):

echo "goosfraba" | hunspell -a
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
*
Run Code Online (Sandbox Code Playgroud)

* =Word在字典里。