Search in sources :

Example 6 with Segment

use of com.hankcs.hanlp.seg.Segment in project HanLP by hankcs.

the class TestSegment method testACSegment.

public void testACSegment() throws Exception {
    Segment segment = new DoubleArrayTrieSegment();
    segment.enablePartOfSpeechTagging(true);
    System.out.println(segment.seg("江西鄱阳湖干枯,中国最大淡水湖变成大草原"));
}
Also used : DoubleArrayTrieSegment(com.hankcs.hanlp.seg.Other.DoubleArrayTrieSegment) 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 7 with Segment

use of com.hankcs.hanlp.seg.Segment 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 8 with Segment

use of com.hankcs.hanlp.seg.Segment in project HanLP by hankcs.

the class TestSegment method testCRFSegment.

public void testCRFSegment() throws Exception {
    HanLP.Config.enableDebug();
    //        HanLP.Config.ShowTermNature = false;
    Segment segment = new CRFSegment();
    System.out.println(segment.seg("有句谚语叫做一个萝卜一个坑儿"));
}
Also used : 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) CRFSegment(com.hankcs.hanlp.seg.CRF.CRFSegment)

Example 9 with Segment

use of com.hankcs.hanlp.seg.Segment in project HanLP by hankcs.

the class TestSegment method testIssue199.

public void testIssue199() throws Exception {
    Segment segment = new CRFSegment();
    // 开启自定义词典
    segment.enableCustomDictionary(false);
    segment.enablePartOfSpeechTagging(true);
    List<Term> termList = segment.seg("更多采购");
    System.out.println(termList);
    for (Term term : termList) {
        if (term.nature == null) {
            System.out.println("识别到新词:" + term.word);
        }
    }
}
Also used : 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) CRFSegment(com.hankcs.hanlp.seg.CRF.CRFSegment)

Example 10 with Segment

use of com.hankcs.hanlp.seg.Segment in project HanLP by hankcs.

the class TestSegment method testTryToCrashSegment.

public void testTryToCrashSegment() throws Exception {
    String text = "尝试玩坏分词器";
    Segment segment = new ViterbiSegment().enableMultithreading(100);
    System.out.println(segment.seg(text));
}
Also used : ViterbiSegment(com.hankcs.hanlp.seg.Viterbi.ViterbiSegment) 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)

Aggregations

Segment (com.hankcs.hanlp.seg.Segment)33 CRFSegment (com.hankcs.hanlp.seg.CRF.CRFSegment)20 DijkstraSegment (com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment)20 ViterbiSegment (com.hankcs.hanlp.seg.Viterbi.ViterbiSegment)19 DoubleArrayTrieSegment (com.hankcs.hanlp.seg.Other.DoubleArrayTrieSegment)18 Term (com.hankcs.hanlp.seg.common.Term)12 NShortSegment (com.hankcs.hanlp.seg.NShort.NShortSegment)4 ResultTerm (com.hankcs.hanlp.seg.common.ResultTerm)4 HMMSegment (com.hankcs.hanlp.seg.HMM.HMMSegment)2 DictionaryMaker (com.hankcs.hanlp.corpus.dictionary.DictionaryMaker)1 Item (com.hankcs.hanlp.corpus.dictionary.item.Item)1 CharacterBasedGenerativeModelSegment (com.hankcs.hanlp.seg.CharacterBasedGenerativeModelSegment)1