THULAC-Python icon indicating copy to clipboard operation
THULAC-Python copied to clipboard

使用rm_space=True跟手动去除空格结果不同

Open hliang opened this issue 6 years ago • 0 comments

使用rm_space=True分词有些不理想。对有空格的人名,分词结果会把名字拆开。

thu1 = thulac.thulac(rm_space=True) 
intext=u"而袁 世 凯又 心 平 气 和 的不肯同意段 祺 瑞"
seg = thu1.cut(intext, text=True)
print(seg)

会得到:而_c 袁_v 世_g 凯_g 又_d 心平气和_i 的_u 不_d 肯_v 同意_v 段_g 祺_j 瑞_j

而如果手动先把字符串里的空格去掉,就没有问题。

seg = thu1.cut(intext.replace(" ",""), text=True)
print(seg)

会得到# 而_c 袁世凯_np 又_d 心平气和_id 的_u 不_d 肯_v 同意_v 段祺瑞_np(预期的正确结果)。

用的是ubuntu 16.04,python3,thulac-0.1.2,pip安装。

hliang avatar Mar 01 '18 05:03 hliang