use of com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment in project HanLP by hankcs.
the class TestDijkstra method testSeg.
public void testSeg() throws Exception {
String text = "商品与服务";
DijkstraSegment segment = new DijkstraSegment();
List<Term> resultList = segment.seg(text);
System.out.println(resultList);
}
use of com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment in project HanLP by hankcs.
the class TestPersonRecognition method testBatch.
public void testBatch() throws Exception {
List<File> fileList = FolderWalker.open(FOLDER);
int i = 0;
for (File file : fileList) {
System.out.println(++i + " / " + fileList.size() + " " + file.getName() + " ");
String path = file.getAbsolutePath();
String content = IOUtil.readTxt(path);
DijkstraSegment segment = new DijkstraSegment();
List<List<Term>> sentenceList = segment.seg2sentence(content);
for (List<Term> sentence : sentenceList) {
if (SentencesUtil.hasNature(sentence, Nature.nr)) {
System.out.println(sentence);
}
}
}
}
use of com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment in project HanLP by hankcs.
the class TestSegment method testViterbi.
public void testViterbi() throws Exception {
HanLP.Config.enableDebug(true);
CustomDictionary.add("网剧");
Segment seg = new DijkstraSegment();
List<Term> termList = seg.seg("优酷总裁魏明介绍了优酷2015年的内容战略,表示要以“大电影、大网剧、大综艺”为关键词");
System.out.println(termList);
}
use of com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment in project HanLP by hankcs.
the class TestSegment method testSpeechTagging.
public void testSpeechTagging() throws Exception {
HanLP.Config.enableDebug();
String text = "教授正在教授自然语言处理课程";
DijkstraSegment segment = new DijkstraSegment();
System.out.println("未标注:" + segment.seg(text));
segment.enablePartOfSpeechTagging(true);
System.out.println("标注后:" + segment.seg(text));
}
use of com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment in project HanLP by hankcs.
the class TestNSRecognition method testSeg.
public void testSeg() throws Exception {
HanLP.Config.enableDebug();
DijkstraSegment segment = new DijkstraSegment();
segment.enableJapaneseNameRecognize(false);
segment.enableTranslatedNameRecognize(false);
segment.enableNameRecognize(false);
segment.enableCustomDictionary(false);
segment.enablePlaceRecognize(true);
System.out.println(segment.seg("南翔向宁夏固原市彭阳县红河镇黑牛沟村捐赠了挖掘机"));
}
Aggregations