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