本文整理汇总了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();
}
示例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);
}
}
}
示例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);
}