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


Java LogicLanguageServices.isCoordinationPredicate方法代码示例

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


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

示例1: test

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Test
public void test() {
	final LogicalExpression exp = TestServices.getCategoryServices()
			.readSemantics(
					"(a:<id,<<e,t>,e>> !1 (lambda $0:e (and:<t*,t> (state-01:<e,t> $0) (c_ARG0:<e,<e,t>> $0 (a:<id,<<e,t>,e>> !2 (lambda $1:e (and:<t*,t> (person:<e,t> $1) (c_name:<e,<e,t>> $1 Megawati:e))))))))");
	final LogicalExpression partialExp = TestServices.getCategoryServices()
			.readSemantics(
					"(a:<id,<<e,t>,e>> !2 (lambda $1:e (and:<t*,t> (person:<e,t> $1) (c_name:<e,<e,t>> $1 Megawati:e))))");
	final SupervisedFilterFactory<SingleSentence> factory = new SupervisedFilterFactory<SingleSentence>(
			e -> !LogicLanguageServices.isCoordinationPredicate(e));
	Assert.assertTrue(factory.create(exp)
			.test(new ParsingOp<LogicalExpression>(
					Category.create(Syntax.N, partialExp),
					new SentenceSpan(1, 1, 2),
					RuleName.create("dummy", Direction.FORWARD))));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:17,代码来源:SupervisedFilterFactoryTest.java

示例2: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(Literal literal) {
	increaseDepth();
	boolean literalHasOnlyVariables = true;
	literal.getPredicate().accept(this);
	literalHasOnlyVariables &= variablesOnly;
	final int len = literal.numArgs();
	for (int i = 0; i < len; ++i) {
		literal.getArg(i).accept(this);
		literalHasOnlyVariables &= variablesOnly;
	}
	--depth;

	if (!literalHasOnlyVariables
			&& (!skipCoordinations || !LogicLanguageServices
					.isCoordinationPredicate(literal.getPredicate()))) {
		addCurrent(literal);
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:20,代码来源:ExtractTypedSubExpression.java

示例3: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(LogicalConstant logicalConstant) {
	if (logicalConstant.getType().isComplex()
			&& !LogicLanguageServices
					.isCoordinationPredicate(logicalConstant)
			&& !LogicLanguageServices
					.isArrayIndexPredicate(logicalConstant)
			&& !LogicLanguageServices.isArraySubPredicate(logicalConstant)) {
		// Case found a predicate, add it to the return set
		predicates.add(logicalConstant);
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:13,代码来源:GetAllPredicates.java

示例4: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(Literal literal) {
	// Visit the predicate
	literal.getPredicate().accept(this);

	final LogicalExpression pred = literal.getPredicate();
	final int numArgs = literal.numArgs();
	if (!LogicLanguageServices.isCoordinationPredicate(pred)
			&& !LogicLanguageServices.isArrayIndexPredicate(pred)
			&& !LogicLanguageServices.isArraySubPredicate(pred)
			&& literal.getPredicate() instanceof LogicalConstant) {
		if (numArgs == 1
				&& !(literal.getArg(0) instanceof LogicalConstant)) {
			// Unary predicates
			predConstPairs.add(Pair.of(literal.getPredicate(),
					(LogicalExpression) null));
			return;
		} else if (numArgs == 2
				&& !(literal.getArg(0) instanceof LogicalConstant)
				&& IsExtendedConstant.of(literal.getArg(1))) {
			// Binary predicate
			predConstPairs.add(Pair.of(literal.getPredicate(),
					literal.getArg(1)));
			return;
		}
	}

	// Just visit the arguments and predicate
	for (int i = 0; i < numArgs; ++i) {
		literal.getArg(i).accept(this);
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:33,代码来源:SingleSentencePartialCreditTestingStatistics.java

示例5: isFactorable

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
public static boolean isFactorable(LogicalConstant constant) {
	return !LogicLanguageServices.isCoordinationPredicate(constant)
			&& !LogicLanguageServices.isArrayIndexPredicate(constant)
			&& !LogicLanguageServices.isArraySubPredicate(constant)
			&& !LogicLanguageServices.getTypeRepository().getIndexType()
					.equals(constant.getType())
			&& INSTANCE.filter.apply(constant)
			&& !INSTANCE.unfactoredConstants.contains(constant);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:10,代码来源:FactoringServices.java

示例6: getCoordinatedItems

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
/**
 * Given a coordination skolem term, return all the coordinated elements
 * (i.e., the second arguments in all c_opX binary literals in the upper
 * most conjunction).
 */
public static List<LogicalExpression> getCoordinatedItems(
		Literal coordination) {
	final LogicalExpression coordinationBody = ((Lambda) coordination
			.getArg(1)).getBody();
	if (coordinationBody instanceof Literal
			&& LogicLanguageServices
					.isCoordinationPredicate(((Literal) coordinationBody)
							.getPredicate())) {
		final Literal coordinationBodyLiteral = (Literal) coordinationBody;
		final int coordinationBodyLiteralNumArgs = coordinationBodyLiteral
				.numArgs();
		final List<LogicalExpression> items = new ArrayList<>(
				coordinationBodyLiteralNumArgs);
		for (int i = 0; i < coordinationBodyLiteralNumArgs; ++i) {
			final LogicalExpression arg = coordinationBodyLiteral.getArg(i);
			if (arg instanceof Literal
					&& ((Literal) arg).numArgs() == 2
					&& ((Literal) arg).getPredicate() instanceof LogicalConstant
					&& isCOpPredicate((LogicalConstant) ((Literal) arg)
							.getPredicate())) {
				items.add(((Literal) arg).getArg(1));
			}
		}
		return items;
	} else {
		return Collections.emptyList();
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:34,代码来源:CoordinationServices.java

示例7: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(Literal literal) {
	final int numArgs = literal.numArgs();
	final LogicalExpression predicate = literal
			.getPredicate() instanceof LogicalConstant
					? OverloadedLogicalConstant.getWrapped(
							(LogicalConstant) literal.getPredicate())
					: literal.getPredicate();
	if (numArgs == 2
			&& !LogicLanguageServices.isCoordinationPredicate(predicate)
			&& predicate instanceof LogicalConstant
			&& constantFilter.test((LogicalConstant) predicate)) {
		countRelationalPairs((LogicalConstant) predicate,
				literal.getArg(1));
		if (!isValid) {
			return;
		}
	}

	if (LogicLanguageServices.isCoordinationPredicate(predicate)) {
		// Try to construct the instance-type-related-type triplets as
		// much as possible. We are trying to do as early as possible,
		// even before the skolem term is closed.
		countInstanceTypeRelatedTypeTriplets(literal);
		if (!isValid) {
			return;
		}
	}

	predicate.accept(this);
	for (int i = 0; i < numArgs; ++i) {
		literal.getArg(i).accept(this);
		if (!isValid) {
			return;
		}
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:38,代码来源:AMRSupervisedFilter.java

示例8: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(Literal literal) {
	final int len = literal.numArgs();
	 TypeRepository typeRepository = LogicLanguageServices
		        .getTypeRepository();
	
	if (LogicLanguageServices.isCoordinationPredicate(literal
			.getPredicate())
			// TODO: Fix this hack. Figure out how 
			|| literal.getPredicate().equals(AND_c)) {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		++currentDepth;
		for (int i = 0; i < len; ++i) {
			outputString.append("\n"
					+ StringUtils.multiply(indentation, currentDepth));
			literal.getArg(i).accept(this);
		}
		--currentDepth;
		outputString.append(')');
	} else if (literal.getPredicate().equals(EX_ex)) {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		outputString.append(' ');
		literal.getArg(0).accept(this); // the variable
		
		++currentDepth;
		for (int i = 1; i < len; ++i) {
			outputString.append("\n"
					+ StringUtils.multiply(indentation, currentDepth));
			literal.getArg(i).accept(this);
		}
		--currentDepth;
		outputString.append(')');
	} else if (!HasFreeVariables.of(literal, true)
			&& outputString.length() > 0) {
		++currentDepth;
		outputString.append("\n"
				+ StringUtils.multiply(indentation, currentDepth));
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		// ++currentDepth;
		for (int i = 0; i < len; ++i) {
			// outputString.append("\n"
			// + StringUtils.multiply(indentation, currentDepth));
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		// --currentDepth;
		--currentDepth;
		outputString.append(')');
	} else {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		for (int i = 0; i < len; ++i) {
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		outputString.append(')');
	}
}
 
开发者ID:sivareddyg,项目名称:UDepLambda,代码行数:70,代码来源:LogicalExpressionSimpleIndenter.java

示例9: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(Literal literal) {
	final int numArgs = literal.numArgs();
	if (LogicLanguageServices.isCoordinationPredicate(literal
			.getPredicate())) {
		// Case coordination predicate.
		for (int i = 0; i < numArgs; ++i) {
			literal.getArg(i).accept(this);
			if (i + 1 < numArgs) {
				outputString.append(' ');
				literal.getPredicate().accept(this);
				outputString.append(' ');
			}
		}
	} else if (numArgs > 1
			&& literal.getArg(0).getType()
					.equals(SkolemServices.getIDType())
			&& literal.getArg(1).getType()
					.equals(SkolemServices.getIDType())) {
		// Case skolem terms with referring ID: pred_{id}^{ref}(args).
		literal.getPredicate().accept(this);
		outputString.append("_{");
		literal.getArg(0).accept(this);
		outputString.append('}');
		outputString.append("^{");
		literal.getArg(1).accept(this);
		outputString.append('}');
		if (numArgs > 2) {
			outputString.append('(');
			for (int i = 2; i < numArgs; ++i) {
				literal.getArg(i).accept(this);
				if (i + 1 < numArgs) {
					outputString.append(", ");
				}
			}
			outputString.append(')');
		}
	} else if (numArgs > 0
			&& literal.getArg(0).getType()
					.equals(SkolemServices.getIDType())) {
		// Case skolem term without reference: pred_{id}(args).
		literal.getPredicate().accept(this);
		outputString.append("_{");
		literal.getArg(0).accept(this);
		outputString.append('}');
		if (numArgs > 1) {
			for (int i = 1; i < numArgs; ++i) {
				outputString.append('(');
				literal.getArg(i).accept(this);
				if (i + 1 < numArgs) {
					outputString.append(", ");
				}
			}
			outputString.append(')');
		}
	} else {
		literal.getPredicate().accept(this);
		outputString.append('(');
		for (int i = 0; i < numArgs; ++i) {
			literal.getArg(i).accept(this);
			if (i + 1 < numArgs) {
				outputString.append(", ");
			}
		}
		outputString.append(')');
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:68,代码来源:LogicalExpressionToLatexString.java

示例10: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(Literal literal) {
	final int len = literal.numArgs();
	if (LogicLanguageServices.isCoordinationPredicate(literal
			.getPredicate())) {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		++currentDepth;
		for (int i = 0; i < len; ++i) {
			outputString.append("\n"
					+ StringUtils.multiply(indentation, currentDepth));
			literal.getArg(i).accept(this);
		}
		--currentDepth;
		outputString.append(')');
	} else if (!HasFreeVariables.of(literal, true)
			&& outputString.length() > 0) {
		++currentDepth;
		outputString.append("\n"
				+ StringUtils.multiply(indentation, currentDepth));
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		// ++currentDepth;
		for (int i = 0; i < len; ++i) {
			// outputString.append("\n"
			// + StringUtils.multiply(indentation, currentDepth));
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		// --currentDepth;
		--currentDepth;
		outputString.append(')');
	} else {
		outputString.append("(");
		literal.getPredicate().accept(this);
		// Visit the arguments to print them. Print a space before each
		// argument.
		for (int i = 0; i < len; ++i) {
			outputString.append(' ');
			literal.getArg(i).accept(this);
		}
		outputString.append(')');
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:49,代码来源:LogicalExpressionToIndentedString.java

示例11: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(LogicalConstant logicalConstant) {
	if (!LogicLanguageServices.isCoordinationPredicate(logicalConstant)) {
		++count;
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:7,代码来源:CountLogicalConstants.java

示例12: visit

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public void visit(Literal literal) {
	testInterruption();
	// Try to get from cache
	if (services.isCached(literal)) {
		result = services.getFromCache(literal);
		return;
	}

	// If it's a coordination update the result variable with the
	// default return value (T for conjunction, F for disjunction)
	final int len = literal.numArgs();
	if (LogicLanguageServices.isCoordinationPredicate(literal
			.getPredicate())) {
		// Case coordination predicate, can short-circuit

		// Get short-circuiting argument value
		final Boolean shortCircuitingValue;
		if (LogicLanguageServices.getConjunctionPredicate().equals(
				literal.getPredicate())) {
			shortCircuitingValue = Boolean.FALSE;
		} else if (LogicLanguageServices.getDisjunctionPredicate().equals(
				literal.getPredicate())) {
			shortCircuitingValue = Boolean.TRUE;
		} else {
			throw new IllegalStateException(
					"unhandled coordination predicate: " + literal);
		}

		for (int i = 0; i < len; ++i) {
			literal.getArg(i).accept(this);
			if (result == null || shortCircuitingValue.equals(result)) {
				// Cache
				services.cacheResult(literal, result);

				return;
			}

		}

		// Case not short-circuited, so return the default value
		result = !shortCircuitingValue;
	} else {
		// Case not a coordination, no shortcuts, use domain executors to
		// evaluate

		// Iterate over the arguments
		final Object[] evalArgs = new Object[len];
		int counter = 0;
		for (int i = 0; i < len; ++i) {
			literal.getArg(i).accept(this);
			if (result == null) {
				// If failed to evaluate, propagate failure to literal

				// Cache
				services.cacheResult(literal, result);

				return;
			} else {
				evalArgs[counter] = result;
			}
			++counter;
		}

		// Execute predicate with arguments, return result
		result = services.evaluateLiteral(literal.getPredicate(), evalArgs);
	}

	// Cache
	services.cacheResult(literal, result);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:72,代码来源:Evaluation.java

示例13: isInterpretable

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public boolean isInterpretable(LogicalConstant constant) {
	return LogicLanguageServices.isCoordinationPredicate(constant);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:5,代码来源:AbstractEvaluationServices.java

示例14: main

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	// //////////////////////////////////////////
	// Init logging
	// //////////////////////////////////////////

	Logger.DEFAULT_LOG = new Log(System.err);
	Logger.setSkipPrefix(true);
	LogLevel.INFO.set();

	// //////////////////////////////////////////
	// Init AMR.
	// //////////////////////////////////////////

	Init.init(new File(args[0]), false);

	for (final SingleSentence sentence : SingleSentenceCollection.read(
			new File(args[1]), new Tokenizer())) {
		System.out.println(sentence.getSample());
		for (final LogicalConstant c : GetConstantsMultiSet.of(sentence
				.getLabel())) {
			if (!LogicLanguageServices.isCoordinationPredicate(c)
					&& !c.getBaseName().startsWith("c_")
					&& !LogicLanguageServices.getNumeralType().equals(
							c.getType())
					&& !AMRServices.isRefPredicate(c)
					&& !LogicLanguageServices.getNegationPredicate()
							.equals(c) && !AMRServices.isSkolemPredicate(c)
					&& !AMRServices.isTextType(c.getType())) {
				final Matcher matcher = PROPBANK_PREDICATE.matcher(c
						.getBaseName());
				if (matcher.matches()) {
					System.out.println(matcher.group("sense"));
				} else {
					System.out.println(c.getBaseName());
				}
			}
		}
		System.out.println();
	}

}
 
开发者ID:clic-lab,项目名称:amr,代码行数:42,代码来源:LemmatizeCandidates.java


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