Package aima.core.logic.fol.parsing.ast

Examples of aima.core.logic.fol.parsing.ast.NotSentence


    }
  }

  @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()));
  }
View Full Code Here


  }

  @Test
  public void testSimpleParanthizedSentence() {
    Sentence ps = parser.parse("(NOT King(John))");
    Assert.assertEquals(ps, new NotSentence(getKingPredicate(new Constant(
        "John"))));
  }
View Full Code Here

  }

  @Test
  public void testExtraParanthizedSentence() {
    Sentence ps = parser.parse("(((NOT King(John))))");
    Assert.assertEquals(ps, new NotSentence(getKingPredicate(new Constant(
        "John"))));
  }
View Full Code Here

  }

  @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())));
  }
View Full Code Here

  @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")),
View Full Code Here

    Sentence ps = parser
        .parse("((King(John) AND NOT King(Richard)) OR King(Saladin))");

    Assert.assertEquals(ps, new ConnectedSentence("OR",
        new ConnectedSentence("AND", getKingPredicate(new Constant(
            "John")), new NotSentence(
            getKingPredicate(new Constant("Richard")))),
        getKingPredicate(new Constant("Saladin"))));
  }
View Full Code Here

      reflexivityClause = KB.standardizeApart(reflexivityClause);
      reflexivityClause.setStandardizedApartCheckNotRequired();
      usable.add(reflexivityClause);
    }

    Sentence notAlpha = new NotSentence(alpha);
    // Want to use an answer literal to pull
    // query variables where necessary
    Literal answerLiteral = KB.createAnswerLiteral(notAlpha);
    Set<Variable> answerLiteralVariables = KB
        .collectAllVariables(answerLiteral.getAtomicSentence());
View Full Code Here

    public AnswerHandler(FOLKnowledgeBase kb, Sentence aQuery,
        long maxQueryTime) {

      finishTime = System.currentTimeMillis() + maxQueryTime;

      Sentence refutationQuery = new NotSentence(aQuery);

      // Want to use an answer literal to pull
      // query variables where necessary
      Literal answerLiteral = kb.createAnswerLiteral(refutationQuery);
      answerLiteralVariables = kb.collectAllVariables(answerLiteral
View Full Code Here

              for (Literal l : newSentences) {
                Sentence s = null;
                if (l.isPositiveLiteral()) {
                  s = l.getAtomicSentence();
                } else {
                  s = new NotSentence(l.getAtomicSentence());
                }
                KB.tell(s);
              }
              ansHandler.setAnswers(KB.fetch(alpha));
              return ansHandler;
            }
          }
        }
      }
      // add new to KB
      for (Literal l : newSentences) {
        Sentence s = null;
        if (l.isPositiveLiteral()) {
          s = l.getAtomicSentence();
        } else {
          s = new NotSentence(l.getAtomicSentence());
        }
        KB.tell(s);
      }
    } while (newSentences.size() > 0);
View Full Code Here

    FOLKnowledgeBase akb = FOLKnowledgeBaseFactory
        .createLovesAnimalKnowledgeBase(infp);
    List<Term> terms = new ArrayList<Term>();
    terms.add(new Constant("Jack"));
    terms.add(new Constant("Tuna"));
    NotSentence query = new NotSentence(new Predicate("Kills", terms));

    InferenceResult answer = akb.ask(query);

    Assert.assertTrue(null != answer);
    if (expectedToTimeOut) {
View Full Code Here

TOP

Related Classes of aima.core.logic.fol.parsing.ast.NotSentence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.