messense / jieba-rs

The Jieba Chinese Word Segmentation Implemented in Rust
MIT License
738 stars 46 forks source link

请问如何让自定义词典支持标点符号或者空格 #75

Closed xkungfu closed 4 years ago

xkungfu commented 4 years ago

如: example-word example word 中文 空格 中文-符号

messense commented 4 years ago

add_word 方法应该都支持,目前字典文件是用空格来分割的,标点符号应该没有问题,空格暂时不支持,空格的需求是?

xkungfu commented 4 years ago

比如英文品牌: Louis Vuitton Calvin Klein Collection Dolce&Gabbana

中文可能没有空格需求,暂时还没碰上。英文确实有大量的空格词汇。

另外测试标点符号不能匹配。比如:

$jieba->addWord('田-女士', 42, 'n'); dump($jieba->cut('市民田-女士急匆匆来到上海市公安局松江分局方松派出所求助', false));

分词结果没有将“田-女士”分离出来。

messense commented 4 years ago

- 的问题和 jieba python 的这个问题 fix 一致:https://github.com/fxsjy/jieba/commit/36a27302ce345a1866d125a9e59bd8611cf06813

Fixed in https://github.com/messense/jieba-rs/commit/7a520c13db3f60f4e686c6b8278d565ebc3cc922

xkungfu commented 4 years ago

了解。也许空格问题也可以借此解决,在分词前将文章所有空格替换为“-”。 感谢回复。

messense commented 4 years ago

Louis Vuitton 这种应该已经不适合只用分词来处理了,更像是实体识别的需求。