在java中使用word分词工具进行简单分词
大佬关于word分词组件使用的总结:
https://my.oschina.net/apdplat/blog/228619#OSC_h3_3
简单应用:
添加依赖
<dependency>
<groupId>org.apdplat</groupId>
<artifactId>word</artifactId>
<version>1.1</version>
</dependency>
分词简单应用
private String spliceString(String str) {
//移除停用词进行分词
//List<Word> list = WordSegmenter.seg(str);
//保留停用词
return listWordToString(WordSegmenter.segWithStopWords(str));
}
将List 转为String
//将List<Word>转为String
private String listWordToString(List<Word> words) {
StringBuffer sb = new StringBuffer();
for (Word word : words) {
sb.append(word.getText());
sb.append("、");
}
return sb.toString();
}