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


Java DijkstraSegment.seg方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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


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