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

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


              new ArrayList<Term>(universalScope)));
        } else {
          // Replace with a Skolem Constant
          String skolemConstantName = parser.getFOLDomain()
              .addSkolemConstant();
          skolemSubst.put(eVar, new Constant(skolemConstantName));
        }
      }

      Sentence skolemized = substVisitor.subst(skolemSubst, quantified);
      return skolemized.accept(this, arg);
View Full Code Here


  //
  // PRIVATE METHODS
  //
  private void constructFOLEg() {
    ithExampleConstant = new Constant(folDSDomain.getExampleConstant(egNo));

    List<Term> terms = new ArrayList<Term>();
    terms.add(ithExampleConstant);
    // Create the classification sentence
    classification = new Predicate(folDSDomain.getGoalPredicateName(),
        terms);
    if (!example.getAttributeValueAsString(
        folDSDomain.getDataSetTargetName()).equals(
        folDSDomain.getTrueGoalValue())) {
      // if not true then needs to be a Not sentence
      classification = new NotSentence(classification);
    }

    // Create the description sentence
    List<Sentence> descParts = new ArrayList<Sentence>();
    for (String dname : folDSDomain.getDescriptionDataSetNames()) {
      String foldDName = folDSDomain.getFOLName(dname);
      terms = new ArrayList<Term>();
      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 {
        part = new Predicate(foldDName, terms);
        // Need to determine if false
View Full Code Here

  @Test
  public void testParseSimpleConstant() {
    parser.setUpToParse("John");
    Term c = parser.parseConstant();
    Assert.assertEquals(c, new Constant("John"));
  }
View Full Code Here

  @Test
  public void testParseFunction() {
    parser.setUpToParse("BrotherOf(John)");
    Term f = parser.parseFunction();
    Assert.assertEquals(f, getBrotherOfFunction(new Constant("John")));
  }
View Full Code Here

  @Test
  public void testPredicate() {
    // parser.setUpToParse("King(John)");
    Predicate p = (Predicate) parser.parse("King(John)");
    Assert.assertEquals(p, getKingPredicate(new Constant("John")));
  }
View Full Code Here

  public void testTermEquality() {
    try {
      TermEquality te = (TermEquality) parser
          .parse("BrotherOf(John) = EnemyOf(Saladin)");
      Assert.assertEquals(te, new TermEquality(
          getBrotherOfFunction(new Constant("John")),
          getEnemyOfFunction()));
    } catch (RuntimeException e) {
      Assert.fail("RuntimeException thrown");
    }
  }
View Full Code Here

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

  @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

TOP

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

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.