首页 > 解决方案 > 是否可以在附魔中传递多个字典?

问题描述

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

import enchant
d = enchant.Dict("en_US")
d.check("materialise")
>> False

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

标签: pythonpython-3.xpyenchantenchant

解决方案


我可能来晚了,但这个问题也引起了我的兴趣。

因此,在 Python 的 enchant 中使用多种英语方言的解决方案如下:

    import enchant
    '''
    Use "en" simply to cover all available dialects and word usages of the English language
    '''
    d = enchant.Dict("en")
    d.check("materialise")  # UK (en_GB)
    >>> True
    
    d.check("materialize")  # USA (en_US)
    >>> True

希望这对我们未来的读者有所帮助:)


推荐阅读