代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
"""
@author:XuMing(xuming624@qq.com)
@description:
"""
import sys
sys.path.append("..")
import pycorrector
if __name__ == '__main__':
# 1. 演示英文句子纠错
sent = "what happending? how to speling it, can you gorrect it?"
corrected_text, details = pycorrector.en_correct(sent)
print(sent, '=>', corrected_text)
print(details)
print()
# 2. 演示英文句子列表纠错
sent_lst = ['what hapenning?','how to speling it', 'gorrect', 'i know']
for sent in sent_lst:
corrected_text, details = pycorrector.en_correct(sent)
if details:
print('[error] ', sent, '=>', corrected_text, details)
print()
# 3. 演示自定义英文词典
from pycorrector.en_spell import EnSpell
sent = "what is your name? shylock?"
spell = EnSpell()
corrected_text, details = spell.correct(sent)
print(sent, '=>', corrected_text, details)
print('-' * 42)
my_dict = {'your': 120, 'name': 2, 'is': 1, 'shylock': 1, 'what': 1} # word, freq
spell = EnSpell(word_freq_dict=my_dict)
corrected_text, details = spell.correct(sent)
print(sent, '=>', corrected_text, details)
print()
# 4. 演示自定义纠错集
from pycorrector.en_spell import EnSpell
spell = EnSpell()
sent = "what happt ? who is shylock."
corrected_text, details = spell.correct(sent)
print(sent, '=>', corrected_text, details)
print('-' * 42)
spell.set_en_custom_confusion_dict('./my_custom_confusion.txt')
corrected_text, details = spell.correct(sent)
print(sent, '=>', corrected_text, details)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。