更新:澄清行号要求,减少一些冗长
从命令行,有没有办法:
为了帮助纠正它们?
目前,帮助完成一篇文章或其他英文写作,aspell -c text.txt有助于发现拼写错误。但是,当错误是无意中连续重复一个单词时,这没有帮助。
highlander_typo.txt:
There can be only one one.
Run Code Online (Sandbox Code Playgroud)
运行aspell:
$ aspell -c highlander_typo.txt
Run Code Online (Sandbox Code Playgroud)
可能因为aspell是拼写检查器,而不是语法检查器,所以重复的单词拼写错误超出了其预期的功能范围。因此,结果是该文件通过了aspell检查,因为就单个单词的拼写而言,没有任何“错误”。
正确的句子是There can be only one.,第二个one是无意的重复单词错字。
但另一种情况是,例如kylie_minogue.txt:
La la la
Run Code Online (Sandbox Code Playgroud)
这里的重复不是错字,因为这些是艺术家歌词的一部分。
所以解决方案不应该自己假设和“修复”任何东西,否则它可能会覆盖故意重复的单词。
jefferson_typo.txt:
He has has refused his Assent to Laws, the most wholesome and necessary
for the public good.
He has forbidden his …Run Code Online (Sandbox Code Playgroud) 我如何使用 grep 编写正则表达式来查找以 'O' 或 'o' 开头并包含 2 个连续的 'c' 字符的行。
grep '^[Oo]c{2}' 文件名