Search in sources :

Example 26 with Segment

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

the class TestPersonRecognition method testChineseNameRecognition.

public void testChineseNameRecognition() throws Exception {
    HanLP.Config.enableDebug();
    Segment segment = new DijkstraSegment();
    System.out.println(segment.seg("编剧邵钧林和稽道青说"));
}
Also used : DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment) NShortSegment(com.hankcs.hanlp.seg.NShort.NShortSegment) Segment(com.hankcs.hanlp.seg.Segment) DijkstraSegment(com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment)

Example 27 with Segment

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

the class TestSegment method testCustomDictionary.

public void testCustomDictionary() throws Exception {
    CustomDictionary.insert("肯德基", "ns 1000");
    Segment segment = new ViterbiSegment();
    System.out.println(segment.seg("肯德基"));
}
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)

Example 28 with Segment

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

the class TestSegment method testShortest.

public void testShortest() throws Exception {
    HanLP.Config.enableDebug();
    Segment segment = new ViterbiSegment().enableAllNamedEntityRecognize(true);
    System.out.println(segment.seg("把市场经济奉行的等价交换原则引入党的生活和国家机关政务活动中"));
}
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)

Example 29 with Segment

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

the class TestSegment method testIssue193.

public void testIssue193() throws Exception {
    String[] testCase = new String[] { "以每台约200元的价格送到苹果售后维修中心换新机(苹果的保修基本是免费换新机)", "可能以2500~2800元的价格回收", "3700个益农信息社打通服务“最后一公里”", "一位李先生给高政留言说上周五可以帮忙献血", "一位浩宁达高层透露", "五和万科长阳天地5个普宅项目", "以1974点低点和5178点高点作江恩角度线", "纳入统计的18家京系基金公司", "华夏基金与嘉实基金两家京系基金公司", "则应从排名第八的投标人开始依次递补三名投标人" };
    Segment segment = HanLP.newSegment().enableOrganizationRecognize(true).enableNumberQuantifierRecognize(true);
    for (String sentence : testCase) {
        List<Term> termList = segment.seg(sentence);
        System.out.println(termList);
    }
}
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)

Example 30 with Segment

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

the class TestSegment method testIssue343.

public void testIssue343() throws Exception {
    CustomDictionary.insert("酷我");
    CustomDictionary.insert("酷我音乐");
    Segment segment = HanLP.newSegment().enableIndexMode(true);
    System.out.println(segment.seg("1酷我音乐2酷我音乐3酷我4酷我音乐6酷7酷我音乐"));
}
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)

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