<jupyter_start><jupyter_text>- 文本纠错<jupyter_code>corrected_sent, detail = pycorrector.correct('少先队员因该为老人让坐')
print(corrected_sent, detail)<jupyter_output>[  DEBUG 20201223 01:43:57 detector:  87] Loaded language model: C:\Users\10768\.pycorrector\datasets\zh_giga.no_cna_cmn.prune01244.klm, spend: 9.330 s.
[  DEBUG 20201223 01:44:00 detector: 106] Loaded dict file, spend: 2.642 s.<jupyter_text>- 错误检测<jupyter_code>idx_errors = pycorrector.detect('少先队员因该为老人让坐')
print(idx_errors)<jupyter_output>[['因该', 4, 6, 'word'], ['坐', 10, 11, 'char']]<jupyter_text>- 关闭字粒度纠错<jupyter_code>error_sentence_1 = '我的喉咙发炎了要买点阿莫细林吃'
pycorrector.enable_char_error(enable=True)
correct_sent = pycorrector.correct(error_sentence_1)
print(correct_sent)
error_sentence_1 = '我的喉咙发炎了要买点阿莫细林吃'
pycorrector.enable_char_error(enable=False)
correct_sent = pycorrector.correct(error_sentence_1)
print(correct_sent)<jupyter_output>('我的喉咙发炎了要买点阿莫西林吃', [['细林', '西林', 12, 14]])<jupyter_text>- 加载自定义混淆集<jupyter_code># pycorrector.set_log_level('INFO')
if __name__ == '__main__':

    error_sentences = [
        '买iphonex，要多少钱',  # 漏召回
        '我想喝小明同学。',  # 漏召回
        '哪里卖苹果吧？请大叔给我让坐',  # 漏召回
        '交通先行了怎么过去啊？',  # 漏召回
        '共同实际控制人萧华、霍荣铨、张旗康',  # 误杀
        '上述承诺内容系本人真实意思表示',  # 正常
    ]
    for line in error_sentences:
        print(pycorrector.correct(line))

    print('*' * 42)
    pycorrector.set_custom_confusion_dict(path='./my_custom_confusion.txt')
    for line in error_sentences:
        print(pycorrector.correct(line))<jupyter_output>('买iphonex，要多少钱', [])
('我想喝小明同学。', [])
('哪里卖苹果吧？请大叔给我让坐', [])
('交通先行了怎么过去啊？', [])
('共同实际控制人萧华、霍荣铨、张启康', [['张旗康', '张启康', 14, 17]])
('上述承诺内容系本人真实意思表示', [])
******************************************
('买iphoneX，要多少钱', [['iphonex', 'iphoneX', 1, 8]])
('我想喝小茗同学。', [['小明同学', '小茗同学', 3, 7]])
('哪里卖苹果八？请大叔给我让坐', [['苹果吧', '苹果八', 3, 6]])
('交通限行了怎么过去啊？', [['交通先行', '交通限行', 0, 4]])
('共同实际控制人萧华、霍荣铨、张旗康', [])
('上述承诺内容系本人真实意思表示', [])
{'fraction_non_alphanumeric': 0.2025706940874036, 'fraction_numerical': 0.04061696658097686, 'mean_word_length': 6.154411764705882, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '139464', 'license': 'MIT', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1176, 'n_words': 117, 'path': 'scripts/ex_pycorrector.ipynb', 'repo_name': 'Alex2Yang97/brand_match', 'size': '1945'}