hunspell:コマンドラインから辞書に単語を追加する

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).
...

私は次のように試しましたが、echo "* my_word" | hunspell -aサンプルファイルを再解析すると、その単語はスペルミスの単語として表示されるため、その単語は私の辞書にありません。

どのように機能し、カスタム単語を追加するにはどうすればよいですか?
または、AspellまたはHunspell / Aspellが読み取る互換性のある辞書を作成する「汎用」プログラムを使用しますか?

ベストアンサー1

(similar to the I command)私は次のようにすべきだと思います(similar to the A command)

A

Accept the word for the rest of this hunspell session. 

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.

これにより、-a mode入力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)[........] A line prefixed with '#' will cause the
personal dictionary to be saved.

単一の単語行にプレフィックスを追加すると*(単語とプレフィックスの間にスペースを含めないでください)、その単語はユーザー辞書に追加されますが、現在のhunspellセッションにのみ追加されます。なぜなら、ページによると、manプレフィックスが付いた行だけが#追加されるからです。保存する個人辞書(ディスク上のファイルなど)に移動します。だから走る

echo "*goosfraba" | hunspell -a

何もしないでください。hunspell次へ追加ガスプラバこのセッションの辞書に移動して終了します(これ以上処理する行はありません)。#最近追加された単語を保存するには、プレフィックスを含む2行目を追加する必要があります。

echo -e "*goosfraba\n#" | hunspell -a

みましょう:

::スペルチェックガスプラバ:

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

&=はWord事前にありませんが、ほとんど発生したことがあります。愚かなボール

::goosfrabaを辞書に追加し、hunspell同じセッション中にスペルチェックを実行します(2行):

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

* =Word辞書にあります。

::スペルチェックガスプラバ再(新しいhunspellセッション):

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

& = 繰り返しますが、word辞書にはありません(以前のセッションでは何も保存されませんでした)。

:: goosfrabaを辞書に追加し、hunspell同じセッション中に保存します(2行):

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

::スペルチェックガスプラバ再(新しいhunspellセッション):

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

* =Word辞書にあります。

おすすめ記事