是否可以附魔地传递多个字典?

Mas*_*s17 6 python python-3.x pyenchant enchant

有什么办法可以在附魔中使用多个字典。我就是这样

import enchant
d = enchant.Dict("en_US")
d.check("materialise")
>> False
Run Code Online (Sandbox Code Playgroud)

但是如果我使用enchant.Dict("en_UK"),我会得到True。组合多个字典的最佳方法是什么,以便True无论返回materialise还是materialize作为输入参数返回?

ipa*_*eka 1

For Hunspell dictionaries there's a workaround if both dictionaries share the same .aff file and I suppose en_US and en_GB pass that condition.

The author is Sergey Kurakin and the Bash script is (dic_combine.sh) as follows:

#!/bin/bash

# Combines two or more hunspell dictionaries.
# (C) 2010 Sergey Kurakin <kurakin_at_altlinux_dot_org>

# Attention! All source dictionaries MUST share the same affix file.

# Usage: dic_combine source1.dic source2.dic [source3.dic...] > combined.dic

TEMPFILE=`mktemp`

cat $@ | sort --unique | sed -r 's|^[0123456789]*$||;/^$/d' > $TEMPFILE

cat $TEMPFILE | wc -l
cat $TEMPFILE
rm -f $TEMPFILE
rm -f $TEMPFILE 
Run Code Online (Sandbox Code Playgroud)

So, you have to put those dictionary files in a directory and run:

$ dic_combine en_US.dic en_GB.dic > en.dic
Run Code Online (Sandbox Code Playgroud)