向Aspell/Pspell添加字典

8

我已成功安装了Aspell,并使用Pspell编译了PHP,一切似乎都运行良好。

唯一无法做到的是创建一个“忽略”单词列表或个人词典,不管你想怎么称呼它。

我尝试了这里这里概述的步骤,但两者都没有任何效果。

如上面的链接和Aspell文档所述,我尝试按照手册中概述的方式创建个人词典:

personal_ws-1.1 en 0
Rubiflex
quasirhombicosidodecahedron

我将其放置在aspell目录、我的主目录和根目录中,但它从未被识别。Aspell文档从未明确说明它应该位于哪里或如何加载它。
另一个参考是关于创建个人词汇表的。

Create a txt file with the words that you'd like to add to the dictionary, where each word is on a separate line then run the following command:

 aspell --lang=en create master ./custom.rws < test.txt

This will create a file called custom.rws that will contain the aspell encoded word(s) for the dictionary. You can name the file anything you want as long as the extension is .rws. Now to add this to the dictionary move the custom.rws file to the dictionary location which is /usr/lib/aspell by running the following command:

cp custom.rws /usr/lib/aspell/

To finish adding it to the dictionary change into the dictionary directory by running the following:

 cd /usr/lib/aspell/
 then edit the following file: nano en_US.multi

and add the following line:

add custom.rws

这两种方法似乎都不起作用,我找不到任何清晰的示例来正确添加字典或单词列表。这是我能找到的两种最有希望的方法,但都没有成功。有人知道如何让Aspell使用我创建的个人字典文件吗?
感谢您的时间。
编辑:这里概述的步骤对我有效。它们很像这里概述的步骤,只是后者引用了“en_US.multi”,而前者引用了“en.multi”。在将自定义列表添加到en.multi(而不是en_US.multi)之后,它按预期工作。

你应该给出一些例子,介绍编码方式,并展示如何加载字典的代码。 - hakre
@hakre 我已经给出了两个例子,并且我完全按照它们的样子去做了。我使用了那些页面上展示的代码来尝试创建和加载个人词典。 - edeneye
我也想要你的字典文件和文件编码的示例。此外,我无法打开那两个链接,所以可能你可以大致概述一下你做了什么。 - hakre
@hakre 我已经编辑了我的帖子,包括我链接的页面上使用的大部分步骤。 - edeneye
通过在谷歌上找到的另一个页面解决了问题。在原帖的结尾进行了解释。 - edeneye
请在下面的答案中添加您的解决方案。您可以稍后接受它作为“答案”,这将标记您的问题已解决(这就是此网站的工作方式)。感谢您的支持!还有,您看过这个例子吗?(PHP手册) - hakre
3个回答

2
我能够使用选项--add-extra-dicts将个人词典添加到aspell调用中。

aspell -c --add-extra-dicts=./custom.rws my_text_to_spell_check.txt

如OP所述,已创建custom.rws

aspell --encoding=UTF-8 --lang=<lang> create master ./custom.rws < test.txt

并记得添加--encoding选项以匹配源文件的正确编码。
希望这能帮助到某些人!

2
对于我最新的Perl的Text::Aspell模块的工作和代码,用于确定查询公司搜索引擎的Web访问者的母语,我遇到了一些你所描述的陷阱(在Aspell6中未实现个人词典)。然而,我使用“extra-dicts”概念解决了这个问题,每种可能的语言使用一个“extra-dicts”。
我还不得不解决Aspell没有阿拉伯语、希伯来语、日语、汉语和韩语字典的事实。这些语言需要特殊处理。
您可以查看完整的最新Perl和bash代码,适用于运行Windows/MinGW的Linux和Windows,网址为http://vouters.dyndns.org/tima/Linux-Windows-Perl-Aspell-Determining_the_country_of_a_Web_query.html。您可以使用文档参考部分中的URL链接来调整一些Perl代码概念以适用于PHP。

0

在Cygwin中使用以下版本的aspell:

International Ispell Version 3.1.20 (but really Aspell 0.60.6.1)

它在我的主目录中寻找名为.aspell.en.pws的个人词典,而不管我在命令行上使用--personal选项指定了什么。我能够在我的主目录中放置一个名为.aspell.en.pws的符号链接,并让它指向文件系统上的不同位置。我必须先创建文件并添加所需的头文件,然后aspell才会开始添加到我的个人词典。

简而言之,您可以这样做:

echo "personal_ws-1.1 en" > ~/my/file/location.pws
ln -s ~/my/file/location.pws ~/.aspell.en.pws

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接