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


Java ApplyAndSimplify.of方法代码示例

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


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

示例1: apply

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Override
public LogicalExpression apply(LogicalExpression function,
		LogicalExpression argument) {
	final LogicalExpression result;

	// Combined application and simplification
	final LogicalExpression applicationResult = ApplyAndSimplify.of(
			function, argument);
	// Verify application result is well typed, only if verification is
	// turned on
	if (applicationResult != null && doTypeChecking
			&& !IsTypeConsistent.of(applicationResult)) {
		result = null;
	} else {
		result = applicationResult;
	}

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

示例2: bindOperation

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
private static LogicalExpression bindOperation(
    LogicalExpression leftTreeParse, LogicalExpression rightTreeParse) {
  Preconditions.checkNotNull(leftTreeParse);
  Preconditions.checkNotNull(rightTreeParse);
  Preconditions.checkArgument(rightTreeParse instanceof LogicalConstant);

  // Dirty implementation. A better way is to work with objects and not the
  // strings.
  Type leftType = leftTreeParse.getType();
  String existsExpression =
      String.format("(lambda $f:%s (exists:<%s,<%s,%s>> $x:%s ($f $x))",
          leftType, leftType.getDomain(), leftType.getRange(),
          leftType.getRange(), leftType.getDomain());
  leftTreeParse =
      ApplyAndSimplify
          .of(SimpleLogicalExpressionReader.read(existsExpression),
              leftTreeParse);

  String variable = rightTreeParse.toString();
  String leftParse = leftTreeParse.toString();
  String variableType = rightTreeParse.getType().getDomain().toString();
  String returnType = rightTreeParse.getType().getRange().toString();
  Pattern variablePattern =
      Pattern.compile(String.format("([\\(\\)\\s])(%s)([\\(\\)\\s])",
          variable));
  Matcher matcher = variablePattern.matcher(leftParse);

  String finalString =
      matcher
          .replaceAll(String.format("$1%s:<%s,<%s,%s>> \\$x$3",
              PredicateKeys.EQUAL_PREFIX, variableType, variableType,
              returnType));
  finalString = String.format("(lambda $x:%s %s)", variableType, finalString);
  return SimpleLogicalExpressionReader.read(finalString);
}
 
开发者ID:sivareddyg,项目名称:UDepLambda,代码行数:36,代码来源:TreeTransformer.java

示例3: test1

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test1() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:<e,t> (lambda $1:e (and:<t*,t> (boo:<e,t> $1) ($0 $1))))");
	final LogicalExpression a1 = LogicalExpression.read("doo:<e,t>");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(lambda $0:e (and:<t*,t> (boo:<e,t> $0) (doo:<e,t> $0)))");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:12,代码来源:ApplyAndSimplifyTest.java

示例4: test10

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test10() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:t (or:<t*,t> (boo:<e,t> foo:e) $0))");
	final LogicalExpression a1 = LogicalExpression
			.read("(or:<t*,t> (goo:<e,t> foo:e) (koo:<e,t> foo:e))");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(or:<t*,t> (goo:<e,t> foo:e) (koo:<e,t> foo:e) (boo:<e,t> foo:e))");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:13,代码来源:ApplyAndSimplifyTest.java

示例5: test11

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test11() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:t (or:<t*,t> (boo:<e,t> foo:e) $0))");
	final LogicalExpression a1 = LogicalExpression
			.read("(and:<t*,t> (goo:<e,t> foo:e) (koo:<e,t> foo:e))");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(or:<t*,t> (and:<t*,t> (goo:<e,t> foo:e) (koo:<e,t> foo:e)) (boo:<e,t> foo:e))");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:13,代码来源:ApplyAndSimplifyTest.java

示例6: test2

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test2() {
	final LogicalExpression e1 = LogicalExpression.read("goo:<<e,t>,t>");
	final LogicalExpression a1 = LogicalExpression.read("doo:<e,t>");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(goo:<<e,t>,t> doo:<e,t>)");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:11,代码来源:ApplyAndSimplifyTest.java

示例7: test3

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test3() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:e (lambda $1:e (boo:<e,<e,t>> $0 $1)))");
	final LogicalExpression a1 = LogicalExpression.read("goo:e");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(lambda $0:e (boo:<e,<e,t>> goo:e $0))");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:12,代码来源:ApplyAndSimplifyTest.java

示例8: test4

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test4() {
	final LogicalExpression e1 = LogicalExpression
			.read("(boo:<e,<e,t>> go:e)");
	final LogicalExpression a1 = LogicalExpression.read("bo:e");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(boo:<e,<e,t>> go:e bo:e)");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:12,代码来源:ApplyAndSimplifyTest.java

示例9: test5

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test5() {
	final LogicalExpression e1 = LogicalExpression
			.read("(and:<t*,t> go:t)");
	final LogicalExpression a1 = LogicalExpression.read("do:t");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(and:<t*,t> go:t do:t)");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:12,代码来源:ApplyAndSimplifyTest.java

示例10: test6

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test6() {
	final LogicalExpression e1 = LogicalExpression
			.read("(and:<t*,t> go:t do:t)");
	final LogicalExpression a1 = LogicalExpression.read("lo:t");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	assertTrue(String.format("%s != %s", r1, null), r1 == null);
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:9,代码来源:ApplyAndSimplifyTest.java

示例11: test7

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test7() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:<e,<e,e>> ($0 "
					+ "(do_until:<e,<t,e>> (do:<e,e> turn:e) (notempty:<<e,t>,t> (intersect:<<e,t>*,<e,t>> chair:<e,t> (front:<<e,t>,<e,t>> at:<e,t>)))) "
					+ "(do_until:<e,<t,e>> (do:<e,e> travel:e) (notempty:<<e,t>,t> (intersect:<<e,t>*,<e,t>> chair:<e,t> at:<e,t>)))))");
	final LogicalExpression a1 = LogicalExpression.read("do_seq:<e+,e>");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected = LogicalExpression
			.read("(do_seq:<e+,e> (do_until:<e,<t,e>> (do:<e,e> turn:e) (notempty:<<e,t>,t> (intersect:<<e,t>*,<e,t>> chair:<e,t> (front:<<e,t>,<e,t>> at:<e,t>)))) (do_until:<e,<t,e>> (do:<e,e> travel:e) (notempty:<<e,t>,t> (intersect:<<e,t>*,<e,t>> chair:<e,t> at:<e,t>))))");
	assertTrue(String.format("%s != %s", r1, expected), r1.equals(expected));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:13,代码来源:ApplyAndSimplifyTest.java

示例12: test8

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test8() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:e (and:<t*,t> (p:<e,t> $0) (q:<e,t> $0)))");
	final LogicalExpression a1 = LogicalExpression
			.read("(a:<<e,t>,e> (lambda $0:e (r:<e,t> $0)))");
	final LogicalExpression expected = LogicalExpression
			.read("(and:<t*,t> (p:<e,t> (a:<<e,t>,e> (lambda $0:e (r:<e,t> $0)))) (q:<e,t> (a:<<e,t>,e> (lambda $1:e (r:<e,t> $1)))))");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	assertTrue(String.format("%s != %s", r1, expected), r1.equals(expected));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:12,代码来源:ApplyAndSimplifyTest.java

示例13: test9

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
@Test
public void test9() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:t (and:<t*,t> (boo:<e,t> foo:e) $0))");
	final LogicalExpression a1 = LogicalExpression
			.read("(and:<t*,t> (goo:<e,t> foo:e) (koo:<e,t> foo:e))");
	final LogicalExpression r1 = ApplyAndSimplify.of(e1, a1);
	final LogicalExpression expected1 = LogicalExpression
			.read("(and:<t*,t> (goo:<e,t> foo:e) (koo:<e,t> foo:e) (boo:<e,t> foo:e))");
	assertTrue(String.format("%s != %s", r1, expected1),
			expected1.equals(r1));
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:13,代码来源:ApplyAndSimplifyTest.java

示例14: of

import edu.cornell.cs.nlp.spf.mr.lambda.visitor.ApplyAndSimplify; //导入方法依赖的package包/类
public static LogicalExpression of(LogicalExpression semantics) {
	final Type etType = LogicLanguageServices.getTypeRepository()
			.getTypeCreateIfNeeded(
					LogicLanguageServices.getTypeRepository()
							.getTruthValueType(),
					LogicLanguageServices.getTypeRepository()
							.getEntityType());
	final Type eType = LogicLanguageServices.getTypeRepository()
			.getEntityType();

	LogicalExpression stripped = semantics;
	while (!(stripped.getType().equals(etType)
			|| stripped.getType().equals(eType))
			&& stripped instanceof Lambda) {
		final Variable variable = ((Lambda) stripped).getArgument();
		if (variable.getType().isComplex() && variable.getType().getRange()
				.equals(variable.getType().getDomain())) {
			final Variable argVariable = new Variable(
					variable.getType().getDomain());
			stripped = ApplyAndSimplify.of(stripped,
					new Lambda(argVariable, argVariable));
		} else {
			stripped = ((Lambda) stripped).getBody();
		}
	}

	final SloppyAmrClosure visitor = new SloppyAmrClosure();
	visitor.visit(stripped);

	final LogicalExpression resultSemantics;
	if (visitor.result == null) {
		LOG.info(() -> {
			if (GetConstantsSet.of(semantics)
					.stream().filter(c -> AMRServices
							.getTypingPredicateType().equals(c.getType()))
					.count() != 0) {
				// This is fairly rare.
				LOG.debug(
						"Failed to close to AMR, but there are instance predicates: %s",
						semantics);
			}
		});
		return null;
	} else if (visitor.result.getType().equals(eType)) {
		resultSemantics = visitor.result;
	} else if (visitor.result.getType().equals(etType)) {
		resultSemantics = AMRServices.skolemize(visitor.result);
	} else {
		// Mostly (or even only) happens in the case of a coordination that
		// is not finalized.
		LOG.info("Unexpected return type from closing to AMR: %s -> %s",
				semantics, visitor.result);
		return null;
	}

	// TODO Fix to avoid this, pretty common (~900)
	if (IsValidAmr.of(resultSemantics, false, true)
			&& AMRServices.isSkolemTerm(resultSemantics)) {
		return resultSemantics;
	} else {
		LOG.info("Result of closing to AMR is invalid: %s -> %s", semantics,
				resultSemantics);
		return null;
	}
}
 
开发者ID:clic-lab,项目名称:amr,代码行数:66,代码来源:SloppyAmrClosure.java


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