hunspell: Printing the line number of the corrected word

白昼怎懂夜的黑 提交于 2019-12-10 15:20:41

问题


I am trying to use hunspell to correct an essay i have written. Unfortunately it is useless to me, as long as it doesn't print the line number of the word, which it predicts to be misspelled.

So right now I am using the -a option, to be able to pipe it into hunspell. The man page says, that the -L option would "Print lines with misspelled words.". But I don't see any difference in the output.

This is what I do right now:

cat myessay.txt | hunspell -d en_US,de_DE -a -L

An example output looks like this:

& JavaServer 3 412: Java Server, Java-Server, Javasee

The word "JavaServer" is in line 78, and as described in the man-pages, it really has an offset of 412 characters in that line.

Is there something I am missing? Is there an easy solution to this problem, or do I really have to pipe each line into hunspell to find out at which line number it was?

Thanks in advance


回答1:


Now I actaully downloaded the sources of hunspell and got down to business. There is an undocumented switch -u that gives me a comfortable output to work with. e.g.

hunspell -u -d en_US,de_DE myessay.txt

This does the trick for printing line numbers using a german and an american dictionary. Alternatively, you can use -U to get a excerpt of the text as well. Other available undocumented switches are -u2 and -u3

But be careful: Those switches are experimental and the source-code says, that those functions are missing unicode support.



来源:https://stackoverflow.com/questions/10617743/hunspell-printing-the-line-number-of-the-corrected-word

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!