aspell
html および xml ファイルのパイプ モードでオフセットではなく行番号を出力できますか? aspell
この場合、閉じたタグを識別できないため(タグが次の行にある場合)、ファイルを1行ずつ読み取ることができません。
1910 次
4 に答える
4
これにより、スペルミスのあるすべての単語が行番号付きで出力されます。
# Get aspell output...
<my_document.txt aspell pipe list -d en_GB --personal=./aspell.ignore.txt |
# Proccess the aspell output...
grep '[a-zA-Z]\+ [0-9]\+ [0-9]\+' -oh | \
grep '[a-zA-Z]\+' -o | \
while read word; do grep -on "\<$word\>" my_document.txt; done
どこ:
- my_document.txt はオリジナルのドキュメントです
- en_GB は、主要な辞書の選択です (たとえば、en_US を試してください)。
- aspell.ignore.txt は aspell 個人用辞書です (以下の例)。
- aspell_output.txt は、パイプ モード (ispell スタイル) での aspell の出力です。
- result.txt は最終結果ファイルです
aspell.ignore.txt の例:
personal_ws-1.1 en 500
foo
bar
results.txt の出力例 (en_GB 辞書の場合):
238:color
302:writeable
355:backends
433:dataonly
最後grep -on
を に変更して、行全体を印刷することもできgrep -n
ます。
于 2011-06-19T18:57:46.800 に答える
1
これは単なるアイデアであり、まだ実際に試したことはありません (私は Windows マシンを使用しています :()。しかし、html ファイルをヘッド経由で (バイト制限付きで) パイプし、grep を使用して改行を数えて行を見つけることができるかもしれませんこれは効率的でもきれいでもありませんが、うまくいくかもしれません。
cat icantspell.html | head -c <offset from aspell> | egrep -Uc "$"
于 2011-06-18T04:36:43.883 に答える
0
aspell pipe
//入力行ごとに 1 つの空の行を出力します (行のエラーを報告した後) aspell -a
。ispell
awk を使用して行番号を出力するデモ:
$ aspell pipe < testFile.txt |
awk '/^$/ { countedLine=countedLine+1; print "#L=" countedLine; next; } //'
次の出力が生成されます。
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.7-20110707)
& iinternational 7 0: international, Internationale, internationally, internationals, intentional, international's, Internationale's
#L=1
*
*
*
& reelly 22 11: Reilly, really, reel, rely, rally, relay, resell, retell, Riley, rel, regally, Riel, freely, real, rill, roll, reels, reply, Greeley, cruelly, reel's, Reilly's
#L=2
*
#L=3
*
*
& sometypo 18 8: some typo, some-typo, setup, sometime, someday, smote, meetup, smarty, stupor, Smetana, somatic, symmetry, mistype, smutty, smite, Sumter, smut, steppe
#L=4
testFile.txt で
iinternational
I say this reelly.
hello
here is sometypo.
(それでもhunspell -u
( https://stackoverflow.com/a/10778071/4124767ほど良くはありません。) しかし、hunspell には、私が気に入っているいくつかのコマンド ライン オプションがありません。)
于 2020-05-13T07:34:00.903 に答える