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


Java ResolvedDependency.getCategory方法代码示例

本文整理汇总了Java中edu.uw.easysrl.dependencies.ResolvedDependency.getCategory方法的典型用法代码示例。如果您正苦于以下问题:Java ResolvedDependency.getCategory方法的具体用法?Java ResolvedDependency.getCategory怎么用?Java ResolvedDependency.getCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uw.easysrl.dependencies.ResolvedDependency的用法示例。


在下文中一共展示了ResolvedDependency.getCategory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showDependency

import edu.uw.easysrl.dependencies.ResolvedDependency; //导入方法依赖的package包/类
/**
 * Decide which dependencies are worth showing.
 */
private boolean showDependency(final ResolvedDependency dep, final SyntaxTreeNode parse) {
	final SyntaxTreeNodeLeaf predicateNode = parse.getLeaves().get(dep.getHead());
	if (dep.getHead() == dep.getArgumentIndex()) {
		return false;
	} else if (dep.getSemanticRole() != SRLFrame.NONE) {
		return true;
	} else if (predicateNode.getPos().startsWith("JJ") && dep.getCategory() != Category.valueOf("NP/N")) {
		// Adjectives, excluding determiners
		return true;
	} else if (Category.valueOf("(S\\NP)/(S\\NP)") == dep.getCategory()) {
		// Exclude auxiliary verbs. Hopefully the SRL will have already identified the times this category isn't
		// an auxiliary.
		return false;
	} else if (predicateNode.getPos().startsWith("NN") && dep.getCategory().isFunctionInto(Category.N)) {
		// Checking category to avoid annoying getting a "subject" dep on yesterday|NN|(S\NP)\(S\NP)
		return true;
	} else if (predicateNode.getPos().startsWith("VB")) {
		// Other verb arguments, e.g. particles
		return true;
	} else {
		return false;
	}
}
 
开发者ID:uwnlp,项目名称:EasySRL,代码行数:27,代码来源:ParsePrinter.java

示例2: evaluate

import edu.uw.easysrl.dependencies.ResolvedDependency; //导入方法依赖的package包/类
private static Results evaluate(final Set<ResolvedDependency> predicted, final Set<ResolvedDependency> gold,
		final ErrorAnalysis ea, final List<String> words) {

	final Set<ResolvedDependency> correctDeps = Sets.intersection(predicted, gold);

	for (final ResolvedDependency dep : Sets.union(predicted, gold)) {
		final String key = dep.getCategory() + "." + dep.getArgNumber();
		Results results = ea.perRelationResults.get(key);
		if (results == null) {
			results = new Results();
			ea.perRelationResults.put(key, results);
		}
		final Results resultsForDep = new Results(predicted.contains(dep) ? 1 : 0, correctDeps.contains(dep) ? 1
				: 0, gold.contains(dep) ? 1 : 0);
		results.add(resultsForDep);

		ea.lengthBinToResults.get(Math.abs(dep.getOffset()) / 5).add(resultsForDep);
	}

	// System.out.println(predicted.size());
	// for (final ResolvedDependency dep : predicted) {
	// System.out.println(words.get(dep.getHead()) + "\t" + dep.getCategory() + "." + dep.getArgNumber() + "\t"
	// + words.get(dep.getArgumentIndex()));
	// }
	// System.out.println();

	addCounts(Sets.difference(predicted, gold), ea.precisionErrors, words);
	addCounts(Sets.difference(gold, predicted), ea.recallErrors, words);
	addCounts(correctDeps, ea.correct, words);

	return new Results(predicted.size(), correctDeps.size(), gold.size());
}
 
开发者ID:uwnlp,项目名称:EasySRL,代码行数:33,代码来源:CCGBankEvaluation.java

示例3: dependencyToString

import edu.uw.easysrl.dependencies.ResolvedDependency; //导入方法依赖的package包/类
public static String dependencyToString(final ResolvedDependency dep) {
    return dep.getHead() + "_" + dep.getArgument() + "_" + dep.getCategory() + "." + dep.getArgNumber();
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:4,代码来源:CcgEvaluation.java

示例4: parseDependency

import edu.uw.easysrl.dependencies.ResolvedDependency; //导入方法依赖的package包/类
private DisjunctiveNode parseDependency(final ResolvedDependency dep) {
	final DisjunctiveNode parent = new DisjunctiveNode();
	final Collection<ConjunctiveDependencyNode> possibleLabels = new ArrayList<>();

	if (dep.getOffset() == 0 || // Unrealized arguments. Make the labels latent.
			// Unlabelled arguments are those which are under-specified from
			// the training charts
			dep.getSemanticRole() == SRLFrame.UNLABELLED_ARGUMENT) {

		// Underspecified labels.
		for (final SRLLabel label : cutoffsDictionary.getRoles(words.get(dep.getHead()).word, dep.getCategory(),
				dep.getPreposition(), dep.getArgNumber())) {
			if (cutoffsDictionary.isFrequent(dep.getCategory(), dep.getArgNumber(), label)) {
				final ResolvedDependency labelledDep = dep.overwriteLabel(label);

				possibleLabels.add(new ConjunctiveDependencyNode(labelledDep, parent, cutoffsDictionary.isFrequent(
						label, dep.getOffset())));
			}

		}
	} else {
		// Gold labels.

		if (!cutoffsDictionary.getRoles(words.get(dep.getHead()).word, dep.getCategory(), dep.getPreposition(),
				dep.getArgNumber()).contains(dep.getSemanticRole())) {
			throw new RuntimeException("Role " + dep.getSemanticRole() + " should have been pruned:"
					+ words.get(dep.getHead()).word + " " + dep.getCategory() + " " + dep.getPreposition() + " "
					+ dep.getArgNumber());
		}

		Preconditions.checkState(cutoffsDictionary.isFrequent(dep.getCategory(), dep.getArgNumber(),
				dep.getSemanticRole()));

		possibleLabels.add(new ConjunctiveDependencyNode(dep, parent, cutoffsDictionary.isFrequent(
				dep.getSemanticRole(), dep.getOffset())));
	}

	for (final ConjunctiveDependencyNode depNode : possibleLabels) {
		parent.addChild(depNode);
		conjunctiveNodes.add(depNode);
	}
	return parent;
}
 
开发者ID:uwnlp,项目名称:EasySRL,代码行数:44,代码来源:FeatureForest.java


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