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


Java ConcurrentDependencyNode类代码示例

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

	}
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:52,代码来源:MaltParser.java

示例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);
		}

	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:47,代码来源:MaltParser.java


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