Search in sources :

Example 1 with DijkstraSegment

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);
}
Also used : DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment) Term(com.hankcs.hanlp.seg.common.Term)

Example 2 with DijkstraSegment

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);
            }
        }
    }
}
Also used : DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment) List(java.util.List) Term(com.hankcs.hanlp.seg.common.Term) File(java.io.File)

Example 3 with DijkstraSegment

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);
}
Also used : DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment) Term(com.hankcs.hanlp.seg.common.Term) ResultTerm(com.hankcs.hanlp.seg.common.ResultTerm) Segment(com.hankcs.hanlp.seg.Segment) DoubleArrayTrieSegment(com.hankcs.hanlp.seg.Other.DoubleArrayTrieSegment) CRFSegment(com.hankcs.hanlp.seg.CRF.CRFSegment) DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment) ViterbiSegment(com.hankcs.hanlp.seg.Viterbi.ViterbiSegment)

Example 4 with DijkstraSegment

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));
}
Also used : DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment)

Example 5 with DijkstraSegment

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("南翔向宁夏固原市彭阳县红河镇黑牛沟村捐赠了挖掘机"));
}
Also used : DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment)

Aggregations

DijkstraSegment (com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment)18 Segment (com.hankcs.hanlp.seg.Segment)5 Term (com.hankcs.hanlp.seg.common.Term)5 CRFSegment (com.hankcs.hanlp.seg.CRF.CRFSegment)3 DoubleArrayTrieSegment (com.hankcs.hanlp.seg.Other.DoubleArrayTrieSegment)3 ViterbiSegment (com.hankcs.hanlp.seg.Viterbi.ViterbiSegment)3 NShortSegment (com.hankcs.hanlp.seg.NShort.NShortSegment)2 ResultTerm (com.hankcs.hanlp.seg.common.ResultTerm)1 File (java.io.File)1 List (java.util.List)1