本文整理汇总了Java中org.maltparser.concurrent.graph.ConcurrentDependencyNode类的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentDependencyNode类的具体用法?Java ConcurrentDependencyNode怎么用?Java ConcurrentDependencyNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConcurrentDependencyNode类属于org.maltparser.concurrent.graph包,在下文中一共展示了ConcurrentDependencyNode类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doProcess
import org.maltparser.concurrent.graph.ConcurrentDependencyNode; //导入依赖的package包/类
@Override
protected void doProcess(final JCas jCas) throws AnalysisEngineProcessException {
for (final Sentence sentence : JCasUtil.select(jCas, Sentence.class)) {
final List<WordToken> wordTokens = JCasUtil.selectCovered(jCas, WordToken.class, sentence);
final String[] tokens = new String[wordTokens.size()];
int i = 0;
for (final WordToken wt : wordTokens) {
// TODO: Can include the lemma too
final String pos = wt.getPartOfSpeech();
final String lemma = getLemma(wt);
final String tag = udTags ? convertPennToUniversal(pos) : pos;
tokens[i] = String.format("%d\t%s\t%s\t%s\t%s\t_", i + 1, wt.getCoveredText(), lemma, tag, pos);
// System.out.println(tokens[i]);
i++;
}
try {
final ConcurrentDependencyGraph graph = model.parse(tokens);
for (int j = 0; j < graph.nDependencyNodes(); j++) {
final ConcurrentDependencyNode node = graph.getDependencyNode(j);
if (node.hasHead()) {
final Dependency dep = new Dependency(jCas);
// System.out.println(node.getIndex() + " : " + node.isRoot() + ": " +
// node.getHeadIndex());
if (node.getHeadIndex() != 0) {
dep.setGovernor(wordTokens.get(node.getHeadIndex() - 1));
final String label = node.getLabel(7);
dep.setDependencyType(label);
} else {
dep.setGovernor(wordTokens.get(node.getIndex() - 1));
dep.setDependencyType("ROOT");
}
dep.setDependent(wordTokens.get(node.getIndex() - 1));
dep.setBegin(dep.getDependent().getBegin());
dep.setEnd(dep.getDependent().getEnd());
addToJCasIndex(dep);
}
}
} catch (final Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
}
示例2: doProcess
import org.maltparser.concurrent.graph.ConcurrentDependencyNode; //导入依赖的package包/类
@Override
protected void doProcess(final JCas jCas) throws AnalysisEngineProcessException {
for (final Sentence sentence : JCasUtil.select(jCas, Sentence.class)) {
final List<WordToken> wordTokens = JCasUtil.selectCovered(jCas, WordToken.class, sentence);
final String[] tokens = new String[wordTokens.size()];
int i = 0;
for (final WordToken wt : wordTokens) {
final String pos = wt.getPartOfSpeech();
final String lemma = getLemma(wt);
final String tag = udTags ? convertPennToUniversal(pos) : pos;
tokens[i] = String.format("%d\t%s\t%s\t%s\t%s\t_", i + 1, wt.getCoveredText(), lemma, tag, pos);
i++;
}
try {
final ConcurrentDependencyGraph graph = model.parse(tokens);
for (int j = 0; j < graph.nDependencyNodes(); j++) {
final ConcurrentDependencyNode node = graph.getDependencyNode(j);
if (node.hasHead()) {
final Dependency dep = new Dependency(jCas);
if (node.getHeadIndex() != 0) {
dep.setGovernor(wordTokens.get(node.getHeadIndex() - 1));
final String label = node.getLabel(7);
dep.setDependencyType(label);
} else {
dep.setGovernor(wordTokens.get(node.getIndex() - 1));
dep.setDependencyType("ROOT");
}
dep.setDependent(wordTokens.get(node.getIndex() - 1));
dep.setBegin(dep.getDependent().getBegin());
dep.setEnd(dep.getDependent().getEnd());
addToJCasIndex(dep);
}
}
} catch (final Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
}