文档
依赖
<dependency>
<groupId>com.huabangroupId>
<artifactId>jieba-analysisartifactId>
<version>1.0.2version>
dependency>
使用示例
package com.example.demo;
import com.huaban.analysis.jieba.JiebaSegmenter;
import com.huaban.analysis.jieba.SegToken;
import org.junit.Test;
import java.util.List;
import java.util.stream.Collectors;
public class JiebaTests {
@Test
public void testJieba(){
String text = "工信处女干事每月经过下属科室都要亲口交代24口交换机等技术性器件的安装工作";
JiebaSegmenter segmenter = new JiebaSegmenter();
List<SegToken> list = segmenter.process(text, JiebaSegmenter.SegMode.INDEX);
List<String> collect = list.stream()
.map(segToken -> segToken.word)
.collect(Collectors.toList());
System.out.println(collect);
// [工信处, 干事, 女干事, 每月, 经过, 下属, 科室, 都, 要, 亲口, 交代, 24, 口, 交换, 换机, 交换机, 等, 技术, 技术性, 器件, 的, 安装, 工作]
}
}