本文整理汇总了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);
}
}
}
}
示例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);
}
};
}
示例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("南翔向宁夏固原市彭阳县红河镇黑牛沟村捐赠了挖掘机"));
}
示例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();
}
示例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("黑龙江建筑职业技术学院近百学生发生冲突"));
}
示例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("东欧的球队"));
}
示例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("林志玲亮相网友:确定不是波多野结衣?"));
}
示例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("汤姆和杰克逊"));
}
示例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);
}
}
}
示例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("编剧邵钧林和稽道青说"));
}
示例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(
"我遗忘我的密码了"
));
}
示例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);
}
示例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));
}
示例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);
}
示例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("清河工业园区"));
}