Closed zhubinjun closed 6 years ago
@zhubinjun Thanks for using PyNLPIR!
PyNLPIR does not actually segment the text, it simply outputs whatever NLPIR returns. I'd recommend asking around at NLPIR:
My guess is that NLPIR works more reliably with actual sentences, not one-word strings. For example:
>>> pynlpir.segment('随着20世纪70年代环孢素A的问世和移植技术的进步,1981年美国斯坦福大学医院首先获得心肺联合移植的成功;1983年和1986年加拿大多伦多肺移植组又相继成功地施行了单肺移植和双肺移植,开创了肺移
植的新纪元。'))
[... ('双', 'numeral'), ('肺', 'noun'), ...]
>>> pynlpir.nlpir.AddUserWord( '双肺'.encode('utf8') )
>>> print(pynlpir.segment('随着20世纪70年代环孢素A的问世和移植技术的进步,1981年美国斯坦福大学医院首先获得心肺联合移植的成功;1983年和1986年加拿大多伦多肺移植组又相继成功地施行了单肺移植和双肺移植,开创了肺移
植的新纪元。'))
[... ('双肺', 'noun') ...]
Text from https://baike.baidu.com/item/%E5%8F%8C%E8%82%BA%E7%A7%BB%E6%A4%8D
After I added the user words, I get the wrong segment result:
Test Code:
output: (python 3 WIndows /Ubuntu ):