liwenju0 / cutword

一个简单快速的分词、命名实体识别工具

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnicodeDecodeError: 'gbk' codec can't decode

chflame163 opened this issue · comments

报错:
Traceback (most recent call last):
File "C:\Project\test\test.py", line 25, in
cutter = cutword.Cutter(want_long_word=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Project\test\venv\Lib\site-packages\cutword\cutword.py", line 32, in init
self._load_dict(dict_path)
File "C:\Project\test\venv\Lib\site-packages\cutword\cutword.py", line 51, in _load_dict
for line in open(file_path):
UnicodeDecodeError: 'gbk' codec can't decode byte 0xb1 in position 2: illegal multibyte sequence

代码如下
`import cutword

text = '''
据国家铁路局消息,近年来,随着铁路建设不断推进,我国铁路网越织越密,“八纵八横”高速铁路网主通道已建成约80%,普速铁路网不断完善。
在10日召开的全国铁路监督管理工作会议上,国家铁路局总工程师田军表示,当前,铁路路网建设正由以路网干线建设为主向联网补网强链转变。
“在加强出疆入藏、沿江沿边沿海等干线铁路建设的同时,多层次轨道交通互联互通需求日益凸显,城际铁路、市域(郊)铁路、铁路专用线等区域性
铁路和现代化物流枢纽建设方兴未艾,正逐步成为铁路建设的主战场。”,实现运输服务品质全面跃升。
'''
cutter = cutword.Cutter(want_long_word=True)
result = cutter.cutword(text)
print(result)`

已经更新,在windows平台,系统默认编码是gpk。已经在文件中指定了utf8编码来加载字典。pip install cutword==0.0.14

已经更新,在windows平台,系统默认编码是gpk。已经在文件中指定了utf8编码来加载字典。pip install cutword==0.0.14

光速更新啊,感谢