当前位置: 首页>>代码示例>>Java>>正文


Java DijkstraSegment类代码示例

本文整理汇总了Java中com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment的典型用法代码示例。如果您正苦于以下问题:Java DijkstraSegment类的具体用法?Java DijkstraSegment怎么用?Java DijkstraSegment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DijkstraSegment类属于com.hankcs.hanlp.seg.Dijkstra包,在下文中一共展示了DijkstraSegment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBatch

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testBatch() throws Exception
{
    List<File> fileList = FolderWalker.open(FOLDER);
    int i = 0;
    for (File file : fileList)
    {
        System.out.println(++i + " / " + fileList.size() + " " + file.getName() + " ");
        String path = file.getAbsolutePath();
        String content = IOUtil.readTxt(path);
        DijkstraSegment segment = new DijkstraSegment();
        List<List<Term>> sentenceList = segment.seg2sentence(content);
        for (List<Term> sentence : sentenceList)
        {
            if (SentencesUtil.hasNature(sentence, Nature.nr))
            {
                System.out.println(sentence);
            }
        }
    }
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:21,代码来源:TestPersonRecognition.java

示例2: createShortest

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public static HanLPTokenizerFactory createShortest(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    return new HanLPTokenizerFactory(indexSettings, environment, name, settings) {
        @Override
        public Tokenizer create() {
            Segment seg = new DijkstraSegment().enableCustomDictionary(false).enablePlaceRecognize(true).enableOrganizationRecognize(true);
            return new HanLPTokenizer(seg, null, enablePorterStemming);
        }
    };
}
 
开发者ID:hualongdata,项目名称:hanlp-ext,代码行数:10,代码来源:HanLPTokenizerFactory.java

示例3: testSeg

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testSeg() throws Exception
{
    HanLP.Config.enableDebug();
    DijkstraSegment segment = new DijkstraSegment();
    segment.enableJapaneseNameRecognize(false);
    segment.enableTranslatedNameRecognize(false);
    segment.enableNameRecognize(false);
    segment.enableCustomDictionary(false);

    segment.enablePlaceRecognize(true);
    System.out.println(segment.seg("南翔向宁夏固原市彭阳县红河镇黑牛沟村捐赠了挖掘机"));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:13,代码来源:TestNSRecognition.java

示例4: testMake

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testMake() throws Exception
{
    DijkstraSegment segment = new DijkstraSegment();
    String line = null;
    BufferedReader bw = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\Doc\\语料库\\company.dic")));
    BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("data/test/nt/company.txt")));
    int limit = Integer.MAX_VALUE;
    while ((line = bw.readLine()) != null && limit-- > 0)
    {
        if (line.endsWith(")")) continue;
        if (line.length() < 4) continue;
        if (line.contains("个体") || line.contains("个人"))
        {
            continue;
        }
        List<Term> termList = segment.seg(line);
        if (termList.size() == 0) continue;
        Term last = termList.get(termList.size() - 1);
        last.nature = Nature.nis;
        br.write("[");
        for (Term term : termList)
        {
            br.write(term.toString());
            if (term != last) br.write(" ");
        }
        br.write("]/ntc");
        br.newLine();
        br.flush();
    }
    bw.close();
    br.close();
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:33,代码来源:TestMakeCompanyCorpus.java

示例5: testCase

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testCase() throws Exception
{
    HanLP.Config.enableDebug();
    DijkstraSegment segment = new DijkstraSegment();
    segment.enableOrganizationRecognize(true);
    System.out.println(segment.seg("黑龙江建筑职业技术学院近百学生发生冲突"));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:8,代码来源:TestMakeCompanyCorpus.java

示例6: testSeg

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testSeg() throws Exception
{
    HanLP.Config.enableDebug();
    DijkstraSegment segment = new DijkstraSegment();
    segment.enableCustomDictionary(false);

    segment.enableOrganizationRecognize(true);
    System.out.println(segment.seg("东欧的球队"));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:10,代码来源:TestNTRecognition.java

示例7: testSeg

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testSeg() throws Exception
{
    HanLP.Config.enableDebug();
    DijkstraSegment segment = new DijkstraSegment();
    segment.enableJapaneseNameRecognize(true);
    System.out.println(segment.seg("林志玲亮相网友:确定不是波多野结衣?"));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:8,代码来源:TestMakeJapaneseName.java

示例8: testNonRec

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testNonRec() throws Exception
{
    HanLP.Config.enableDebug();
    DijkstraSegment segment = new DijkstraSegment();
    segment.enableTranslatedNameRecognize(true);
    System.out.println(segment.seg("汤姆和杰克逊"));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:8,代码来源:TestMakeTranslateName.java

示例9: testHeadNRF

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testHeadNRF() throws Exception
{
    DijkstraSegment segment = new DijkstraSegment();
    segment.enableTranslatedNameRecognize(false);
    for (String name : IOUtil.readLineList("data/dictionary/person/nrf.txt"))
    {
        List<Term> termList = segment.seg(name);
        if (termList.get(0).nature != Nature.nrf)
        {
            System.out.println(name + " : " + termList);
        }
    }
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:14,代码来源:TestMakeTranslateName.java

示例10: testChineseNameRecognition

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testChineseNameRecognition() throws Exception
{
    HanLP.Config.enableDebug();
    Segment segment = new DijkstraSegment();
    System.out.println(segment.seg("编剧邵钧林和稽道青说"));

}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:8,代码来源:TestPersonRecognition.java

示例11: testSeg

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testSeg() throws Exception
{
    HanLP.Config.enableDebug();
    Segment segment = new DijkstraSegment();
    System.out.println(segment.seg(
            "我遗忘我的密码了"
    ));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:9,代码来源:TestSegment.java

示例12: testViterbi

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
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);
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:9,代码来源:TestSegment.java

示例13: testSpeechTagging

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testSpeechTagging() throws Exception
{
    HanLP.Config.enableDebug();
    String text = "教授正在教授自然语言处理课程";
    DijkstraSegment segment = new DijkstraSegment();

    System.out.println("未标注:" + segment.seg(text));
    segment.enablePartOfSpeechTagging(true);
    System.out.println("标注后:" + segment.seg(text));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:11,代码来源:TestSegment.java

示例14: testSeg

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testSeg() throws Exception
{
    String text = "商品与服务";
    DijkstraSegment segment = new DijkstraSegment();
    List<Term> resultList = segment.seg(text);
    System.out.println(resultList);
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:8,代码来源:TestDijkstra.java

示例15: testSeg

import com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment; //导入依赖的package包/类
public void testSeg() throws Exception
{
    HanLP.Config.enableDebug();
    DijkstraSegment segment = new DijkstraSegment();
    segment.enableCustomDictionary(false);

    segment.enableOrganizationRecognize(true);
    System.out.println(segment.seg("清河工业园区"));
}
 
开发者ID:ml-distribution,项目名称:HanLP,代码行数:10,代码来源:TestNTRecognition.java


注:本文中的com.hankcs.hanlp.seg.Dijkstra.DijkstraSegment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。