From: <jen...@us...> - 2008-02-17 13:09:05
|
Revision: 590 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=590&view=rev Author: jenslehmann Date: 2008-02-17 05:08:46 -0800 (Sun, 17 Feb 2008) Log Message: ----------- - added toManchester string for all descriptions - fixed toString method for named elements Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Description.java trunk/src/dl-learner/org/dllearner/core/owl/Individual.java trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java trunk/src/dl-learner/org/dllearner/core/owl/Negation.java trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Thing.java trunk/src/dl-learner/org/dllearner/core/owl/Union.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2008-02-17 13:08:46 UTC (rev 590) @@ -27,7 +27,16 @@ return "ADC"; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + */ @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + // TODO Auto-generated method stub + return null; + } + + @Override public int getArity() { return 0; } @@ -44,4 +53,6 @@ visitor.visit(this); } + + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -52,12 +52,23 @@ return null; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + */ @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + // TODO Auto-generated method stub + return null; + } + + @Override public void accept(DescriptionVisitor visitor) { visitor.visit(this); } public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } + + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -60,4 +60,13 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + // TODO Auto-generated method stub + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -62,5 +62,14 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + // TODO Auto-generated method stub + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-17 13:08:46 UTC (rev 590) @@ -50,7 +50,7 @@ * @see org.dllearner.core.dl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return Helper.getAbbreviatedString(name, baseURI, prefixes); + return "\"" + Helper.getAbbreviatedString(name, baseURI, prefixes) + "\""; } public void accept(KBElementVisitor visitor) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -69,5 +69,14 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + // TODO Auto-generated method stub + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -19,6 +19,8 @@ */ package org.dllearner.core.owl; +import java.util.Map; + /** * @author Jens Lehmann * @@ -35,5 +37,14 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + // TODO Auto-generated method stub + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Description.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2008-02-17 13:08:46 UTC (rev 590) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.core.owl; import java.util.LinkedList; @@ -2,8 +21,8 @@ import java.util.List; +import java.util.Map; /** - * TODO: alless was fast retrieval algorithm angeht, sollte - * ausgegliedert werden! + * A class description is sometimes also called "complex class" or "concept". * - * @author jl + * @author Jens Lehmann * @@ -14,74 +33,13 @@ protected Description parent = null; protected List<Description> children = new LinkedList<Description>(); - //protected SortedSet<String> posSet = new TreeSet<String>(); - //protected SortedSet<String> negSet = new TreeSet<String>(); - - /* - public Node(List<Node> children) { - this.children = children; - for(Node n : children) - n.setParent(this); - } - */ - - // TODO: die Methode noch hinzuf�gen + public abstract int getArity(); /** - * Berechnet die + und - Menge. Wenn die Mengen berechnet sind, dann können - * sie über die get-Methoden abgefragt werden. Der Algorithmus ist relativ - * einfach zu implementieren, aber ein großer Teil des Codes wird zum - * vermeiden von Nullpointern (bei unvollständigen Daten) eingesetzt. + * Calculate the number of nodes for this description tree (each + * description can be seen as a tree). * - * Die �bergebenen Mengen - */ - // protected abstract void calculatePosSet(FlatABox abox); - // protected abstract void calculateSets(FlatABox abox, SortedSet<String> adcPosSet, SortedSet<String> adcNegSet); - /* - // Score ohne ADF berechnen - public Score computeScore() { - return computeScore(null,null); - } - */ - - // Score mit ADF berechnen - - //public Score computeScore(SortedSet<String> adcPosSet, SortedSet<String> adcNegSet) { - /* - Set<String> posExamples = null; - Set<String> negExamples = null; - - FlatABox abox = FlatABox.getInstance(); - - // es wird angenommen, dass nur ein Konzept gelernt wird - for(String s : abox.exampleConceptsPos.keySet()) { - posExamples = abox.exampleConceptsPos.get(s); - } - for(String s : abox.exampleConceptsNeg.keySet()) { - negExamples = abox.exampleConceptsNeg.get(s); - } - - // Algorithmus anwenden - calculateSets(abox); - //Set<String> posSet = program.getPosSet(); - //Set<String> negSet = program.getNegSet(); - - // Punktzahl sind die abgedeckten positiven Beispiele + - // die nicht abgedeckten negativen Beispiele - int points = Helper.intersection(posSet,posExamples).size() - + Helper.intersection(negSet,negExamples).size(); - - // besser: Abzüge wenn pos. Beispiel negativ wird bzw. umgekehrt - - return points; - */ - // calculateSets(FlatABox.getInstance(),posSet,negSet); - // return new Score(posSet,negSet); - //} - - /** - * Calculate the number of nodes for this tree. * @return The number of nodes. */ public int getNumberOfNodes() { @@ -90,26 +48,13 @@ sum += child.getNumberOfNodes(); return sum; } - - // protected abstract int getLength(); /** - * Calculate the number of nodes for this tree. - * @return The number of nodes. - */ - /* - public int getConceptLength() { - int length = getLength(); - for (Concept child : children) - length += child.getConceptLength(); - return length; - }*/ - - /** * Selects a sub tree. * @param i A position in the tree. Positions are iteratively given to nodes * by leftmost depth-first search. This allows efficient selection of subtrees. - * (Implementation does not work if any node has more than two children.) + * (TODO: Implementation does not work if any node has more than two children + * like conjunction and disjunction.) * @return The selected subtree. */ public Description getSubtree(int i) { @@ -137,8 +82,8 @@ } /** - * Calculates the tree depth. - * @return The depth of this tree. + * Calculates the description tree depth. + * @return The depth of this description. */ public int getDepth() { // compute the max over all children @@ -154,8 +99,7 @@ } /** - * Returns a clone of this programm tree. Die positiven und negativen Sets - * werden dabei nicht mitgeklont, sondern nur parent und children. + * Returns a clone of this description. */ @SuppressWarnings("unchecked") @Override @@ -164,64 +108,27 @@ try { node = (Description) super.clone(); } catch (CloneNotSupportedException e) { - // this should never happen + // should never happen throw new InternalError(e.toString()); } - // parent kann man ev. auf null setzen bzw. testen, ob er null ist und - // in diesem Fall auf null setzen - // node.parent = (Node) parent.clone(); - // node.parent = null; - // eventuell sollte man jedes einzelne Kind durchgehen und klonen, da die clone() - // Methode von LinkedList nur eine "shallow copy" erzeugt - // node.children = (List<Node>) ((LinkedList)children).clone(); - // List<Node> childList = new LinkedList<Node>(); - - // Die Kopie des Knotens wird folgenderma�en angelegt: Zuerst wird mit - // super.clone() ein Klon des Knotens erstellt. Dabei handelt es sich um - // eine flache Kopie, d.h. bei nichtprimitiven Objekten wird einfach auf - // das gleiche Objekt gezeigt. Bei der Liste von Kindern ist das nicht - // erw�nscht. Es ist auch nicht m�glich nur clone() auf der Kinderliste - // selbst aufzurufen, weil dabei nur die Liste und nich die Elemente der Liste - // geklont werden. Aus dem Grund wird eine komplett neue Kinderliste erzeugt - // und dort die Knoten eingef�gt, die zuvor geklont werden. Durch aufrufen von - // addChild wird auch sichergestellt, dass der parent-Link auf den geklonten - // Knoten zeigt. + + // Create a deep copy, i.e. we iterate over all children and clone them. + // The addChild operation is used to ensure that the parent links are + // correct, i.e. all parent links point to the new clones instead of the + // old descriptions. node.children = new LinkedList<Description>(); for(Description child : children) { Description clonedChild = (Description) child.clone(); node.addChild(clonedChild); } - // Beim durchlaufen des Algorithmus werden posSet und negSet ge�ndert. Es ist - // nicht erw�nscht, dass sich diese Mengen, dann auch in anderen B�umen - // �ndern, da diese mittlerweile durch Crossover, Mutation etc. ge�ndert - // worden sein k�nnten. Momentan ist das nicht von Bedeutung (man k�nnte also - // die beiden folgenden Zeilen auch weglassen), da immer nur eine baumweise - // Abarbeitung des Algorithmus erfolgt und diese Mengen nicht wiederverwendet - // werden. - //node.posSet = new TreeSet<String>(); - //node.negSet = new TreeSet<String>(); return node; } - /* - protected Set<String> getPosSet() { - return posSet; - } - - protected Set<String> getNegSet() { - return negSet; - } - */ - - /* - public Concept getChildren(int index) { - return children.get(index); - } - */ - /** - * Adds child and sets this node as parent. + * Adds a description as child of this one. The parent link + * of the concept will point to this one. + * * @param child * @return */ @@ -231,7 +138,9 @@ } /** - * Adds child and sets this node as parent. + * Adds a child description at the specified index. + * + * @see #addChild(Description) * @param index * @param child */ @@ -240,15 +149,21 @@ children.add(index, child); } - // relativ neue Methode + /** + * Remove the specified child description (its parent link is set + * to null). + * @param child The child to remove. + */ public void removeChild(Description child) { child.setParent(null); children.remove(child); } /** - * Tests if this node is the root of a tree. - * @return True if this node is the root of a program tree, false otherwise. + * Tests whether this description is at the root, i.e. + * does not have a parent. + * + * @return True if this node is the root of a description, false otherwise. */ public boolean isRoot() { return (parent == null); @@ -275,5 +190,14 @@ return toString(null, null); } + /** + * Returns a manchester syntax string of this description. For a + * reference, see + * <a href="http://www.co-ode.org/resources/reference/manchester_syntax">here</a> + * and <a href="http://owl-workshop.man.ac.uk/acceptedLong/submission_9.pdf">here</a> (PDF). + * @return The manchester syntax string for this description. + */ + public abstract String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes); + public abstract void accept(DescriptionVisitor visitor); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Individual.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2008-02-17 13:08:46 UTC (rev 590) @@ -60,7 +60,7 @@ } public String toString(String baseURI, Map<String,String> prefixes) { - return Helper.getAbbreviatedString(name, baseURI, prefixes); + return "\"" + Helper.getAbbreviatedString(name, baseURI, prefixes) + "\""; } public void accept(KBElementVisitor visitor) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java 2008-02-17 13:08:46 UTC (rev 590) @@ -46,6 +46,23 @@ return ret; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + if(children.size()==0) + return "EMPTY_AND"; + + String ret = "("; + for(int i=0; i<children.size()-1; i++) { + ret += children.get(i).toManchesterSyntaxString(baseURI, prefixes) + " and "; + } + ret += children.get(children.size()-1).toManchesterSyntaxString(baseURI, prefixes) + ")"; + return ret; + } + + @Deprecated public String toStringOld() { String ret = "MULTI_AND ["; for(Description child : children) { @@ -65,5 +82,7 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } + + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-02-17 13:08:46 UTC (rev 590) @@ -57,7 +57,7 @@ } public String toString(String baseURI, Map<String,String> prefixes) { - return Helper.getAbbreviatedString(name, baseURI, prefixes); + return "\"" + Helper.getAbbreviatedString(name, baseURI, prefixes) + "\""; } /* (non-Javadoc) @@ -70,5 +70,13 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString(java.lang.String, java.util.Map) + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return Helper.getAbbreviatedString(name, baseURI, prefixes); } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Negation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2008-02-17 13:08:46 UTC (rev 590) @@ -41,5 +41,13 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString(java.lang.String, java.util.Map) + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return "(not " +children.get(0).toString(baseURI, prefixes) + ")"; } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2008-02-17 13:08:46 UTC (rev 590) @@ -18,6 +18,15 @@ return "BOTTOM"; } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString(java.lang.String, java.util.Map) + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + // TODO: check whether this is correct + return "owl:Nothing"; + } + public int getLength() { return 1; } @@ -37,5 +46,7 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } + + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.core.owl; import java.util.Map; @@ -2,3 +21,9 @@ - +/** + * All quantified restriction on objects, e.g. \forall hasChild.description + * stands for all objects having only children satisfying description. + * + * @author Jens Lehmann + * + */ public class ObjectAllRestriction extends ObjectQuantorRestriction { @@ -8,93 +33,15 @@ public ObjectAllRestriction(ObjectPropertyExpression role, Description c) { super(role, c); } - - /* - public All(String roleName) { - this.roleName = roleName; - } - - public String getRoleName() { - return roleName; - } - */ - - /* - @Override - protected void calculateSets(FlatABox abox, SortedSet<String> adcPosSet, SortedSet<String> adcNegSet) { - children.get(0).calculateSets(abox, posSet, negSet); - - // Daten zu R+ und R- - Map<String, SortedSet<String>> rplus = abox.rolesPos.get(roleName); - Map<String, SortedSet<String>> rminus = abox.rolesNeg.get(roleName); - // Daten zu C und C+ - Set<String> cPlus = children.get(0).posSet; - Set<String> cMinus = children.get(0).negSet; - - // Fallunterscheidungen einbauen, da R+ und R- leer sein können - // und es nicht für jedes a der Domain ein (a,b) \in R+ bzw. R- geben muss; - // man beachte, dass viele Regeln nur gelten, weil als Domain die Menge aller - // Individuen angenommen wird! - - // R- ist leer - if(rminus==null) { - // falls C die ganze Domain umfasst, dann erüllt jedes Individual - // All R.C, ansonsten keines (es muss nichts gemacht werden) - if(cPlus.equals(abox.domain)) - // keine Kopie notwendig, da Domain unveränderlich - posSet = abox.domain; - } else { - for (String a : abox.domain) { - if(!rminus.containsKey(a)) { - // a erfüllt die Bedingung, falls alle b in C+ sind - if(cPlus.equals(abox.domain)) - posSet.add(a); - } - else if (checkAll(Helper.difference(abox.domain, rminus.get(a)), cPlus)) - posSet.add(a); - } - } - - // falls R+ leer ist, dann ist Bedingung nie erfüllt - if(rplus!=null) { - for (String a : rplus.keySet()) { - // falls R+ Schlüssel nicht enthält, ist Bedingung nicht erfüllt - if (rplus.containsKey(a) && checkExist(rplus.get(a), cMinus)) - negSet.add(a); - } - } - - - - } - - // aus Exists-Klasse übernommen - private static boolean checkExist(Set<String> s1, Set<String> s2) { - for (String b : s1) { - if (s2.contains(b)) - return true; - } - return false; - } - - private static boolean checkAll(Set<String> s1, Set<String> s2) { - for (String b : s1) { - if (!s2.contains(b)) - return false; - } - return true; - } - */ - + public String toString(String baseURI, Map<String,String> prefixes) { return "ALL " + role + "." + children.get(0).toString(baseURI, prefixes); } - - /* - public int getLength() { - return 2; - } - */ + + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return role.toString(baseURI, prefixes) + " some " + children.get(0).toManchesterSyntaxString(baseURI, prefixes); + } /* (non-Javadoc) * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) @@ -106,5 +53,5 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -40,6 +40,11 @@ return "= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return role.toString(baseURI, prefixes) + " exactly " + number + " " + getChild(0).toManchesterSyntaxString(baseURI, prefixes); + } + /* (non-Javadoc) * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) */ @@ -50,5 +55,6 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -17,6 +17,11 @@ return "<= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return role.toString(baseURI, prefixes) + " max " + number + " " + getChild(0).toManchesterSyntaxString(baseURI, prefixes); + } + /* (non-Javadoc) * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -17,6 +17,11 @@ return ">= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return role.toString(baseURI, prefixes) + " min " + number + " " + getChild(0).toManchesterSyntaxString(baseURI, prefixes); + } + /* (non-Javadoc) * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2008-02-17 13:08:46 UTC (rev 590) @@ -44,11 +44,11 @@ public String toString() { return name; } + + public String toString(String baseURI, Map<String,String> prefixes) { + return "\"" + Helper.getAbbreviatedString(name, baseURI, prefixes) + "\""; + } - public String toString(String baseURI, Map<String,String> prefixes) { - return Helper.getAbbreviatedString(name, baseURI, prefixes); - } - public void accept(KBElementVisitor visitor) { visitor.visit(this); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.core.owl; import java.util.Map; @@ -2,3 +21,8 @@ - +/** + * Existantial restriction on objects, e.g. \exists hasChild.Male. + * + * @author Jens Lehmann + * + */ public class ObjectSomeRestriction extends ObjectQuantorRestriction { @@ -9,93 +33,14 @@ super(role,c); } - /* - public Exists(String roleName) { - this.roleName = roleName; - } - - public String getRoleName() { - return roleName; - } - */ - - /* - @Override - protected void calculateSets(FlatABox abox, SortedSet<String> adcPosSet, SortedSet<String> adcNegSet) { - children.get(0).calculateSets(abox, posSet, negSet); - - // Daten zu R+ - Map<String, SortedSet<String>> rplus = abox.rolesPos.get(roleName); - Map<String, SortedSet<String>> rminus = abox.rolesNeg.get(roleName); - // Daten zu C und C+ - Set<String> cPlus = children.get(0).posSet; - Set<String> cMinus = children.get(0).negSet; - - // es wird r(a,b) untersucht und sobald ein b mit b \in C+ gefunden - // wird, wird a in posSet aufgenommen - - if(rplus!=null) { - for (String a : rplus.keySet()) { - if (rplus.containsKey(a) && checkExist(rplus.get(a), cPlus)) - posSet.add(a); - } - } - - - // ich muss über die ganze Domain gehen: selbst wenn für ein a gar kein - // (a,b) in R- existiert, dann kann so ein a trotzdem die Bedingung erfüllen - - if(rminus==null) { - if(cMinus.equals(abox.domain)) - negSet = abox.domain; - } else { - for (String a : abox.domain) { - if(!rminus.containsKey(a)) { - if(cMinus.equals(abox.domain)) - negSet.add(a); - } else - if (checkAll(Helper.difference(abox.domain, rminus.get(a)), cMinus)) - negSet.add(a); - } - } - - } - - // check-Methoden: hier ist s1 jeweils immer die Menge aller b, die für - // ein festes a in den - // Updategleichungen die erste Bedingung erfüllen (z.B. alle b - // mit (a,b) \not\in R-) und s2 die Menge, die die zweite Bedingung erfüllt - - // gibt true zurück, falls es ein b gibt mit b \in s1 und b \in s2, - // ansonsten false - private static boolean checkExist(Set<String> s1, Set<String> s2) { - for (String b : s1) { - if (s2.contains(b)) - return true; - } - return false; - } - - // gibt false zurück, falls für ein b \in s1 gilt b \in s2, - // ansonsten true - private static boolean checkAll(Set<String> s1, Set<String> s2) { - for (String b : s1) { - if (!s2.contains(b)) - return false; - } - return true; - } - */ - public String toString(String baseURI, Map<String,String> prefixes) { return "EXISTS " + role.toString(baseURI, prefixes) + "." + children.get(0).toString(baseURI, prefixes); } - /* - public int getLength() { - return 2; - } - */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return role.toString(baseURI, prefixes) + " only " + children.get(0).toManchesterSyntaxString(baseURI, prefixes); + } /* (non-Javadoc) * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-02-17 13:08:46 UTC (rev 590) @@ -19,6 +19,8 @@ */ package org.dllearner.core.owl; +import java.util.Map; + /** * Restricts the value of an object property to a single individual * (corresponds to owl:hasValue). @@ -38,5 +40,14 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString(java.lang.String, java.util.Map) + */ + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + // TODO Auto-generated method stub + return null; } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Thing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2008-02-17 13:08:46 UTC (rev 590) @@ -16,6 +16,11 @@ return "TOP"; } + @Override + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return "owl:Thing"; + } + public int getLength() { return 1; } @@ -35,5 +40,7 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } + + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Union.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Union.java 2008-02-17 11:18:26 UTC (rev 589) +++ trunk/src/dl-learner/org/dllearner/core/owl/Union.java 2008-02-17 13:08:46 UTC (rev 590) @@ -48,6 +48,19 @@ return ret; } + @Override + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + if(children.size()==0) + return "EMPTY_OR"; + + String ret = "("; + for(int i=0; i<children.size()-1; i++) { + ret += children.get(i).toManchesterSyntaxString(baseURI, prefixes) + " or "; + } + ret += children.get(children.size()-1).toManchesterSyntaxString(baseURI, prefixes) + ")"; + return ret; + } + public String toStringOld() { String ret = "MULTI_OR ["; for(Description child : children) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |