luopeixiang / named_entity_recognition

中文命名实体识别(包括多种模型:HMM,CRF,BiLSTM,BiLSTM+CRF的具体实现)
2.13k stars 537 forks source link

Python3中遇到UnicodeEncodeError: 'ascii' codec can't encode characters in ordinal not in range(128) #17

Open Gaoshuang77 opened 4 years ago

Gaoshuang77 commented 4 years ago

在运行到crf模型时出现上述错误,查了很久,试了各种方法也没有解决,请问有没有人知道该如何解决呢? 环境:win10 python3.8 编码方式查过了是utf-8没错,但一直出现这个错误。求大神支招!

TENGSP commented 4 years ago

同样问题,请问你解决了吗?

lynlynnlynnn commented 4 years ago

同问,请问解决了吗?

TENGSP commented 4 years ago

在运行到crf模型时出现上述错误,查了很久,试了各种方法也没有解决,请问有没有人知道该如何解决呢? 环境:win10 python3.8 编码方式查过了是utf-8没错,但一直出现这个错误。求大神支招!

求解决方法

lln1997 commented 4 years ago

只能用linux运行

BlackSpritee commented 3 years ago

找到报错的地方,变量名加str()转换一下,

hujunyi96 commented 3 years ago

在字符串前加小写r

1yangjianfei commented 3 years ago

同问,请问解决了吗

Hai-Chao-ren commented 1 year ago

同问,在linux上运行crf时出现了这个问题

jiayuanyuan67777 commented 1 year ago

我也遇到这个问题,求问怎么解决

EstrellaXiao commented 8 months ago

找到报错的地方,变量名加str()转换一下,

您好,请问是要加在哪里呢?

正在训练评估CRF模型... Traceback (most recent call last): File "D:\named_entity_recognition-master\named_entity_recognition-master\main.py", line 73, in main() File "D:\named_entity_recognition-master\named_entity_recognition-master\main.py", line 29, in main crf_pred = crf_train_eval( File "D:\named_entity_recognition-master\named_entity_recognition-master\evaluate.py", line 43, in crf_train_eval crf_model.train(str(train_word_lists), str(train_tag_lists)) File "D:\named_entity_recognition-master\named_entity_recognition-master\models\crf.py", line 23, in train self.model.fit(str(features), str(tag_lists)) File "D:\anaconda\lib\site-packages\sklearn_crfsuite\estimator.py", line 331, in fit trainer.train(self.modelfile.name, holdout=-1 if X_dev is None else 1) File "pycrfsuite/_pycrfsuite.pyx", line 359, in pycrfsuite._pycrfsuite.BaseTrainer.train File "", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string UnicodeEncodeError: 'ascii' codec can't encode characters in position 9-10: ordinal not in range(128)