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


Java LogicLanguageServices.getConjunctionPredicate方法代码示例

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


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

示例1: getCoordinationPredicate

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
/**
 * Given a coordination predicate, as initiated by
 * {@link CoordinationC1Rule}, return the appropriate coordination instance
 * of conjunction predicate.
 *
 * @param coordinationWrapper
 *            Coordination predicate, as initiated by
 *            {@link CoordinationC1Rule}.
 * @param coordinatedType
 *            The type of the coordinated items.
 */
public static LogicalConstant getCoordinationPredicate(
		String coordinationWrapperBaseName, Type coordinatedType) {
	if (coordinatedType.equals(LogicLanguageServices.getTypeRepository()
			.getTruthValueType())) {
		return coordinationWrapperBaseName
				.equals(INSTANCE.conjunctionLabel) ? LogicLanguageServices
				.getConjunctionPredicate() : LogicLanguageServices
				.getDisjunctionPredicate();
	} else if (coordinatedType.equals(LogicLanguageServices
			.getTypeRepository().getEntityType())) {
		return coordinationWrapperBaseName
				.equals(INSTANCE.conjunctionLabel) ? INSTANCE.entityConjunctionInstance
				: INSTANCE.entityDisjunctionInstance;
	} else {
		LOG.debug("Unsupported coordinationw wrapper type: %s with %s",
				coordinationWrapperBaseName, coordinatedType);
		return null;
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:31,代码来源:CoordinationServices.java

示例2: createSimpleCoordination

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
@Override
public LogicalExpression createSimpleCoordination(
		LogicalExpression coordinated, LogicalExpression coordinator) {
	// Create a binary predicate from coordinator
	if (!isBaseCoordinator(coordinator)) {
		return null;
	}

	if (LogicLanguageServices.getTypeRepository().getTruthValueType()
			.equals(coordinated.getType())) {
		// Case coordinating truth-typed expressions
		final LogicalExpression coordinationPredicate;
		if (isConjunctionCoordinator((LogicalConstant) coordinator)) {
			coordinationPredicate = LogicLanguageServices
					.getConjunctionPredicate();
		} else if (isDisjunctionCoordinator((LogicalConstant) coordinator)) {
			coordinationPredicate = LogicLanguageServices
					.getDisjunctionPredicate();
		} else {
			throw new IllegalStateException("invalid coordinator: "
					+ coordinator);
		}

		final Variable variable = new Variable(LogicLanguageServices
				.getTypeRepository().getTruthValueType());
		final LogicalExpression[] args = new LogicalExpression[2];
		args[0] = variable;
		args[1] = coordinated;
		return Simplify.of(new Literal(coordinationPredicate, args));
	}

	return null;
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:34,代码来源:LogicalExpressionCoordinationServices.java

示例3: createCoordination

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
/**
 * Create an AMR coordination, e.g., (lambda $0:e (and:<t*,t> (C:<e,t> $0)
 * (c_op1:<e,<e,t>> $0 a1) ... (c_opn:<e,<e,t>> $0 an))).
 *
 * @param coordinatedElements
 *            The entities being coordinated a1,...,an, where the type of
 *            each ai is baseType.
 * @param baseType
 *            The type of all coordinated entities.
 * @param coordinationWrapper
 *            The wrapping predicate that packed this coordination, as
 *            initialized by {@link CoordinationC1Rule}. C is inferred from
 *            this wrapper.
 * @return <e,t>-typed logical expression.
 */
public static LogicalExpression createCoordination(
		LogicalExpression[] coordinatedElements, Type baseType,
		LogicalConstant coordinationWrapper) {
	// Create coordination variable.
	final Variable coordinationVariable = new Variable(
			LogicLanguageServices.getTypeRepository().getEntityType());

	final LogicalExpression[] conjunctionElements = new LogicalExpression[coordinatedElements.length + 1];

	// Wrap each coordinated element with a c_op predicate and get the
	// common type.
	Type commonType = null;
	for (int i = 0; i < coordinatedElements.length; ++i) {
		final LogicalExpression element = coordinatedElements[i];
		if (commonType == null || element.getType().isExtending(commonType)) {
			commonType = element.getType();
		} else if (!commonType.isExtending(element.getType())) {
			return null;
		}
		conjunctionElements[i + 1] = new Literal(createpCOpPredicate(i + 1,
				baseType), ArrayUtils.create(coordinationVariable, element));
	}

	/*
	 * Create the coordination instance, the conjunction of all the c_op
	 * literals and the instance unary literal.
	 */
	final LogicalConstant predicate = getCoordinationPredicate(
			coordinationWrapper.getBaseName(), commonType);
	if (predicate == null) {
		return null;
	}
	conjunctionElements[0] = new Literal(predicate,
			ArrayUtils.create(coordinationVariable));

	return new Lambda(coordinationVariable, new Literal(
			LogicLanguageServices.getConjunctionPredicate(),
			conjunctionElements));
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:55,代码来源:CoordinationServices.java

示例4: typeShiftSemantics

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
/**
 * (lambda $0:x (g $0)) ==> (lambda $0:<x,t> (lambda $1:x (and:<t*,t> ($0
 * $1) (g $1))))
 */
protected LogicalExpression typeShiftSemantics(LogicalExpression sem) {
	final Type semType = sem.getType();
	final Type range = semType.getRange();

	if (semType.isComplex()
			&& range.equals(LogicLanguageServices.getTypeRepository()
					.getTruthValueType())) {

		// Make sure the expression is wrapped with lambda operators, since
		// the variables are required
		final Lambda lambda = (Lambda) sem;

		// Variable for the new outer lambda
		final Variable outerVariable = new Variable(LogicLanguageServices
				.getTypeRepository().getTypeCreateIfNeeded(
						LogicLanguageServices.getTypeRepository()
								.getTruthValueType(),
						lambda.getArgument().getType()));

		// Create the literal applying the function to the original
		// argument
		final LogicalExpression[] args = new LogicalExpression[1];
		args[0] = lambda.getArgument();
		final Literal newLiteral = new Literal(outerVariable, args);

		// Create the conjunction of newLitral and the original body
		final Literal conjunction = new Literal(
				LogicLanguageServices.getConjunctionPredicate(),
				ArrayUtils.create(newLiteral, lambda.getBody()));

		// The new inner lambda
		final Lambda innerLambda = new Lambda(lambda.getArgument(),
				conjunction);

		// The new outer lambda
		final Lambda outerLambda = new Lambda(outerVariable, innerLambda);

		// Simplify the output and return it
		final LogicalExpression ret = Simplify.of(outerLambda);

		return ret;
	}

	return null;
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:50,代码来源:SententialAdverbialTypeShifting.java

示例5: typeShiftSemantics

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
/**
 * (lambda $0:x (g $0)) ==> (lambda $0:<x,t> (lambda $1:x (and:<t*,t> ($0
 * $1) (g $1))))
 */
protected LogicalExpression typeShiftSemantics(LogicalExpression sem) {
	final Type semType = sem.getType();
	final Type range = semType.getRange();

	if (semType.isComplex() && range.equals(LogicLanguageServices
			.getTypeRepository().getTruthValueType())) {

		// Make sure the expression is wrapped with lambda operators, since
		// the variables are required
		final Lambda lambda = (Lambda) sem;

		// Variable for the new outer lambda
		final Variable outerVariable = new Variable(LogicLanguageServices
				.getTypeRepository().getTypeCreateIfNeeded(
						LogicLanguageServices.getTypeRepository()
								.getTruthValueType(),
						lambda.getArgument().getType()));

		// Create the literal applying the function to the original
		// argument
		final LogicalExpression[] args = new LogicalExpression[1];
		args[0] = lambda.getArgument();
		final Literal newLiteral = new Literal(outerVariable, args);

		// Create the conjunction of newLitral and the original body
		final Literal conjunction = new Literal(
				LogicLanguageServices.getConjunctionPredicate(),
				ArrayUtils.create(newLiteral, lambda.getBody()));

		// The new inner lambda
		final Lambda innerLambda = new Lambda(lambda.getArgument(),
				conjunction);

		// The new outer lambda
		final Lambda outerLambda = new Lambda(outerVariable, innerLambda);

		// Simplify the output and return it
		final LogicalExpression ret = Simplify.of(outerLambda);

		return ret;
	}

	return null;
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:49,代码来源:AbstractShiftingRule.java

示例6: of

import edu.cornell.cs.nlp.spf.mr.lambda.LogicLanguageServices; //导入方法依赖的package包/类
public static LogicalExpression of(LogicalExpression exp,
		LogicalExpression existsPredicate, LogicalConstant aPredicate,
		Map<Type, LogicalConstant> equalsPredicates) {
	final AToExists visitor = new AToExists(existsPredicate, aPredicate);
	visitor.visit(exp);

	// If the stack still contains variables, try to wrap the result and
	// return it
	final LogicalExpression output = visitor.noUpperLevelWrapIfPossible(
			visitor.result.first(), visitor.result.second());

	if (visitor.result.second().isEmpty()) {
		return Simplify.of(output);
	} else if (visitor.result.second().size() == 1) {
		// Case a single item on the stack, there are a few cases

		// Get the type of the current logical expression and the
		// appropriate equals
		final Type expType = LogicLanguageServices.getTypeRepository()
				.generalizeType(visitor.result.first().getType());
		final LogicalConstant equals = equalsPredicates.get(expType);

		if (equals != null) {
			// Create an 'equals' structure

			// The variable that threads the equals
			final Variable variable = new Variable(expType);

			// Create the equals literal
			final LogicalExpression equalsLiteral = new Literal(equals,
					ArrayUtils.create(variable, visitor.result.first()));

			// Conjunction of the equals literal and the rest
			final Literal conjLiteral = new Literal(
					LogicLanguageServices.getConjunctionPredicate(),
					ArrayUtils.create(visitor.result.second().peek()
							.second(), equalsLiteral));

			// Create the exists literal for the variable of the indefinite
			// quatifier
			final LogicalExpression existsLiteral = new Literal(
					visitor.existsPredicate, ArrayUtils.create(new Lambda(
							visitor.result.second().peek().first(),
							conjLiteral)));

			// Create the final lambda operator, simplify and return
			return Simplify.of(new Lambda(variable, existsLiteral));
		} else if (isVacuousLambda(output)) {
			final Lambda lambda = (Lambda) output;

			// Create the existential
			final Literal existential = new Literal(existsPredicate,
					ArrayUtils.create((LogicalExpression) new Lambda(
							visitor.result.second().peek().first(),
							visitor.result.second().peek().second())));

			return Simplify
					.of(new Lambda(lambda.getArgument(), existential));
		} else {
			LOG.error(
					"ERROR: No 'equals' for %s and not a vacuous lambda, failed to process: %s",
					expType, exp);
			throw new IllegalStateException(
					String.format(
							"ERROR: No 'equals' for %s and not a vacuous lambda, failed to process: %s",
							expType, exp));
		}
	} else {
		// Case conversion failed
		LOG.error("ERROR: Failed to convert indefinite quantifier to an existential one");
		return null;
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:74,代码来源:AToExists.java


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