如何使用词缀文件(.aff)转换字典文件(.dic)来创建单词列表?

时间:2011-01-04 19:13:59

标签: dictionary

我正在查看字典文件(“.dic”)及其相关的“aff”文件。我要做的是将“aff”文件中的规则与“dic”文件中的单词组合,以创建字典文件中包含的所有单词的全局列表。

很难找到这些文件背后的文档。有谁知道我可以学习的资源?

是否有任何代码可以执行此操作(我是否重复了我不需要的工作)?

谢谢!

3 个答案:

答案 0 :(得分:2)

您需要一个名为munch.exe的实用程序才能将aff规则应用于dic文件。

答案 1 :(得分:2)

这些可能是Hunspell字典文件。不幸的是,创建“全局”或未经编辑的词表的命令仅完全支持简单的.aff和.dic文件。

来自the documentation

unmunch: list all recognized words of a MySpell dictionary

语法:

unmunch dic_file affix_file

尝试一下,看看会发生什么。要仅生成一个单词的所有字形,请查看here

答案 2 :(得分:0)

根据Pillowcase,这是一个使用示例:

# Download dictionary
wget -O ./dic/es_ES.aff "https://raw.githubusercontent.com/sbosio/rla-es/master/source-code/hispalabras-0.1/hispalabras/es_ES.aff"
wget -O ./dic/es_ES.dic "https://raw.githubusercontent.com/sbosio/rla-es/master/source-code/hispalabras-0.1/hispalabras/es_ES.dic"

# Compile program
wget -O ./dic/unmunch.cxx "https://raw.githubusercontent.com/hunspell/hunspell/master/src/tools/unmunch.cxx"
wget -O ./dic/unmunch.h "https://raw.githubusercontent.com/hunspell/hunspell/master/src/tools/unmunch.h"
g++ -o ./dic/unmunch ./dic/unmunch.cxx

# Generate dictionary
./dic/unmunch ./dic/es_ES.dic ./dic/es_ES.aff 2> /dev/null > ./dic/es_ES.txt.bk
sort ./dic/es_ES.txt.bk > ./dic/es_ES.txt # Opcional
rm ./dic/es_ES.txt.bk # Opcional