xmnlp icon indicating copy to clipboard operation
xmnlp copied to clipboard

文本纠错AssertionError

Open wannian1997 opened this issue 2 years ago • 5 comments

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

wannian1997 avatar Jan 06 '23 04:01 wannian1997

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

wannian1997 avatar Jan 06 '23 04:01 wannian1997

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

SeanLee97 avatar Jan 06 '23 05:01 SeanLee97

'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

wannian1997 avatar Jan 06 '23 10:01 wannian1997

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 avatar May 26 '23 16:05 jiluojiluo

我的报这个错误

TypeError: 'NoneType' object is not subscriptable

jiluojiluo avatar May 26 '23 16:05 jiluojiluo