Search in sources :

Example 6 with ViterbiSegment

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

use of com.hankcs.hanlp.seg.Viterbi.ViterbiSegment in project HanLP by hankcs.

the class TestSegment method testIssue16.

public void testIssue16() throws Exception {
    CustomDictionary.insert("爱听4g", "nz 1000");
    Segment segment = new ViterbiSegment();
    System.out.println(segment.seg("爱听4g"));
    System.out.println(segment.seg("爱听4G"));
    System.out.println(segment.seg("爱听4G"));
    System.out.println(segment.seg("爱听4G"));
    System.out.println(segment.seg("愛聽4G"));
}
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 8 with ViterbiSegment

use of com.hankcs.hanlp.seg.Viterbi.ViterbiSegment in project HanLP by hankcs.

the class DemoNShortSegment method main.

public static void main(String[] args) {
    Segment nShortSegment = new NShortSegment().enableCustomDictionary(false).enablePlaceRecognize(true).enableOrganizationRecognize(true);
    Segment shortestSegment = new ViterbiSegment().enableCustomDictionary(false).enablePlaceRecognize(true).enableOrganizationRecognize(true);
    String[] testCase = new String[] { "今天,刘志军案的关键人物,山西女商人丁书苗在市二中院出庭受审。", "江西省监狱管理局与中国太平洋财产保险股份有限公司南昌中心支公司保险合同纠纷案", "新北商贸有限公司" };
    for (String sentence : testCase) {
        System.out.println("N-最短分词:" + nShortSegment.seg(sentence) + "\n最短路分词:" + shortestSegment.seg(sentence));
    }
}
Also used : NShortSegment(com.hankcs.hanlp.seg.NShort.NShortSegment) ViterbiSegment(com.hankcs.hanlp.seg.Viterbi.ViterbiSegment) NShortSegment(com.hankcs.hanlp.seg.NShort.NShortSegment) Segment(com.hankcs.hanlp.seg.Segment) ViterbiSegment(com.hankcs.hanlp.seg.Viterbi.ViterbiSegment)

Aggregations

Segment (com.hankcs.hanlp.seg.Segment)8 ViterbiSegment (com.hankcs.hanlp.seg.Viterbi.ViterbiSegment)8 CRFSegment (com.hankcs.hanlp.seg.CRF.CRFSegment)7 DijkstraSegment (com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment)7 DoubleArrayTrieSegment (com.hankcs.hanlp.seg.Other.DoubleArrayTrieSegment)7 NShortSegment (com.hankcs.hanlp.seg.NShort.NShortSegment)1