

使用aspell检查英文拼写错误
source link: https://www.lujun9972.win/blog/2018/02/07/%E4%BD%BF%E7%94%A8aspell%E6%A3%80%E6%9F%A5%E8%8B%B1%E6%96%87%E6%8B%BC%E5%86%99%E9%94%99%E8%AF%AF/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

使用aspell检查英文拼写错误
安装aspell及其字典
aspell是一款拼写检查工具,它存在于几乎所有的Linux发行版的仓库中。在archlinux上可以通过下面命令来安装:
sudo pacman -S aspell aspell-en
其中, aspell
为aspell程序本身,而 aspell-en
为aspell用来检查的英文字典。
注意使用aspell一定要安装相应的字典,否则会提示
Error: No word lists can be found for the language "en_US"
事实上, aspell
除了英文外还支持其他多种语言:
pacman -Ss aspell
extra/aspell 0.60.6.1-5 [已安装] A spell checker designed to eventually replace Ispell extra/aspell-de 20161207-1 German dictionary for aspell extra/aspell-en 2017.08.24-1 [已安装] English dictionary for aspell extra/aspell-es 1.11-6 Spanish dictionary for aspell extra/aspell-fr 0.50.3-7 French dictionary for aspell extra/aspell-nl 0.50.2-3 Dutch dictionary for aspell community/aspell-ca 2.3.0-2 Catalan dictionary for aspell community/aspell-cs 20040614-8 Czech dictionary for aspell community/aspell-el 0.08-2 Greek dictionary for aspell community/aspell-hu 0.99.4.2-4 Hungarian spellcheck dictionary for aspell community/aspell-it 2.2_20050523-5 Italian dictionary for aspell community/aspell-pl 20171220-1 Polish dictionary for aspell community/aspell-pt 20161001-1 Portuguese and Brazilian Portuguese dictionary for aspell community/aspell-ru 0.99f7-6 Russian dictionary for aspell community/aspell-sv 0.51-1 Swedish dictionary for aspell community/aspell-uk 1.8.0-1 Ukrainian dictionary for aspell
可以看出,aspell还支持德语、法语、西班牙语、俄语等等很多语言,可惜的是没有中文
使用aspell检查文件中的错误拼写
使用aspell的 check
操作就能进行拼写检查了,像这样
aspell check file.txt # 或者 aspell -c file.txt
这里 file.txt
就是要被检查的文件了。
aspell默认会根据当前的语言环境(具体来说是根据LC_MESSAGES变量值)来决定使用哪个语言的字典来进行检查,因此若你的LANG设置成了 zh_CN.UTF-8
,那么运行上面命令会得到下面的错误信息
错误:No word lists can be found for the language "zh_CN".
你可以通过修改LANG变量或者使用aspell的 --lang
/ -l
选项来解决:
LANG=C aspell -c file.txt # 或者 aspell --lang=en -c file.txt # 或者 aspell -l en -c file.txt
执行 check
操作后,Aspell会打开一个双窗口的编辑器:
上面那个窗口包含的是被检查的文件内容,其中光标停留在被认为是错误拼写的地方并把错误拼写的内容高亮起来了。
而下面的窗口列出了建议修改的单词(以数字标记)和可以进行的操作(以字母标记)。
按下单词旁边的数字,则表示用对应的单词替代错误内容;而按下操作旁边的字母,则表示执行相应的操作。
aspell的常用选项
aspell提供了大量的选项,其中最常用的选项大概有这么几个:
--dont-backup默认情况下,若你在aspell中修改了文件内容,aspell会以.bak为后缀保存一份原文件的副本。若你觉得没有必要则可以用这个参数指定不做备份
--mode=
当用aspell来带格式的文本文件时,比如html/Tex,你肯定希望aspell不去检查那些关键字吧,这个时候就可以使用 --mode
来指定aspell的过滤模式了。
aspell支持多种过滤模式,可以使用 aspell dump modes
来查看。
aspell dump modes
ccpp mode for checking C++ comments and string literals html mode for checking HTML documents email mode for skipping quoted text in email messages comment mode to check any lines starting with a # perl mode for checking Perl comments and string literals url mode to skip URL like constructs (default mode) texinfo mode for checking Texinfo documents nroff mode for checking Nroff documents none mode to disable all filters tex mode for checking TeX/LaTeX documents sgml mode for checking generic SGML/XML documents
--ignore-case / --dont-ignore-case指定检查拼写时是否忽略大小写
--igore=N / -W N忽略单词长度少于N个字符的单词
Recommend
-
42
-
49
-
8
在VIM中设置拼写检查 2021年2月2日 / 1次阅读VIM 如果是写markdown文件,拼写检查应该会更有用,对代码做拼写检查,其实是对代码内的字符串(包含注释)进行检查。 :set spell ...
-
8
简单的需求临近下班,小明忙完了今天的任务,正准备下班回家。一条消息闪烁了起来。“最近发现公众号的拼写检查功能不错,帮助用户发现错别字,体验不错。给我们系统也做一个。”看着这条消息,小明在内心默默问候了一句。“...
-
7
一个提升英文单词拼写检测性能 1000 倍的算法?发布于 58 分钟前小明同学上一次在产品经理的忽悠下,写好了一个中英文拼写纠正工具:
-
7
关闭 SublimeText 3.2.2 Build 3211 的拼写检查在更新 SublimeText 之后,发现所有的字符下面都有波浪线,这是新版本的 SublimeText 提供的拼写语法功能,然而我不需要此功能。本文来告诉大家如何关闭 点击标题栏的 Perferences 的 Settings...
-
6
Tools IntelliJ IDEA 中的代码拼写检查器
-
5
浏览器拼写检查或会泄露用户密码,特别是在云端服务器上使用时
-
7
推荐3个不错的英文翻译、拼写检查黑科技工具 ...
-
8
electron应用更新版本后的拼写检查失效?原来一行代码就搞定如果您发现本文排版有问题,可以先点击下面的链接切换至老版进行查看!!!
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK