Search in sources :

Example 1 with NShortSegment

use of com.hankcs.hanlp.seg.NShort.NShortSegment in project HanLP by hankcs.

the class TestXianDaiHanYu method testSeg.

public void testSeg() throws Exception {
    Segment segment = new NShortSegment().enableNameRecognize(true);
    HanLP.Config.enableDebug(true);
    System.out.println(segment.seg("我在区人保工作"));
}
Also used : NShortSegment(com.hankcs.hanlp.seg.NShort.NShortSegment) Segment(com.hankcs.hanlp.seg.Segment) NShortSegment(com.hankcs.hanlp.seg.NShort.NShortSegment)

Example 2 with NShortSegment

use of com.hankcs.hanlp.seg.NShort.NShortSegment in project HanLP by hankcs.

the class TestPersonRecognition method testNameRecognition.

public void testNameRecognition() throws Exception {
    HanLP.Config.enableDebug();
    NShortSegment segment = new NShortSegment();
    System.out.println(segment.seg("世界上最长的姓名是简森·乔伊·亚历山大·比基·卡利斯勒·达夫·埃利奥特·福克斯·伊维鲁莫·马尔尼·梅尔斯·帕特森·汤普森·华莱士·普雷斯顿。"));
}
Also used : NShortSegment(com.hankcs.hanlp.seg.NShort.NShortSegment)

Example 3 with NShortSegment

use of com.hankcs.hanlp.seg.NShort.NShortSegment 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

NShortSegment (com.hankcs.hanlp.seg.NShort.NShortSegment)3 Segment (com.hankcs.hanlp.seg.Segment)2 ViterbiSegment (com.hankcs.hanlp.seg.Viterbi.ViterbiSegment)1