带有辅助自定义词典的拼写校正器

2024-10-01 00:21:20 发布

您现在位置:Python中文网/ 问答频道 /正文

python中支持使用外部字典的拼写检查的最佳系统是什么?例如,我见过使用外部词典替换默认英语词典的包。但我希望外部字典能够补充现有的拼写检查。例如,如果我有奇怪的抽象词(dsdfwpeloepunj),我希望拼写检查器能够将它们识别为英语单词,以便进行拼写更正

This is na exapmle of a setence using pelloe

应该成为

This is an example of a sentence using peloe


Tags: of字典is系统this英语词典词典using
1条回答
网友
1楼 · 发布于 2024-10-01 00:21:20

正如我在评论中所说,一个不错的选择是^{}

下面是一个如何使用它为会话添加单词的示例:

import enchant

en_us = enchant.Dict('en_US')

en_us_weird_words = ['your', 'weird', 'words', 'list', 'here']

for word in en_us_weird_words:

    # add word to personal dictionary
    # en_us.add(word)

    # add word just for this session
    en_us.add_to_session(word)

pt_br = enchant.Dict('pt_BR')

pt_br_weird_words = ['outras', 'palavras', 'estranhas', 'aqui']

for word in pt_br_weird_words:

    # add word to personal dictionary
    # pt_br.add(word)

    # add word just for this session
    pt_br.add_to_session(word)

我希望有帮助

相关问题 更多 >