コード例 #1
0
 @Test
 public void testParseMultiArityFunction() {
   parser.setUpToParse("LegsOf(John,Saladin,Richard)");
   Term f = parser.parseFunction();
   Assert.assertEquals(f, getLegsOfFunction());
   Assert.assertEquals(3, ((Function) f).getTerms().size());
 }
コード例 #2
0
 @Test
 public void testNotSentence() {
   NotSentence ns = (NotSentence) parser.parse("NOT BrotherOf(John) = EnemyOf(Saladin)");
   Assert.assertEquals(
       ns.getNegated(),
       new TermEquality(getBrotherOfFunction(new Constant("John")), getEnemyOfFunction()));
 }
コード例 #3
0
 @Test
 public void testQuantifiedSentenceWithSingleVariable() {
   Sentence qs = parser.parse("FORALL x  King(x)");
   List<Variable> vars = new ArrayList<Variable>();
   vars.add(new Variable("x"));
   Assert.assertEquals(
       qs, new QuantifiedSentence("FORALL", vars, getKingPredicate(new Variable("x"))));
 }
コード例 #4
0
 @Test
 public void testParseComplexParanthizedSentence() {
   Sentence ps = parser.parse("(NOT BrotherOf(John) = EnemyOf(Saladin))");
   Assert.assertEquals(
       ps,
       new NotSentence(
           new TermEquality(getBrotherOfFunction(new Constant("John")), getEnemyOfFunction())));
 }
コード例 #5
0
 @Test
 public void testTermEquality2() {
   try {
     TermEquality te = (TermEquality) parser.parse("BrotherOf(John) = x)");
     Assert.assertEquals(
         te, new TermEquality(getBrotherOfFunction(new Constant("John")), new Variable("x")));
   } catch (RuntimeException e) {
     Assert.fail("RuntimeException thrown");
   }
 }
コード例 #6
0
  @Test
  public void testParseSimpleConnectedSentence() {
    Sentence ps = parser.parse("(King(John) AND NOT King(Richard))");

    Assert.assertEquals(
        ps,
        new ConnectedSentence(
            "AND",
            getKingPredicate(new Constant("John")),
            new NotSentence(getKingPredicate(new Constant("Richard")))));

    ps = parser.parse("(King(John) AND King(Saladin))");
    Assert.assertEquals(
        ps,
        new ConnectedSentence(
            "AND",
            getKingPredicate(new Constant("John")),
            getKingPredicate(new Constant("Saladin"))));
  }
コード例 #7
0
 @Test
 public void testQuantifiedSentenceWithPathologicalParanthising() {
   Sentence qs = parser.parse("(( (EXISTS x,y  (King(x) AND (BrotherOf(x) = y)) ) ))");
   List<Variable> vars = new ArrayList<Variable>();
   vars.add(new Variable("x"));
   vars.add(new Variable("y"));
   ConnectedSentence cse =
       new ConnectedSentence(
           "AND",
           getKingPredicate(new Variable("x")),
           new TermEquality(getBrotherOfFunction(new Variable("x")), new Variable("y")));
   Assert.assertEquals(qs, new QuantifiedSentence("EXISTS", vars, cse));
 }
コード例 #8
0
 @Test
 public void testPredicate() {
   // parser.setUpToParse("King(John)");
   Predicate p = (Predicate) parser.parse("King(John)");
   Assert.assertEquals(p, getKingPredicate(new Constant("John")));
 }
コード例 #9
0
 @Test
 public void testParseFunction() {
   parser.setUpToParse("BrotherOf(John)");
   Term f = parser.parseFunction();
   Assert.assertEquals(f, getBrotherOfFunction(new Constant("John")));
 }
コード例 #10
0
 @Test
 public void testParseSimpleConstant() {
   parser.setUpToParse("John");
   Term c = parser.parseConstant();
   Assert.assertEquals(c, new Constant("John"));
 }
コード例 #11
0
 @Test(expected = RuntimeException.class)
 public void testNotAllowedParseLeadingIndexedVariable() {
   parser.setUpToParse("1x");
   parser.parseVariable();
 }
コード例 #12
0
 @Test
 public void testParseIndexedVariable() {
   parser.setUpToParse("x1");
   Term v = parser.parseVariable();
   Assert.assertEquals(v, new Variable("x1"));
 }
コード例 #13
0
 @Test
 public void testConnectedImplication() {
   parser = new FOLParser(DomainFactory.weaponsDomain());
   parser.parse("((Missile(m) AND Owns(Nono,m)) => Sells(West , m ,Nono))");
 }
コード例 #14
0
 @Test
 public void testExtraParanthizedSentence() {
   Sentence ps = parser.parse("(((NOT King(John))))");
   Assert.assertEquals(ps, new NotSentence(getKingPredicate(new Constant("John"))));
 }