SeanLee97 / xmnlp

xmnlp:提供中文分词, 词性标注, 命名体识别,情感分析,文本纠错,文本转拼音,文本摘要,偏旁部首,句子表征及文本相似度计算等功能
Apache License 2.0
1.23k stars 188 forks source link

文本纠错AssertionError #50

Open wannian1997 opened 1 year ago

wannian1997 commented 1 year ago

checker.py文件中50行assert len(mask_id) == 1出现AssertionError请问如何解决

wannian1997 commented 1 year ago

我将这句改为了assert len(mask_id) >= 1,但是这样输出的结果为类似{(8, ''): [('[', 0.8247228860855103), (']', 0.08479063957929611), ('被', 0.006882567889988422), ('/', 0.0036284865345805883), ('『', 0.0036059825215488672)]},缺少了原本的错误的字。

SeanLee97 commented 1 year ago

将你的输入文本和测试代码也发一下?不然不好追踪原因。

wannian1997 commented 1 year ago

'import xmnlp modelPath = r"E:\deepLearning\xmnlp-onnx-models" xmnlp.set_model(modelPath) text = "不能适应体育专业选拔人材的要求" print(xmnlp.checker(text))'

Lazy load checker... Traceback (most recent call last): File "E:/deepLearning/Bert-Chinese-Text-Classification-Pytorch/toolTest.py", line 6, in print(xmnlp.checker(text)) File "D:\Programs\Anaconda\envs\py36\lib\site-packages\xmnlp\checker__init__.py", line 40, in spellcheck load_checker() File "D:\Programs\Anaconda\envs\py36\lib\site-packages\xmnlp\checker__init.py", line 29, in load_checker os.path.join(config.MODEL_DIR, 'checker')) File "D:\Programs\Anaconda\envs\py36\lib\site-packages\xmnlp\checker\checker.py", line 50, in init__ assert len(mask_id) == 1 AssertionError

进程已结束,退出代码1

jiluojiluo commented 1 year ago

import xmnlp text = "不能适应体育专业选拔人材的要求" File "", line 1 text = "不能适应体育专业选拔人材的要求" IndentationError: unexpected indent text = "不能适应体育专业选拔人材的要求" print(xmnlp.checker(text)) (Lazy Load) Loading model... start to build dictionary... done ! Traceback (most recent call last): File "", line 1, in File "C:\Users\l00660157\Anaconda3\envs\labelme\Lib\site-packages\xmnlp__init__.py", line 135, in checker return _checker.check(text, level=level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\l00660157\Anaconda3\envs\labelme\Lib\site-packages\xmnlp\checker__init__.py", line 48, in check return model.best_match(doc) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\l00660157\Anaconda3\envs\labelme\Lib\site-packages\xmnlp\checker\checker.py", line 110, in best_match return self.word_checker(word)[0]


TypeError: 'NoneType' object is not subscriptable
jiluojiluo commented 1 year ago

我的报这个错误

TypeError: 'NoneType' object is not subscriptable