Package aima.core.logic.propositional.parsing.ast

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


  }

  @Test
  public void testSimpleNegativeSymbol() {
    Sentence sentence = (Sentence) parser.parse("(NOT B)");

    Set<Symbol> neg = classifier.getNegativeSymbolsIn(sentence);
    Set<Symbol> pos = classifier.getPositiveSymbolsIn(sentence);

    Set<Symbol> pureNeg = classifier.getPureNegativeSymbolsIn(sentence);
    Set<Symbol> purePos = classifier.getPurePositiveSymbolsIn(sentence);

    Set<Symbol> pure = classifier.getPureSymbolsIn(sentence);
    Set<Symbol> impure = classifier.getImpureSymbolsIn(sentence);

    Sentence b = (Sentence) parser.parse("B");

    Assert.assertEquals(1, neg.size());
    Assert.assertTrue(neg.contains(b));

    Assert.assertEquals(0, pos.size());
View Full Code Here


    Assert.assertEquals(0, impure.size());
  }

  @Test
  public void testSimplePositiveSymbol() {
    Sentence sentence = (Sentence) parser.parse("B");
    Set<Symbol> neg = classifier.getNegativeSymbolsIn(sentence);
    Set<Symbol> pos = classifier.getPositiveSymbolsIn(sentence);

    Set<Symbol> pureNeg = classifier.getPureNegativeSymbolsIn(sentence);
    Set<Symbol> purePos = classifier.getPurePositiveSymbolsIn(sentence);

    Set<Symbol> pure = classifier.getPureSymbolsIn(sentence);
    Set<Symbol> impure = classifier.getImpureSymbolsIn(sentence);

    Assert.assertEquals(0, neg.size());

    Assert.assertEquals(1, pos.size());
    Sentence b = (Sentence) parser.parse("B");
    Assert.assertTrue(pos.contains(b));

    Assert.assertEquals(1, purePos.size());
    Assert.assertTrue(purePos.contains(b));
View Full Code Here

    Assert.assertEquals(0, impure.size());
  }

  @Test
  public void testSingleSymbolPositiveAndNegative() {
    Sentence sentence = (Sentence) parser.parse("(B AND (NOT B))");
    Set<Symbol> neg = classifier.getNegativeSymbolsIn(sentence);
    Set<Symbol> pos = classifier.getPositiveSymbolsIn(sentence);

    Set<Symbol> pureNeg = classifier.getPureNegativeSymbolsIn(sentence);
    Set<Symbol> purePos = classifier.getPurePositiveSymbolsIn(sentence);

    Set<Symbol> pure = classifier.getPureSymbolsIn(sentence);
    Set<Symbol> impure = classifier.getImpureSymbolsIn(sentence);

    Sentence b = (Sentence) parser.parse("B");

    Assert.assertEquals(1, neg.size());
    Assert.assertTrue(neg.contains(b));

    Assert.assertEquals(1, pos.size());
View Full Code Here

  }

  @Test
  public void testAIMA2eExample() {
    // 2nd Edition Pg 221
    Sentence sentence = (Sentence) parser
        .parse("(((A OR (NOT B)) AND ((NOT B) OR (NOT C))) AND (C OR A))");

    Set<Symbol> neg = classifier.getNegativeSymbolsIn(sentence);
    Set<Symbol> pos = classifier.getPositiveSymbolsIn(sentence);

    Set<Symbol> pureNeg = classifier.getPureNegativeSymbolsIn(sentence);
    Set<Symbol> purePos = classifier.getPurePositiveSymbolsIn(sentence);

    Set<Symbol> pure = classifier.getPureSymbolsIn(sentence);
    Set<Symbol> impure = classifier.getImpureSymbolsIn(sentence);

    Sentence a = (Sentence) parser.parse("A");
    Sentence b = (Sentence) parser.parse("B");
    Sentence c = (Sentence) parser.parse("C");

    Assert.assertEquals(2, neg.size());
    Assert.assertTrue(neg.contains(b));
    Assert.assertTrue(neg.contains(c));
View Full Code Here

    transformer = new CNFTransformer();
  }

  @Test
  public void testSymbolTransform() {
    Sentence symbol = (Sentence) parser.parse("A");
    Sentence transformed = transformer.transform(symbol);
    Assert.assertEquals("A", transformed.toString());
  }
View Full Code Here

    Assert.assertEquals("A", transformed.toString());
  }

  @Test
  public void testBasicSentenceTransformation() {
    Sentence and = (Sentence) parser.parse("(A AND B)");
    Sentence transformedAnd = transformer.transform(and);
    Assert.assertEquals(and.toString(), transformedAnd.toString());

    Sentence or = (Sentence) parser.parse("(A OR B)");
    Sentence transformedOr = transformer.transform(or);
    Assert.assertEquals(or.toString(), transformedOr.toString());

    Sentence not = (Sentence) parser.parse("(NOT C)");
    Sentence transformedNot = transformer.transform(not);
    Assert.assertEquals(not.toString(), transformedNot.toString());
  }
View Full Code Here

    Assert.assertEquals(not.toString(), transformedNot.toString());
  }

  @Test
  public void testImplicationTransformation() {
    Sentence impl = (Sentence) parser.parse("(A => B)");
    Sentence expected = (Sentence) parser.parse("((NOT A) OR B)");
    Sentence transformedImpl = transformer.transform(impl);
    Assert.assertEquals(expected.toString(), transformedImpl.toString());
  }
View Full Code Here

    Assert.assertEquals(expected.toString(), transformedImpl.toString());
  }

  @Test
  public void testBiConditionalTransformation() {
    Sentence bic = (Sentence) parser.parse("(A <=> B)");
    Sentence expected = (Sentence) parser
        .parse("(((NOT A) OR B)  AND ((NOT B) OR A)) ");
    Sentence transformedBic = transformer.transform(bic);
    Assert.assertEquals(expected.toString(), transformedBic.toString());
  }
View Full Code Here

    Assert.assertEquals(expected.toString(), transformedBic.toString());
  }

  @Test
  public void testTwoSuccessiveNotsTransformation() {
    Sentence twoNots = (Sentence) parser.parse("(NOT (NOT A))");
    Sentence expected = (Sentence) parser.parse("A");
    Sentence transformed = transformer.transform(twoNots);
    Assert.assertEquals(expected.toString(), transformed.toString());
  }
View Full Code Here

    Assert.assertEquals(expected.toString(), transformed.toString());
  }

  @Test
  public void testThreeSuccessiveNotsTransformation() {
    Sentence threeNots = (Sentence) parser.parse("(NOT (NOT (NOT A)))");
    Sentence expected = (Sentence) parser.parse("(NOT A)");
    Sentence transformed = transformer.transform(threeNots);
    Assert.assertEquals(expected.toString(), transformed.toString());
  }
View Full Code Here

TOP

Related Classes of aima.core.logic.propositional.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.