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("把市场经济奉行的等价交换原则引入党的生活和国家机关政务活动中"));
}
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"));
}
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));
}
}
Aggregations