HIT-SCIR / pyltp

pyltp: the python extension for LTP
1.53k stars 352 forks source link

字符编码问题,pyltp可否将字符编码逻辑囊括进来。输入和输出都可以为unicode字符串 #54

Closed qiaochen closed 4 years ago

qiaochen commented 8 years ago

由于需要将pyltp作为分词器接入scikit-learn的CountVectorizer,在调用过程中其内部调用无法将pyltp返回的utf-8字符串decode('utf8')。希望可以将字符编码转换的过程内置到pyltp中,也就是encode('utf8')和decode('utf8')处理可以在pyltp中执行。这样可以提供极大的便利。谢谢!

endyul commented 8 years ago

请问可以提供一份将pyltp接入CountVectorizer的示例代码吗?假设pyltp返回的是unicode

CrazyTianC commented 6 years ago

刚改python3,想问一下,文档里说输入必须是utf-8,在py2里我输入unicode也是会报错。 但是在py3里不论是str,或者encode成utf-8都能执行。而且输出也变成了str。我想知道会不会有问题?