當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。