forked from shibing624/pycorrector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
use_custom_confusion.py
43 lines (37 loc) · 1.65 KB
/
use_custom_confusion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
@author:XuMing([email protected])
@description: 用户自定义混淆集,功能:1)补充纠错对,提升召回率;2)对误杀加白,提升准确率
"""
import sys
sys.path.append("../")
import pycorrector
# pycorrector.set_log_level('INFO')
if __name__ == '__main__':
error_sentences = [
'买iPhone差,要多少钱',
'我想喝小明同学。',
'哪里卖苹果吧?请大叔给我让坐',
'交通先行了怎么过去啊?',
'共同实际控制人萧华、霍荣铨、张旗康',
'上述承诺内容系本人真实意思表示',
]
for line in error_sentences:
print(pycorrector.correct(line))
print('*' * 53)
pycorrector.set_custom_confusion_dict(path='./my_custom_confusion.txt')
for line in error_sentences:
print(pycorrector.correct(line))
# ('买iPhone差,要多少钱', [])
# ('我想喝小明同学。', [])
# ('哪里卖苹果吧?请大叔给我让坐', [])
# ('交通先行了怎么过去啊?', [])
# ('共同实际控制人萧华、霍荣铨、张启康', [['张旗康', '张启康', 14, 17]])
# ('上述承诺内容系本人真实意思表示', [])
# *****************************************************
# ('买iphoneX,要多少钱', [['iphone差', 'iphoneX', 1, 8]])
# ('我想喝小茗同学。', [['小明同学', '小茗同学', 3, 7]])
# ('哪里卖苹果八?请大叔给我让坐', [['苹果吧', '苹果八', 3, 6]])
# ('交通限行了怎么过去啊?', [['交通先行', '交通限行', 0, 4]])
# ('共同实际控制人萧华、霍荣铨、张旗康', [])
# ('上述承诺内容系本人真实意思表示', [])