コード例 #1
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()));
 }
コード例 #2
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"))));
 }
コード例 #3
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())));
 }
コード例 #4
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");
   }
 }
コード例 #5
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"))));
  }
コード例 #6
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));
 }
コード例 #7
0
 @Test
 public void testPredicate() {
   // parser.setUpToParse("King(John)");
   Predicate p = (Predicate) parser.parse("King(John)");
   Assert.assertEquals(p, getKingPredicate(new Constant("John")));
 }
コード例 #8
0
 @Test
 public void testConnectedImplication() {
   parser = new FOLParser(DomainFactory.weaponsDomain());
   parser.parse("((Missile(m) AND Owns(Nono,m)) => Sells(West , m ,Nono))");
 }
コード例 #9
0
 @Test
 public void testExtraParanthizedSentence() {
   Sentence ps = parser.parse("(((NOT King(John))))");
   Assert.assertEquals(ps, new NotSentence(getKingPredicate(new Constant("John"))));
 }