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


Java ScopeMapping.push方法代码示例

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


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

示例1: equals

import edu.cornell.cs.nlp.spf.mr.lambda.mapping.ScopeMapping; //导入方法依赖的package包/类
@Override
public boolean equals(LogicalExpression exp,
		ScopeMapping<Variable, Variable> mapping) {
	if (!(exp instanceof SkolemId)) {
		return false;
	}

	final Variable mappedValue = mapping.peek(this);
	if (mappedValue == exp && mapping.peekValue(mappedValue) == this) {
		return true;
	} else if (exp instanceof SkolemIdInstanceWrapper) {
		return exp.equals(this, mapping);
	} else if (!mapping.containsValue((SkolemId) exp)) {
		mapping.push(this, (SkolemId) exp);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:20,代码来源:SkolemId.java

示例2: testCreateArg4

import edu.cornell.cs.nlp.spf.mr.lambda.mapping.ScopeMapping; //导入方法依赖的package包/类
@Test
public void testCreateArg4() {
	final LogicalExpression resultSubExp = TestServices
			.getCategoryServices().readSemantics("(pred:<e,t> $0:e)");
	final LogicalExpression functionSubExp = TestServices
			.getCategoryServices().readSemantics("($1:<e,t> $0:e)");
	final Variable applicationArg = (Variable) ((Literal) functionSubExp)
			.getPredicate();
	final LogicalExpression expected = TestServices.getCategoryServices()
			.readSemantics("pred:<e,t>");
	final ScopeMapping<Variable, Variable> scope = new ScopeMapping<Variable, Variable>();
	scope.push((Variable) ((Literal) functionSubExp).getArg(0),
			(Variable) ((Literal) resultSubExp).getArg(0));
	Assert.assertEquals(expected, GetApplicationArgument.createArgument(
			resultSubExp, functionSubExp, applicationArg, scope));

}
 
开发者ID:clic-lab,项目名称:spf,代码行数:18,代码来源:GetApplicationArgumentTest.java

示例3: read

import edu.cornell.cs.nlp.spf.mr.lambda.mapping.ScopeMapping; //导入方法依赖的package包/类
@Override
public Variable read(String string,
		ScopeMapping<String, LogicalExpression> mapping,
		TypeRepository typeRepository, ITypeComparator typeComparator,
		LogicalExpressionReader reader) {

	try {
		final Pair<String, Variable> defintion = readVariableDefintion(
				string, typeRepository);
		if (defintion != null && !mapping.containsKey(string)) {
			mapping.push(defintion.first(), defintion.second());
			return defintion.second();
		} else if (defintion != null) {
			throw new LogicalExpressionRuntimeException(
					"Re-define a global variable: " + string);
		} else {
			// Case variable reference.
			if (mapping.containsKey(string)) {
				return (Variable) mapping.peek(string);
			} else {
				throw new LogicalExpressionRuntimeException(
						"Undefined variable reference: " + string);
			}
		}
	} catch (final RuntimeException e) {
		LOG.error("Variable error: %s", string);
		throw e;
	}

}
 
开发者ID:clic-lab,项目名称:spf,代码行数:31,代码来源:Variable.java

示例4: doEquals

import edu.cornell.cs.nlp.spf.mr.lambda.mapping.ScopeMapping; //导入方法依赖的package包/类
@Override
protected boolean doEquals(LogicalExpression exp,
		ScopeMapping<Variable, Variable> mapping) {
	if (this == exp) {
		// Since skolem IDs from this literal may be used in other parts of
		// the logical form, we need to create a mapping of them. As the
		// instances are identical, we can just update the mapping by
		// creating a mapping from each SkolemId to itself.
		if (!freeVariables.isEmpty()) {
			for (final Variable freeVariable : freeVariables) {
				if (freeVariable instanceof SkolemId) {
					mapping.push(freeVariable, freeVariable);
				}
			}
		}
		return true;
	}
	if (getClass() != exp.getClass()) {
		return false;
	}
	final Lambda other = (Lambda) exp;
	if (!type.equals(other.type)) {
		return false;
	}

	if (argument.getType().equals(other.argument.getType())) {
		// If the types are equal and both are not null, add the mapping for
		// the comparison of the body.
		mapping.push(argument, other.argument);
	} else {
		return false;
	}

	final boolean ret = body.equals(other.body, mapping);

	// Remove mapping.
	mapping.pop(argument);

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

示例5: read

import edu.cornell.cs.nlp.spf.mr.lambda.mapping.ScopeMapping; //导入方法依赖的package包/类
@Override
public SkolemId read(String string,
		ScopeMapping<String, LogicalExpression> mapping,
		TypeRepository typeRepository, ITypeComparator typeComparator,
		LogicalExpressionReader reader) {
	if (!mapping.containsKey(string)) {
		mapping.push(string, new SkolemId());
	}
	return (SkolemId) mapping.peek(string);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:11,代码来源:SkolemId.java

示例6: read

import edu.cornell.cs.nlp.spf.mr.lambda.mapping.ScopeMapping; //导入方法依赖的package包/类
@Override
public Lambda read(String string,
		ScopeMapping<String, LogicalExpression> mapping,
		TypeRepository typeRepository, ITypeComparator typeComparator,
		LogicalExpressionReader reader) {

	try {
		final LispReader lispReader = new LispReader(new StringReader(
				string));

		// The first argument is the 'lambda' keyword. We just ignore
		// it.
		lispReader.next();

		// The second argument is the variable definition.
		final Pair<String, Variable> variableDef = Variable
				.readVariableDefintion(lispReader.next(),
						typeRepository);

		if (variableDef == null) {
			throw new LogicalExpressionRuntimeException(
					"Invalid lambda argument: " + string);
		}

		// Update the scope mapping.
		mapping.push(variableDef.first(), variableDef.second());

		// The next argument is the body expression.
		final LogicalExpression lambdaBody = reader.read(
				lispReader.next(), mapping, typeRepository,
				typeComparator);

		// Verify that we don't have any more elements.
		if (lispReader.hasNext()) {
			throw new LogicalExpressionRuntimeException(String.format(
					"Invalid lambda expression: %s", string));
		}

		// Remove the variable from the mapping.
		if (mapping.pop(variableDef.first()) == null) {
			throw new LogicalExpressionRuntimeException(
					"Failed to remove variable from mapping. Something werid is happening: "
							+ string);
		}

		return new Lambda(variableDef.second(), lambdaBody);
	} catch (final RuntimeException e) {
		LOG.error("Lambda syntax error: %s", string);
		throw e;
	}

}
 
开发者ID:clic-lab,项目名称:spf,代码行数:53,代码来源:Lambda.java


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