001 /* 002 * Created on Dec 4, 2004 003 * 004 */ 005 package aima.logic.propositional.visitors; 006 007 import java.util.Set; 008 009 import aima.logic.propositional.parsing.ast.Sentence; 010 import aima.logic.propositional.parsing.ast.Symbol; 011 import aima.util.SetOps; 012 013 /** 014 * @author Ravi Mohan 015 * 016 */ 017 018 public class SymbolClassifier { 019 020 public Set<Symbol> getPositiveSymbolsIn(Sentence sentence) { 021 return new PositiveSymbolCollector().getPositiveSymbolsIn(sentence); 022 } 023 024 public Set<Symbol> getNegativeSymbolsIn(Sentence sentence) { 025 return new NegativeSymbolCollector().getNegativeSymbolsIn(sentence); 026 } 027 028 public Set<Symbol> getPureNegativeSymbolsIn(Sentence sentence) { 029 Set<Symbol> allNegatives = getNegativeSymbolsIn(sentence); 030 Set<Symbol> allPositives = getPositiveSymbolsIn(sentence); 031 return new SetOps<Symbol>().difference(allNegatives, allPositives); 032 } 033 034 public Set<Symbol> getPurePositiveSymbolsIn(Sentence sentence) { 035 Set<Symbol> allNegatives = getNegativeSymbolsIn(sentence); 036 Set<Symbol> allPositives = getPositiveSymbolsIn(sentence); 037 return new SetOps<Symbol>().difference(allPositives, allNegatives); 038 } 039 040 public Set<Symbol> getPureSymbolsIn(Sentence sentence) { 041 Set<Symbol> allPureNegatives = getPureNegativeSymbolsIn(sentence); 042 Set<Symbol> allPurePositives = getPurePositiveSymbolsIn(sentence); 043 return new SetOps<Symbol>().union(allPurePositives, allPureNegatives); 044 } 045 046 public Set<Symbol> getImpureSymbolsIn(Sentence sentence) { 047 Set<Symbol> allNegatives = getNegativeSymbolsIn(sentence); 048 Set<Symbol> allPositives = getPositiveSymbolsIn(sentence); 049 return new SetOps<Symbol>().intersection(allPositives, allNegatives); 050 } 051 052 public Set<Symbol> getSymbolsIn(Sentence sentence) { 053 return new SymbolCollector().getSymbolsIn(sentence); 054 } 055 056 }