Java Code Examples for edu.cornell.cs.nlp.spf.mr.lambda.LogicalExpression#read()

The following examples show how to use edu.cornell.cs.nlp.spf.mr.lambda.LogicalExpression#read() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeTransformerTest.java    From UDepLambda with Apache License 2.0 6 votes vote down vote up
@Test
public void testReader() {
  final LogicalExpression e1 =
      LogicalExpression
          .read("(lambda $0:e (boo:<e,<<e,t>,t>> $0 (lambda $0:e (goo:<e,t> $0))))");
  final LogicalExpression e2 =
      LogicalExpression
          .read("(lambda $0:e (boo:<e,<<e,t>,t>> $0 (lambda $1:e (goo:<e,t> $1))))");
  Assert.assertTrue(e1.equals(e2));

  final LogicalExpression e3 =
      LogicalExpression
          .read("(lambda $f1:<<e,t>,<e,t>> (exists:<e,<t,t>> $e:e ($f1 cameron:<e,t> $e)))");
  System.out.println(e3);

  LogicalExpression e4 =
      SimpleLogicalExpressionReader
          .read("(lambda $f1:vp (exists:ex $e:z ($f1 cameron:np $e)))");
  System.out.println(e4);
}
 
Example 2
Source File: LogicalExpressionEqualsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test9() {
	final Variable variable = new Variable(LogicLanguageServices
			.getTypeRepository().getEntityType());
	final LogicalExpression e1 = new Lambda(variable, new Lambda(variable,
			new Literal(LogicalConstant.read("pred:<e,<e,t>>"),
					ArrayUtils.create(variable, variable))));
	final LogicalExpression e2 = LogicalExpression
			.read("(lambda $0:e (lambda $1:e (pred:<e,<e,t>> $0 $1)))");
	Assert.assertNotEquals(e2, e1);
	Assert.assertNotEquals(e1, e2);
}
 
Example 3
Source File: HasFreeVariablesTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test() {
	final LogicalExpression exp = LogicalExpression
			.read("(lambda $0:e (pred1:<e,<e,t>> $0 (a:<<e,t>,e> (lambda $1:e (pred2:<e,t> $1)))))");
	Assert.assertFalse(HasFreeVariables.of(exp));
	Assert.assertTrue(HasFreeVariables.of(((Lambda) exp).getBody()));
}
 
Example 4
Source File: LambdaWrappedTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test8() {
	final LogicalExpression variable = LogicalExpression
			.read("$0:<<e,t>,<e,t>>");
	final LogicalExpression wrapped = LambdaWrapped.of(variable);
	final LogicalExpression expected = variable;
	Assert.assertEquals(expected, wrapped);
}
 
Example 5
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test3() {
	final LogicalExpression exp = LogicalExpression
			.read("(intersect:<e,<e,t>> (a:<<e,t>,e> (lambda $0:e (chair:<e,t> $0))) (a:<<e,t>,e> (lambda $1:e (corner:<e,t> $1))))");
	final LogicalExpression result = LogicalExpression
			.read("(exists:<<e,t>,t> (lambda $0:e (and:<t*,t> (exists:<<e,t>,t> (lambda $1:e (and:<t*,t> (intersect:<e,<e,t>> $0 $1) (corner:<e,t> $1)))) (chair:<e,t> $0))))");
	final LogicalExpression out = AToExists.of(exp, existsPredicate,
			aPredicate, equalsPredicates);
	Assert.assertEquals(result, out);
}
 
Example 6
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test8() {
	final LogicalExpression exp = LogicalExpression
			.read("(fun:<e,e> (a:<<e,t>,e> (lambda $0:e (pred:<e,t> $0))))");
	final LogicalExpression result = LogicalExpression
			.read("(lambda $1:e (exists:<<e,t>,t> (lambda $0:e (and:<t*,t> (pred:<e,t> $0) (eq:<e,<e,t>> $1 (fun:<e,e> $0)))))))");
	final LogicalExpression out = AToExists.of(exp, existsPredicate,
			aPredicate, equalsPredicates);
	Assert.assertEquals(Simplify.of(result), out);
}
 
Example 7
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test() {
	final LogicalExpression exp = LogicalExpression
			.read("(lambda $0:e (pred1:<e,<e,t>> $0 (a:<<e,t>,e> (lambda $1:e (pred2:<e,t> $1)))))");
	final LogicalExpression result = LogicalExpression
			.read("(lambda $0:e (exists:<<e,t>,t> (lambda $1:e (and:<t*,t> (pred1:<e,<e,t>> $0 $1) (pred2:<e,t> $1)))))");
	final LogicalExpression out = AToExists.of(exp, existsPredicate,
			aPredicate, equalsPredicates);
	Assert.assertEquals(result, out);
}
 
Example 8
Source File: LambdaWrappedTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test4() {
	final LogicalExpression wrapped = LambdaWrapped.of(LogicalExpression
			.read("(lambda $0:<e,t> $0)"));
	final LogicalExpression expected = LogicalExpression
			.read("(lambda $0:<e,t> $0)");
	Assert.assertEquals(expected, wrapped);
}
 
Example 9
Source File: ApplyAndSimplifyTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@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));
}
 
Example 10
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test2() {
	final LogicalExpression exp = LogicalExpression
			.read("(lambda $0:e (to:<e,<e,t>> $0 (a:<<e,t>,e> (lambda $1:e (and:<t*,t> (chair:<e,t> $1) (intersect:<e,<e,t>> $1 (a:<<e,t>,e> (lambda $2:e (corner:<e,t> $2)))))))))");
	final LogicalExpression result = LogicalExpression
			.read("(lambda $0:e (exists:<<e,t>,t> (lambda $1:e (and:<t*,t> (to:<e,<e,t>> $0 $1) (chair:<e,t> $1) (exists:<<e,t>,t> (lambda $2:e (and:<t*,t> (intersect:<e,<e,t>> $1 $2) (corner:<e,t> $2))))))))");
	final LogicalExpression out = AToExists.of(exp, existsPredicate,
			aPredicate, equalsPredicates);
	Assert.assertEquals(result, out);
}
 
Example 11
Source File: ApplyAndSimplifyTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test9() {
	final LogicalExpression exp = LogicalExpression
			.read("(lambda $0:e (a:<<e,t>,e> (lambda $1:e (boo:<e,<e,t>> $1 $0))))");
	final LogicalExpression result = LogicalExpression
			.read("(lambda $0:e (exists:<<e,t>,t> (lambda $1:e (boo:<e,<e,t>> $1 $0))))");
	final LogicalExpression out = AToExists.of(exp, existsPredicate,
			aPredicate, equalsPredicates);
	Assert.assertEquals(Simplify.of(result), out);
}
 
Example 13
Source File: LogicalExpressionEqualsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test6() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:e (and:<t*,t> (boo:<e,t> $1:e) (foo:<e,t> $1)))");
	final LogicalExpression e2 = LogicalExpression
			.read("(lambda $0:e (and:<t*,t> (boo:<e,t> $1:e) (foo:<e,t> $0)))");
	Assert.assertFalse(e1.equals(e2));
}
 
Example 14
Source File: ApplyAndSimplifyTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@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));
}
 
Example 15
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test7() {
	final LogicalExpression exp = LogicalExpression
			.read("(fun:<e,e> (a:<<e,t>,e> (lambda $0:e true:t)))");
	final LogicalExpression result = LogicalExpression
			.read("(lambda $0:e (exists:<<e,t>,t> (lambda $1:e (and:<t*,t> true:t (eq:<e,<e,t>> $0 (fun:<e,e> $1))))))");
	final LogicalExpression out = AToExists.of(exp, existsPredicate,
			aPredicate, equalsPredicates);
	Assert.assertEquals(Simplify.of(result), out);
}
 
Example 16
Source File: ApplyAndSimplifyTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@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));
}
 
Example 17
Source File: LogicalExpressionEqualsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test() {
	final LogicalExpression e1 = LogicalExpression
			.read("(lambda $0:e (boo:<e,t> $0))");
	final LogicalExpression e2 = LogicalExpression
			.read("(lambda $0:e (boo:<e,t> $0))");
	Assert.assertTrue(e1.equals(e2));
}
 
Example 18
Source File: AToExistsTest.java    From spf with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test4() {
	final LogicalExpression exp = LogicalExpression
			.read("(a:<<e,t>,e> (lambda $0:e (and:<t*,t> (blue:<e,t> $0) (hall:<e,t> $0))))");
	final LogicalExpression result = LogicalExpression
			.read("(exists:<<e,t>,t> (lambda $0:e (and:<t*,t> (blue:<e,t> $0) (hall:<e,t> $0))))");
	final LogicalExpression out = AToExists.of(exp, existsPredicate,
			aPredicate, equalsPredicates);
	Assert.assertEquals(result, out);
}
 
Example 19
Source File: SerializationTest.java    From spf with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test8() {
	final LogicalExpression exp = LogicalExpression
			.read("(fun:<e,e> (a:<<e,t>,e> (lambda $0:e (pred:<e,t> $0))))");
	doTest(exp);
}
 
Example 20
Source File: SerializationTest.java    From spf with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test9() {
	final LogicalExpression exp = LogicalExpression
			.read("(lambda $0:e (a:<<e,t>,e> (lambda $1:e (boo:<e,<e,t>> $1 $0))))");
	doTest(exp);
}