|
From: Elmer G. <ega...@us...> - 2004-10-19 06:55:57
|
Update of /cvsroot/javaowl/Reasoner/src/org/javaowl/reasoner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7903/src/org/javaowl/reasoner Modified Files: AtomicConcept.java Added Files: ConjunctionConcept.java DisjunctionConcept.java NegatedConcept.java Removed Files: AbstractConcept.java Log Message: Added Negation Conjunction and Disjunction Concepts. --- NEW FILE: ConjunctionConcept.java --- /* ConjunctionConcept.java Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer Garduno Hernandez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.javaowl.reasoner; import java.util.Set; import java.util.HashSet; public class ConjunctionConcept implements Concept{ private Set concepts = new HashSet(); private boolean atomic = false; private boolean bottom = false; private ConjunctionConcept() { } public final static ConjunctionConcept getConcept() { return new ConjunctionConcept(); } public boolean isAtomic() { return atomic; } public boolean isNegated() { return false; } public boolean isTop() { return false; } public boolean isBottom() { return bottom; } public void addConcept(Concept concept) { if (concept.isTop()) { return; } if (concept.isBottom()) { bottom = true; atomic = true; } if (concepts.contains(NegatedConcept.getConcept(concept))) { bottom = true; atomic = true; } concepts.add(concept); } public boolean equals(Object o) { if (bottom) return AtomicConcept.BOTTOM.equals(o); if (! (o instanceof ConjunctionConcept)) return false; ConjunctionConcept cc = (ConjunctionConcept) o; return concepts.equals(cc.concepts); } public int hashCode() { if (bottom) return AtomicConcept.BOTTOM.hashCode(); int result = 17; result = 37 * result + concepts.hashCode(); return result; } } --- AbstractConcept.java DELETED --- --- NEW FILE: DisjunctionConcept.java --- /* DisjunctionConcept.java Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer Garduno Hernandez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.javaowl.reasoner; import java.util.Set; import java.util.HashSet; public class DisjunctionConcept implements Concept{ private Set concepts = new HashSet(); private boolean atomic = false; private boolean top = false; private DisjunctionConcept() { } public final static DisjunctionConcept getConcept() { return new DisjunctionConcept(); } public boolean isAtomic() { return atomic; } public boolean isNegated() { return false; } public boolean isTop() { return top; } public boolean isBottom() { return false; } public void addConcept(Concept concept) { if (concept.isBottom()) { return; } if (concept.isTop()) { top = true; atomic = true; } if (concepts.contains(NegatedConcept.getConcept(concept))) { top = true; atomic = true; } concepts.add(concept); } public boolean equals(Object o) { if (top) return AtomicConcept.TOP.equals(o); if (! (o instanceof DisjunctionConcept)) return false; DisjunctionConcept dc = (DisjunctionConcept) o; return concepts.equals(dc.concepts); } public int hashCode() { if (top) return AtomicConcept.TOP.hashCode(); int result = 17; result = 37 * result + concepts.hashCode(); return result; } } Index: AtomicConcept.java =================================================================== RCS file: /cvsroot/javaowl/Reasoner/src/org/javaowl/reasoner/AtomicConcept.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AtomicConcept.java 13 Oct 2004 01:29:41 -0000 1.1 --- AtomicConcept.java 19 Oct 2004 06:55:44 -0000 1.2 *************** *** 23,55 **** import java.util.HashMap; ! public class AtomicConcept extends AbstractConcept{ ! private final String name; ! ! private final boolean negated; ! ! private final boolean top; ! ! private final boolean bottom; ! private final static Map map = new HashMap(); ! private final static Map negatedMap = new HashMap(); ! ! public final static AtomicConcept TOP; ! public final static AtomicConcept BOTTOM; ! static { ! TOP = new AtomicConcept("TOP", false, true, false); ! map.put("TOP", TOP); ! BOTTOM = new AtomicConcept("TOP", true, false, true); ! negatedMap.put("TOP", BOTTOM); ! } ! private AtomicConcept(String name, boolean negated, boolean top, boolean bottom) { this.name = name; ! this.negated = negated; ! this.top = top; ! this.bottom = bottom; } --- 23,46 ---- import java.util.HashMap; ! public class AtomicConcept implements Concept{ private final static Map map = new HashMap(); ! public static final AtomicConcept TOP = new AtomicConcept("TOP") { ! public boolean isTop() { ! return true; ! } ! }; ! public static final AtomicConcept BOTTOM = new AtomicConcept("BOTTOM") { ! public boolean isBottom() { ! return true; ! } ! }; ! private final String name; ! private AtomicConcept(String name) { this.name = name; ! map.put(name, this); } *************** *** 57,94 **** AtomicConcept concept = (AtomicConcept) map.get(name); if (concept == null) { ! concept = new AtomicConcept(name, false, false, false); ! map.put(name, concept); } return concept; } - public AtomicConcept getNegatedConcept() { - if (negated) { - AtomicConcept concept = (AtomicConcept) map.get(name); - if (concept == null) { - concept = new AtomicConcept(name, false, false, false); - negatedMap.put(name, concept); - } - return concept; - } - AtomicConcept concept = (AtomicConcept) negatedMap.get(name); - if (concept == null) { - concept = new AtomicConcept(name, true, false, false); - negatedMap.put(name, concept); - } - return concept; - } - - public boolean isTop() { ! return top; } public boolean isBottom() { ! return bottom; } public boolean isNegated() { ! return negated; } --- 48,66 ---- AtomicConcept concept = (AtomicConcept) map.get(name); if (concept == null) { ! concept = new AtomicConcept(name); } return concept; } public boolean isTop() { ! return false; } public boolean isBottom() { ! return false; } public boolean isNegated() { ! return false; } *************** *** 96,105 **** return true; } - - public boolean equals(Object o) { - if (! (o instanceof AtomicConcept)) - return false; - - return o == this; - } } --- 68,70 ---- --- NEW FILE: NegatedConcept.java --- /* AtomicConcept.java Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer Garduno Hernandez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.javaowl.reasoner; import java.util.Map; import java.util.HashMap; public class NegatedConcept implements Concept{ private final Concept concept; private final static Map map = new HashMap(); private NegatedConcept(Concept concept) { this.concept = concept; } public final static Concept getConcept(Concept concept) { if (concept.isTop()) return AtomicConcept.BOTTOM; if (concept.isBottom()) return AtomicConcept.TOP; if (concept.isNegated()) return ((NegatedConcept) concept).concept; Concept negatedConcept = (Concept) map.get(concept); if (negatedConcept == null) { negatedConcept = new NegatedConcept(concept); map.put(concept, negatedConcept); } return negatedConcept; } public boolean isTop() { return false; } public boolean isBottom() { return false; } public boolean isNegated() { return true; } public boolean isAtomic() { return concept.isAtomic(); } } |