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

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


    return sentence;
  }

  public Object visitConnectedSentence(ConnectedSentence sentence, Object arg) {
    ArgData ad = (ArgData) arg;
    Sentence first = sentence.getFirst();
    Sentence second = sentence.getSecond();

    first.accept(this, arg);
    if (Connectors.isAND(sentence.getConnector())) {
      ad.clauses.add(new Clause());
    }
    second.accept(this, arg);

    return sentence;
  }
View Full Code Here


      renameSubstitution.put(var, v);
      reverseSubstitution.put(v, var);
    }

    Sentence standardized = substVisitor.subst(renameSubstitution,
        sentence);

    return new StandardizeApartResult(sentence, standardized,
        renameSubstitution, reverseSubstitution);
  }
View Full Code Here

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

      finishTime = System.currentTimeMillis() + maxQueryTime;

      Sentence refutationQuery = new NotSentence(query);

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

      // Create the Set of Support based on the Query.
      if (answerLiteralVariables.size() > 0) {
        Sentence refutationQueryWithAnswer = new ConnectedSentence(
            Connectors.OR, refutationQuery, answerLiteral
                .getAtomicSentence().copy());

        sos = createChainsFromClauses(kb
            .convertToClauses(refutationQueryWithAnswer));
View Full Code Here

            theta = KB.unify(qDelta.getAtomicSentence(),
                alpha.getAtomicSentence());
            // if theta is not fail then return theta
            if (null != theta) {
              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());
        }
View Full Code Here

      terms.add(ithExampleConstant);
      // If multivalued becomes a two place predicate
      // e.g: Patrons(X1, Some)
      // otherwise: Hungry(X1) or ~ Hungry(X1)
      // see pg 769 of AIMA
      Sentence part = null;
      if (folDSDomain.isMultivalued(dname)) {
        terms.add(new Constant(folDSDomain.getFOLName(example
            .getAttributeValueAsString(dname))));
        part = new Predicate(foldDName, terms);
      } else {
View Full Code Here

        getEnemyOfFunction()));
  }

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

        "John"))));
  }

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

        "John"))));
  }

  @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

        getEnemyOfFunction())));
  }

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

        getKingPredicate(new Constant("Saladin"))));
  }

  @Test
  public void testComplexConnectedSentence1() {
    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(
View Full Code Here

TOP

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

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.