You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <lor...@us...> - 2014-08-06 12:19:53
|
Revision: 4285 http://sourceforge.net/p/dl-learner/code/4285 Author: lorenz_b Date: 2014-08-06 12:19:49 +0000 (Wed, 06 Aug 2014) Log Message: ----------- Updated OWL API. Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/reasoning/OWLPunningDetector.java Added: trunk/components-core/src/main/java/org/dllearner/reasoning/OWLPunningDetector.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/OWLPunningDetector.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/OWLPunningDetector.java 2014-08-06 12:19:49 UTC (rev 4285) @@ -0,0 +1,54 @@ +/** + * + */ +package org.dllearner.reasoning; + +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Lorenz Buehmann + * + */ +public class OWLPunningDetector { + + /** + * This object property is used to connect individuals with classes that are also individuals, thus, lead to punning. + */ + public static final ObjectProperty punningProperty = new ObjectProperty("http://dl-learner.org/punning/relatedTo"); + + /** + * Checks whether the same IRI denotes both a class and an individual in the ontology. + * @param ontology + * @param iri + * @return + */ + public static boolean hasPunning(OWLOntology ontology, NamedClass cls){ + return hasPunning(ontology, IRI.create(cls.getName())); + } + + /** + * Checks whether the same IRI denotes both a class and an individual in the ontology. + * @param ontology + * @param iri + * @return + */ + public static boolean hasPunning(OWLOntology ontology, IRI iri){ + boolean isClass = ontology.getClassesInSignature().contains(ontology.getOWLOntologyManager().getOWLDataFactory().getOWLClass(iri)); + boolean isIndividual = ontology.getIndividualsInSignature().contains(ontology.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(iri)); + return isClass && isIndividual; + } + + /** + * Checks whether the same IRI denotes both a class and an individual in the ontology. + * @param ontology + * @param iri + * @return + */ + public static boolean hasPunning(OWLOntology ontology, String iri){ + return hasPunning(ontology, IRI.create(iri)); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-08-06 11:52:32
|
Revision: 4284 http://sourceforge.net/p/dl-learner/code/4284 Author: lorenz_b Date: 2014-08-06 11:52:27 +0000 (Wed, 06 Aug 2014) Log Message: ----------- Updated OWL API. Modified Paths: -------------- trunk/scripts/pom.xml Modified: trunk/scripts/pom.xml =================================================================== --- trunk/scripts/pom.xml 2014-08-06 11:41:26 UTC (rev 4283) +++ trunk/scripts/pom.xml 2014-08-06 11:52:27 UTC (rev 4284) @@ -129,7 +129,6 @@ <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-distribution</artifactId> - <version>3.5.1-SNAPSHOT</version> </dependency> <!-- <dependency> <groupId>net.sourceforge.owlapi</groupId> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-08-06 11:41:31
|
Revision: 4283 http://sourceforge.net/p/dl-learner/code/4283 Author: lorenz_b Date: 2014-08-06 11:41:26 +0000 (Wed, 06 Aug 2014) Log Message: ----------- Updated OWL API. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyExpression.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyInverse.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectQuantorRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyExpression.java trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java trunk/components-core/src/test/resources/punning_example.ttl trunk/pom.xml Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -346,6 +346,9 @@ if(writeSearchTree) { File f = new File(searchTreeFile ); + if(f.getParentFile() != null){ + f.getParentFile().mkdirs(); + } Files.clearFile(f); } Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -52,6 +52,14 @@ public URI getURI() { return URI.create(name); } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.PropertyExpression#isAnonymous() + */ + @Override + public boolean isAnonymous() { + return false; + } @Override public String toString() { Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/Description.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -25,6 +25,8 @@ import java.util.Map; import java.util.Set; +import org.semanticweb.owlapi.model.OWLRuntimeException; + /** * A class description is sometimes also called "complex class" or "concept". * @@ -216,8 +218,20 @@ return this instanceof NamedClass; } + /** + * Determines whether or not this expression represents an anonymous class + * expression. + * + * @return {@code true} if this is an anonymous class expression, or + * {@code false} if this is a named class ( {@code OWLClass}) + */ + public boolean isAnonymous(){ + return true; + }; + public NamedClass asNamedClass(){ - return (NamedClass)this; + throw new OWLRuntimeException( + "Not an OWLClass. This method should only be called if the isAnonymous method returns false!"); } /** Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -56,6 +56,22 @@ return URI.create(name); } + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#isAnonymous() + */ + @Override + public boolean isAnonymous() { + return false; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#asNamedClass() + */ + @Override + public NamedClass asNamedClass() { + return this; + } + public int getLength() { return 1; } Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -46,7 +46,23 @@ public URI getURI() { return URI.create(name); - } + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.ObjectPropertyExpression#asObjectProperty() + */ + @Override + public ObjectProperty asObjectProperty() { + return this; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.PropertyExpression#isAnonymous() + */ + @Override + public boolean isAnonymous() { + return false; + } @Override public String toString() { Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyExpression.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyExpression.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyExpression.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -21,6 +21,8 @@ import java.io.Serializable; +import org.semanticweb.owlapi.model.OWLRuntimeException; + /** * An object property expression is an object property construct, which * can be used in axioms, e.g. complex class descriptions. It can be @@ -52,7 +54,21 @@ result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } - + + /** + * If the property is a named object property then this method will obtain + * the property as such. The general pattern of use is that the + * {@code isAnonymous} method should first be used to determine if the + * property is named (i.e. not an object property expression such as + * inv(p)). If the property is named then this method may be used to obtain + * the property as a named property without casting. + * + * @return The property as an {@code ObjectProperty} if possible. + * @throws OWLRuntimeException + * if the property is not a named property. + */ + public abstract ObjectProperty asObjectProperty(); + @Override public boolean equals(Object obj) { if (this == obj) Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyInverse.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyInverse.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyInverse.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -22,6 +22,7 @@ import java.util.Map; import org.dllearner.utilities.Helper; +import org.semanticweb.owlapi.model.OWLRuntimeException; /** * Represents the inverse of a property expression. It can be used @@ -49,6 +50,23 @@ public int getLength() { return 2; } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.ObjectPropertyExpression#asObjectProperty() + */ + @Override + public ObjectProperty asObjectProperty() { + throw new OWLRuntimeException( + "Property is not a named property. Check using the isAnonymous method before calling this method!"); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.PropertyExpression#isAnonymous() + */ + @Override + public boolean isAnonymous() { + return true; + } public String toString(String baseURI, Map<String,String> prefixes) { return Helper.getAbbreviatedString(name, baseURI, prefixes) + "-"; Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectQuantorRestriction.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectQuantorRestriction.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectQuantorRestriction.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -19,6 +19,7 @@ package org.dllearner.core.owl; + /** * * @author Jens Lehmann @@ -26,9 +27,6 @@ */ public abstract class ObjectQuantorRestriction extends QuantorRestriction { - /** - * - */ private static final long serialVersionUID = -5482730659805823042L; public ObjectQuantorRestriction(ObjectPropertyExpression role, Description c) { Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -29,9 +29,6 @@ */ public class ObjectSomeRestriction extends ObjectQuantorRestriction { - /** - * - */ private static final long serialVersionUID = 858960420513908151L; public ObjectSomeRestriction(ObjectPropertyExpression role, Description c) { Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyExpression.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyExpression.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/PropertyExpression.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -24,5 +24,14 @@ * */ public interface PropertyExpression extends KBElement { + + /** + * Determines if this property expression is anonymous. + * + * @return {@code true} if the property expression is anonymous (because it + * is the inverse of a property). {@code false} if this property is + * a named object property or named data property. + */ + boolean isAnonymous(); } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -26,6 +26,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -153,7 +154,7 @@ private boolean materializeExistentialRestrictions = false; private boolean useCaching = true; - + private boolean handlePunning = true; public enum ForallSemantics { Standard, // standard all quantor @@ -271,6 +272,7 @@ HashFunction hf = Hashing.md5(); Hasher hasher = hf.newHasher(); hasher.putBoolean(materializeExistentialRestrictions); + hasher.putBoolean(handlePunning); for (OWLOntology ont : rc.getOWLAPIOntologies()) { hasher.putInt(ont.getLogicalAxioms().hashCode()); hasher.putInt(ont.getAxioms().hashCode()); @@ -373,6 +375,7 @@ sd.put(dp, rc.getStringDatatypeMembers(dp)); } + if(materializeExistentialRestrictions){ ExistentialRestrictionMaterialization materialization = new ExistentialRestrictionMaterialization(rc.getReasoner().getRootOntology()); for (NamedClass cls : atomicConcepts) { @@ -384,6 +387,42 @@ } } + //materialize facts based on OWL punning, i.e.: + //for each A in N_C + if(handlePunning){ + OWLOntology ontology = rc.getReasoner().getRootOntology(); + + Individual genericIndividual = new Individual("http://dl-learner.org/punning#genInd"); + Map<Individual, SortedSet<Individual>> map = new HashMap<Individual, SortedSet<Individual>>(); + for (Individual individual : individuals) { + SortedSet<Individual> objects = new TreeSet<Individual>(); + objects.add(genericIndividual); + map.put(individual, objects); + } + for (NamedClass cls : atomicConcepts) { + classInstancesNeg.get(cls).add(genericIndividual); + if(OWLPunningDetector.hasPunning(ontology, cls)){ + Individual clsAsInd = new Individual(cls.getName()); + //for each x \in N_I with A(x) we add relatedTo(x,A) + SortedSet<Individual> individuals = classInstancesPos.get(cls); + for (Individual individual : individuals) { + SortedSet<Individual> objects = map.get(individual); + if(objects == null){ + objects = new TreeSet<Individual>(); + map.put(individual, objects); + } + objects.add(clsAsInd); + + } + } + } + opPos.put(OWLPunningDetector.punningProperty, map); + atomicRoles = new TreeSet<ObjectProperty>(atomicRoles); + atomicRoles.add(OWLPunningDetector.punningProperty); + atomicRoles = Collections.unmodifiableSet(atomicRoles); +// individuals.add(genericIndividual); + } + long dematDuration = System.currentTimeMillis() - dematStartTime; logger.debug("TBox dematerialised in " + dematDuration + " ms"); } @@ -482,6 +521,9 @@ } ObjectProperty op = (ObjectProperty) ope; Description child = description.getChild(0); + if(handlePunning && op == OWLPunningDetector.punningProperty && child.equals(new NamedClass(Thing.uri.toString()))){ + return true; + } Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); if (mapping == null) { @@ -489,7 +531,8 @@ + ")."); return false; } - SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + + SortedSet<Individual> roleFillers = mapping.get(individual); if (roleFillers == null) { return false; } @@ -565,7 +608,9 @@ return true; } // return false if there are none or not enough role fillers - if (roleFillers == null || roleFillers.size() < number) { + if (roleFillers == null + || (roleFillers.size() < number && op != OWLPunningDetector.punningProperty) + ) { return false; } @@ -574,7 +619,9 @@ index++; if (hasTypeImpl(child, roleFiller)) { nrOfFillers++; - if (nrOfFillers == number) { + if (nrOfFillers == number + || (handlePunning && op == OWLPunningDetector.punningProperty) + ) { return true; } // early abort: e.g. >= 10 hasStructure.Methyl; @@ -763,7 +810,7 @@ + description + " unsupported. Inverse object properties not supported."); } ObjectProperty op = (ObjectProperty) ope; - Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); // each individual is connected to a set of individuals via the property; // we loop through the complete mapping @@ -1265,4 +1312,18 @@ public void setMaterializeExistentialRestrictions(boolean materializeExistentialRestrictions) { this.materializeExistentialRestrictions = materializeExistentialRestrictions; } + + /** + * @param handlePunning the handlePunning to set + */ + public void setHandlePunning(boolean handlePunning) { + this.handlePunning = handlePunning; + } + + /** + * @param useCaching the useCaching to set + */ + public void setUseMaterializationCaching(boolean useCaching) { + this.useCaching = useCaching; + } } Modified: trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -75,6 +75,7 @@ import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.springframework.beans.factory.annotation.Autowired; import com.google.common.collect.Sets; @@ -499,15 +500,17 @@ } } else if (description instanceof Intersection) { - + + System.out.println("REFINING: " + OWLAPIDescriptionConvertVisitor.getOWLClassExpression(description)); // refine one of the elements for(Description child : description.getChildren()) { - + System.out.println(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(child)); + System.out.println(maxLength - description.getLength()+child.getLength()); // refine the child; the new max length is the current max length minus // the currently considered concept plus the length of the child // TODO: add better explanation tmp = refine(child, maxLength - description.getLength()+child.getLength(),null,currDomain); - + System.out.println(tmp); // create new intersection for(Description c : tmp) { List<Description> newChildren = (List<Description>)((LinkedList<Description>)description.getChildren()).clone(); Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -254,6 +254,12 @@ @Override public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + axiom.getProperty().accept(this); + writeSpace(); + write(DISJOINT_WITH); + writeSpace(); + axiom.getProperty().accept(this); + write(INVERSE); } @Override Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -22,6 +22,10 @@ import java.util.Comparator; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.reasoning.OWLPunningDetector; /** * Comparator for evaluated descriptions, which orders them by @@ -47,8 +51,12 @@ else if(acc1 < acc2) return -1; else { - int length1 = ed1.getDescriptionLength(); - int length2 = ed2.getDescriptionLength(); + int length1 = + getLength(ed1); +// ed1.getDescriptionLength(); + int length2 = + getLength(ed2); +// ed2.getDescriptionLength(); if(length1 < length2) return 1; else if(length1 > length2) @@ -57,5 +65,20 @@ return cc.compare(ed1.getDescription(), ed2.getDescription()); } } + + private int getLength(EvaluatedDescription ed){ + int length = 0; + Description d = ed.getDescription(); + if(d instanceof Intersection){ + for (Description child : d.getChildren()) { + if(child instanceof ObjectSomeRestriction && ((ObjectSomeRestriction) child).getRole().asObjectProperty() == OWLPunningDetector.punningProperty){ + length += child.getChild(0).getLength(); + } else { + length += child.getLength(); + } + } + } + return length; + } } \ No newline at end of file Modified: trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java 2014-08-06 11:41:26 UTC (rev 4283) @@ -3,37 +3,48 @@ */ package org.dllearner.test; -import java.io.ByteArrayInputStream; import java.util.HashSet; +import java.util.List; import java.util.Set; +import java.util.SortedSet; import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.algorithms.celoe.OEHeuristicRuntime; import org.dllearner.core.AbstractCELA; -import org.dllearner.core.AbstractLearningProblem; -import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.ComponentInitException; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.Thing; import org.dllearner.kb.OWLAPIOntology; import org.dllearner.learningproblems.PosNegLPStandard; -import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.utilities.owl.OWLAPIConverter; +import org.dllearner.reasoning.MaterializableFastInstanceChecker; +import org.dllearner.reasoning.OWLPunningDetector; +import org.dllearner.refinementoperators.RhoDRDown; +import org.dllearner.utilities.owl.DLSyntaxObjectRenderer; import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.junit.Assert; import org.junit.Test; import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.ToStringRenderer; import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLClass; import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLEntity; import org.semanticweb.owlapi.model.OWLNamedIndividual; -import org.semanticweb.owlapi.model.OWLObjectProperty; import org.semanticweb.owlapi.model.OWLOntology; import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.owllink.parser.OWLlinkDescriptionElementHandler; import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; import com.google.common.collect.Sets; +import com.google.common.collect.Sets.SetView; /** * @author Lorenz Buehmann @@ -41,87 +52,35 @@ */ public class PunningTest { - - public OWLOntology makeExampleKB() throws OWLOntologyCreationException{ - String kb = "@prefix owl:<http://www.w3.org/2002/07/owl#> . @prefix :<http://foo.org/> ."; - kb += ":p a owl:ObjectProperty ."; - - for (int i = 1; i <= 5; i++) { - kb += ":r" + i + " a owl:ObjectProperty ."; - } - - kb += ":A a owl:Class; :r1 :o1; :r2 :o2 ."; - kb += ":B a owl:Class; :r1 :o3; :r3 :o2 ."; - - for (int i = 1; i <= 10; i++) { - kb += ":x" + i + " a owl:NamedIndividual ."; - } - - int m = 5; - int n = 5; - - //m instances of A - for (int i = 1; i <= m; i++) { - kb += ":x" + i + " a :A ."; - } - - //n instances of B - for (int i = 1; i <= n; i++) { - kb += ":x" + i + " a :A ."; - } - - OWLOntology ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(new ByteArrayInputStream(kb.getBytes())); - return ontology; - } - public OWLOntology loadExample() throws OWLOntologyCreationException{ OWLOntology ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(this.getClass().getClassLoader().getResourceAsStream("punning_example.ttl")); return ontology; } @Test - public void testPunning() throws OWLOntologyCreationException, ComponentInitException{ - OWLOntology ontology = makeExampleKB(); - OWLDataFactory df = new OWLDataFactoryImpl(); + public void testPunningExists() throws OWLOntologyCreationException, ComponentInitException{ + OWLOntology ontology = loadExample(); - //check that A and B are both, individual and class - OWLClass clsA = df.getOWLClass(IRI.create("http://foo.org/A")); - OWLClass clsB = df.getOWLClass(IRI.create("http://foo.org/B")); - OWLIndividual indA = df.getOWLNamedIndividual(IRI.create("http://foo.org/A")); - OWLIndividual indB = df.getOWLNamedIndividual(IRI.create("http://foo.org/B")); - + Set<OWLNamedIndividual> individuals = ontology.getIndividualsInSignature(); Set<OWLClass> classes = ontology.getClassesInSignature(); - Set<OWLObjectProperty> properties = ontology.getObjectPropertiesInSignature(); - Set<OWLNamedIndividual> individuals = ontology.getIndividualsInSignature(); - System.out.println("Classes:" + classes); - System.out.println("Properties:" + properties); - System.out.println("Individuals:" + individuals); + SetView<IRI> intersection = Sets.intersection(toIRI(individuals), toIRI(classes)); + System.out.println("Entities that are class and individual:\n" + intersection); + Assert.assertTrue(!intersection.isEmpty()); - Assert.assertTrue( - ontology.getClassesInSignature().contains(clsA) && - ontology.getClassesInSignature().contains(clsB) && - ontology.getIndividualsInSignature().contains(indA) && - ontology.getIndividualsInSignature().contains(indB) - ); - - KnowledgeSource ks = new OWLAPIOntology(ontology); - ks.init(); - - AbstractReasonerComponent rc = new FastInstanceChecker(ks); - rc.init(); - - AbstractLearningProblem lp = new PosNegLPStandard(rc); - lp.init(); - - AbstractCELA la = new CELOE(lp, rc); - la.init(); - - la.start(); } + private Set<IRI> toIRI(Set<? extends OWLEntity> entities){ + Set<IRI> iris = new HashSet<IRI>(); + for (OWLEntity e : entities) { + iris.add(e.getIRI()); + } + return iris; + } + @Test - public void testPunning2() throws OWLOntologyCreationException, ComponentInitException{ + public void testPunning() throws OWLOntologyCreationException, ComponentInitException{ + ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); OWLOntology ontology = loadExample(); OWLDataFactory df = new OWLDataFactoryImpl(); @@ -138,18 +97,83 @@ KnowledgeSource ks = new OWLAPIOntology(ontology); ks.init(); - AbstractReasonerComponent rc = new FastInstanceChecker(ks); + MaterializableFastInstanceChecker rc = new MaterializableFastInstanceChecker(ks); +// rc.setUseMaterializationCaching(false); + rc.setHandlePunning(true); + rc.setUseMaterializationCaching(false); rc.init(); + rc.setBaseURI("http://ex.org/"); PosNegLPStandard lp = new PosNegLPStandard(rc); lp.setPositiveExamples(posExamples); lp.setNegativeExamples(negExamples); lp.init(); - AbstractCELA la = new CELOE(lp, rc); + CELOE la = new CELOE(lp, rc); + la.setWriteSearchTree(true); + la.setSearchTreeFile("log/punning_search_tree.txt"); + la.setReplaceSearchTree(true); + la.setMaxNrOfResults(50); + la.setMaxExecutionTimeInSeconds(20); + la.setExpandAccuracy100Nodes(true); + OEHeuristicRuntime heuristic = new OEHeuristicRuntime(); +// heuristic.setExpansionPenaltyFactor(0.001); +// la.setHeuristic(heuristic); la.init(); + ((RhoDRDown)la.getOperator()).setUseNegation(false); +// la.start(); - la.start(); + System.out.println("Classes: " + ontology.getClassesInSignature()); + System.out.println("Individuals: " + ontology.getIndividualsInSignature()); + + Description d = new Intersection(new NamedClass("http://ex.org/Fahrzeug")); + System.out.println(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(d)); + SortedSet<Individual> individuals = rc.getIndividuals(d); + System.out.println(individuals); + + d = new Intersection(new NamedClass("http://ex.org/Fahrzeug"), new ObjectSomeRestriction( + OWLPunningDetector.punningProperty, Thing.instance)); + System.out.println(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(d)); + individuals = rc.getIndividuals(d); + System.out.println(individuals); + + d = new Intersection(new NamedClass("http://ex.org/Fahrzeug"), new ObjectSomeRestriction( + OWLPunningDetector.punningProperty, new ObjectSomeRestriction(new ObjectProperty( + "http://ex.org/bereifung"), Thing.instance))); + System.out.println(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(d)); + individuals = rc.getIndividuals(d); + System.out.println(individuals); + + d = new Intersection(new NamedClass("http://ex.org/Fahrzeug"), new ObjectSomeRestriction( + OWLPunningDetector.punningProperty, +// new ObjectSomeRestriction(new ObjectProperty("http://ex.org/bereifung"), + Thing.instance)); + System.out.println(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(d)); + individuals = rc.getIndividuals(d); + System.out.println(individuals); + + //get some refinements + System.out.println("###############"); + System.out.println("Refinements:"); + Set<Description> refinements = la.getOperator().refine(d, d.getLength() + 4); + for (Description ref : refinements) { + System.out.println(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(ref)); + System.out.println(lp.getAccuracyOrTooWeak(ref, 0d)); + } + System.out.println("###############"); + + + d = new Intersection(new NamedClass("http://ex.org/Fahrzeug"), new ObjectSomeRestriction( + OWLPunningDetector.punningProperty, new ObjectSomeRestriction(new ObjectProperty( + "http://ex.org/bereifung"), new ObjectSomeRestriction(OWLPunningDetector.punningProperty, + Thing.instance)))); + System.out.println(OWLAPIDescriptionConvertVisitor.getOWLClassExpression(d)); + individuals = rc.getIndividuals(d); + System.out.println(individuals); +// List<? extends EvaluatedDescription> currentlyBestEvaluatedDescriptions = la.getCurrentlyBestEvaluatedDescriptions(100); +// for (EvaluatedDescription ed : currentlyBestEvaluatedDescriptions) { +// System.out.println(ed); +// } } } Modified: trunk/components-core/src/test/resources/punning_example.ttl =================================================================== --- trunk/components-core/src/test/resources/punning_example.ttl 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/components-core/src/test/resources/punning_example.ttl 2014-08-06 11:41:26 UTC (rev 4283) @@ -57,11 +57,7 @@ <http://ex.org/SIEMENS425#567> a ex:Bahn . <http://ex.org/TATRAT3#678> a ex:Tram . -# punning workaround -ex:p a owl:ObjectProperty . -<http://ex.org/TRABANT601#1234> ex:p ex:Auto . -<http://ex.org/S51#2345> ex:p ex:Moped . -<http://ex.org/MIFA23#3456> ex:p ex:Fahrrad . -<http://ex.org/CLIPSO90MG#4567> ex:p ex:Schubkarre . -<http://ex.org/SIEMENS425#567> ex:p ex:Bahn . -<http://ex.org/TATRAT3#678> ex:p ex:Tram . \ No newline at end of file +# punning of ex:Gummireifen +ex:bestehtAus a owl:ObjectProperty . +ex:Gummireifen ex:bestehtAus ex:GUMMI . +ex:GUMMI a ex:Werkstoff . Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-07-29 13:56:03 UTC (rev 4282) +++ trunk/pom.xml 2014-08-06 11:41:26 UTC (rev 4283) @@ -123,7 +123,7 @@ <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-distribution</artifactId> - <version>3.4.5</version> + <version>3.5.1</version> </dependency> <dependency> <groupId>net.sourceforge.owlapi</groupId> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-07-29 13:56:08
|
Revision: 4282 http://sourceforge.net/p/dl-learner/code/4282 Author: lorenz_b Date: 2014-07-29 13:56:03 +0000 (Tue, 29 Jul 2014) Log Message: ----------- Added punning test. Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/kb/sparql/BlanknodeResolvingCBDGenerator.java Added: trunk/components-core/src/main/java/org/dllearner/kb/sparql/BlanknodeResolvingCBDGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/BlanknodeResolvingCBDGenerator.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/BlanknodeResolvingCBDGenerator.java 2014-07-29 13:56:03 UTC (rev 4282) @@ -0,0 +1,100 @@ +/** + * + */ +package org.dllearner.kb.sparql; + +import java.util.List; + +import org.aksw.jena_sparql_api.model.QueryExecutionFactoryModel; + +import com.hp.hpl.jena.query.ParameterizedSparqlString; +import com.hp.hpl.jena.query.QueryExecution; +import com.hp.hpl.jena.rdf.model.Model; + +/** + * @author Lorenz Buehmann + * + */ +public class BlanknodeResolvingCBDGenerator implements ConciseBoundedDescriptionGenerator{ + + private QueryExecutionFactoryModel qef; + boolean resolveBlankNodes = true; + + public BlanknodeResolvingCBDGenerator(Model model) { + String query = "prefix : <http://dl-learner.org/ontology/> " + + "construct { ?s ?p ?o ; ?type ?s .} " + + "where { ?s ?p ?o . bind( if(isIRI(?s),:sameIri,:sameBlank) as ?type )}"; + qef = new QueryExecutionFactoryModel(model); + QueryExecution qe = qef.createQueryExecution(query); + Model extendedModel = qe.execConstruct(); + qe.close(); + + qef = new QueryExecutionFactoryModel(extendedModel); + } + + /* (non-Javadoc) + * @see org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator#getConciseBoundedDescription(java.lang.String) + */ + @Override + public Model getConciseBoundedDescription(String resourceURI) { + return getConciseBoundedDescription(resourceURI, 0); + } + + /* (non-Javadoc) + * @see org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator#getConciseBoundedDescription(java.lang.String, int) + */ + @Override + public Model getConciseBoundedDescription(String resourceURI, int depth) { + return getConciseBoundedDescription(resourceURI, depth, false); + } + + /* (non-Javadoc) + * @see org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator#getConciseBoundedDescription(java.lang.String, int, boolean) + */ + @Override + public Model getConciseBoundedDescription(String resourceURI, int depth, boolean withTypesForLeafs) { + StringBuilder constructTemplate = new StringBuilder("?s0 ?p0 ?o0 ."); + for(int i = 1; i <= depth; i++){ + constructTemplate.append("?o").append(i-1).append(" ?p").append(i).append(" ?o").append(i).append(" ."); + } + + StringBuilder triplesTemplate = new StringBuilder("?s0 ?p0 ?o0 ."); + for(int i = 1; i <= depth; i++){ + triplesTemplate.append("OPTIONAL{").append("?o").append(i-1).append(" ?p").append(i).append(" ?o").append(i).append(" ."); + } + if(resolveBlankNodes){ + triplesTemplate.append("?o").append(depth).append("((!<x>|!<y>)/:sameBlank)* ?x . ?x ?px ?ox .filter(!(?p in (:sameIri, :sameBlank)))"); + } + for(int i = 1; i <= depth; i++){ + triplesTemplate.append("}"); + } + + + StringBuilder queryString = new StringBuilder("prefix : <http://dl-learner.org/ontology/> "); + queryString.append("CONSTRUCT{").append(constructTemplate).append("}"); + queryString.append(" WHERE {").append(triplesTemplate).append("}"); + + ParameterizedSparqlString query = new ParameterizedSparqlString(queryString.toString()); + query.setIri("s0", resourceURI); + System.out.println(query); + QueryExecution qe = qef.createQueryExecution(query.toString()); + Model cbd = qe.execConstruct(); + qe.close(); + return cbd; + } + + /* (non-Javadoc) + * @see org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator#setRestrictToNamespaces(java.util.List) + */ + @Override + public void setRestrictToNamespaces(List<String> namespaces) { + } + + /* (non-Javadoc) + * @see org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator#setRecursionDepth(int) + */ + @Override + public void setRecursionDepth(int maxRecursionDepth) { + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-07-29 13:55:41
|
Revision: 4281 http://sourceforge.net/p/dl-learner/code/4281 Author: lorenz_b Date: 2014-07-29 13:55:31 +0000 (Tue, 29 Jul 2014) Log Message: ----------- Added punning test. Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/ClassExpressionLiteralCombination.java trunk/components-core/src/main/java/org/dllearner/reasoning/Materialization.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java trunk/components-core/src/test/java/org/dllearner/test/junit/PunningTest.java trunk/components-core/src/test/resources/log4j.properties trunk/components-core/src/test/resources/punning_example.ttl Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/ClassExpressionLiteralCombination.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/ClassExpressionLiteralCombination.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/ClassExpressionLiteralCombination.java 2014-07-29 13:55:31 UTC (rev 4281) @@ -0,0 +1,336 @@ +/** + * + */ +package org.dllearner.algorithms.qtl.util; + +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.algorithms.pattern.ManchesterOWLSyntaxOWLObjectRendererImpl; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataRange; +import org.semanticweb.owlapi.model.OWLDataRangeVisitorEx; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.vocab.OWLFacet; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + +/** + * @author Lorenz Buehmann + * + */ +public class ClassExpressionLiteralCombination implements OWLClassExpressionVisitorEx<Set<OWLClassExpression>>, OWLDataRangeVisitorEx<Set<OWLDataRange>>{ + + private OWLDataFactory df = new OWLDataFactoryImpl(); + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLClass) + */ + @Override + public Set<OWLClassExpression> visit(OWLClass ce) { + Set<OWLClassExpression> expressions = new HashSet<OWLClassExpression>(1); + expressions.add(ce); + return expressions; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectIntersectionOf) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectIntersectionOf ce) { + Set<OWLClassExpression> expressions = new HashSet<OWLClassExpression>(); + Set<Set<OWLClassExpression>> combinations = new HashSet<Set<OWLClassExpression>>(); + for (int i = 0; i < ce.getOperands().size(); i++) { + Set<OWLClassExpression> tmp = new HashSet<OWLClassExpression>(); + combinations.add(tmp); + } + for (OWLClassExpression operand : ce.getOperands()) { + Set<Set<OWLClassExpression>> combinationsTmp = new HashSet<Set<OWLClassExpression>>(); + Set<OWLClassExpression> newOperands = operand.accept(this); + for (Set<OWLClassExpression> set : combinations) { + for (OWLClassExpression newOp : newOperands) { + Set<OWLClassExpression> tmp = new HashSet<OWLClassExpression>(); + tmp.addAll(set); + tmp.add(newOp); + combinationsTmp.add(tmp); + } + } + combinations = combinationsTmp; + } + for (Set<OWLClassExpression> combination : combinations) { + expressions.add(df.getOWLObjectIntersectionOf(combination)); + } + return expressions; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectUnionOf) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectUnionOf ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectComplementOf) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectComplementOf ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectSomeValuesFrom ce) { + Set<OWLClassExpression> expressions = new HashSet<OWLClassExpression>(); + Set<OWLClassExpression> newFillers = ce.getFiller().accept(this); + for (OWLClassExpression newFiller : newFillers) { + expressions.add(df.getOWLObjectSomeValuesFrom(ce.getProperty(), newFiller)); + } + return expressions; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectAllValuesFrom) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectAllValuesFrom ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectHasValue) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectHasValue ce) { + Set<OWLClassExpression> expressions = new HashSet<OWLClassExpression>(); + expressions.add(ce); + return expressions; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectMinCardinality) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectMinCardinality ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectExactCardinality) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectExactCardinality ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectMaxCardinality) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectMaxCardinality ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectHasSelf) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectHasSelf ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLObjectOneOf) + */ + @Override + public Set<OWLClassExpression> visit(OWLObjectOneOf ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataSomeValuesFrom) + */ + @Override + public Set<OWLClassExpression> visit(OWLDataSomeValuesFrom ce) { + Set<OWLClassExpression> expressions = new HashSet<OWLClassExpression>(); + Set<OWLDataRange> newDataRanges = ce.getFiller().accept(this); + for (OWLDataRange newDataRange : newDataRanges) { + expressions.add(df.getOWLDataSomeValuesFrom(ce.getProperty(), newDataRange)); + } + return expressions; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataAllValuesFrom) + */ + @Override + public Set<OWLClassExpression> visit(OWLDataAllValuesFrom ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataHasValue) + */ + @Override + public Set<OWLClassExpression> visit(OWLDataHasValue ce) { + Set<OWLClassExpression> expressions = new HashSet<OWLClassExpression>(); + expressions.add(ce); + return expressions; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataMinCardinality) + */ + @Override + public Set<OWLClassExpression> visit(OWLDataMinCardinality ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataExactCardinality) + */ + @Override + public Set<OWLClassExpression> visit(OWLDataExactCardinality ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataMaxCardinality) + */ + @Override + public Set<OWLClassExpression> visit(OWLDataMaxCardinality ce) { + return null; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitorEx#visit(org.semanticweb.owlapi.model.OWLDatatype) + */ + @Override + public Set<OWLDataRange> visit(OWLDatatype dr) { + Set<OWLDataRange> dataRanges = new HashSet<OWLDataRange>(); + dataRanges.add(dr); + return dataRanges; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataOneOf) + */ + @Override + public Set<OWLDataRange> visit(OWLDataOneOf dr) { + Set<OWLDataRange> dataRanges = new HashSet<OWLDataRange>(); + dataRanges.add(dr); + return dataRanges; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataComplementOf) + */ + @Override + public Set<OWLDataRange> visit(OWLDataComplementOf dr) { + Set<OWLDataRange> dataRanges = new HashSet<OWLDataRange>(); + dataRanges.add(dr); + return dataRanges; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataIntersectionOf) + */ + @Override + public Set<OWLDataRange> visit(OWLDataIntersectionOf dr) { + Set<OWLDataRange> dataRanges = new HashSet<OWLDataRange>(); + dataRanges.add(dr); + return dataRanges; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitorEx#visit(org.semanticweb.owlapi.model.OWLDataUnionOf) + */ + @Override + public Set<OWLDataRange> visit(OWLDataUnionOf dr) { + Set<OWLDataRange> dataRanges = new HashSet<OWLDataRange>(); + dataRanges.add(dr); + return dataRanges; + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitorEx#visit(org.semanticweb.owlapi.model.OWLDatatypeRestriction) + */ + @Override + public Set<OWLDataRange> visit(OWLDatatypeRestriction dr) { + Set<OWLDataRange> dataRanges = new HashSet<OWLDataRange>(); + Set<OWLFacetRestriction> facetRestrictions = dr.getFacetRestrictions(); + OWLLiteral min = null; + OWLLiteral max = null; + for (OWLFacetRestriction facetRestriction : facetRestrictions) { + OWLFacet facet = facetRestriction.getFacet(); + if(facet == OWLFacet.MIN_INCLUSIVE){ + min = facetRestriction.getFacetValue(); + } else if(facet == OWLFacet.MAX_INCLUSIVE){ + max = facetRestriction.getFacetValue(); + } else { + throw new IllegalArgumentException("Facet not allowed for transformation."); + } + } +// dataRanges.add(dr); + dataRanges.add(df.getOWLDatatypeRestriction(dr.getDatatype(), df.getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, min))); + dataRanges.add(df.getOWLDatatypeRestriction(dr.getDatatype(), df.getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, max))); +// dataRanges.add(dr.getDatatype()); + return dataRanges; + } + + + public static void main(String[] args) throws Exception { + ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); + OWLDataFactoryImpl df = new OWLDataFactoryImpl(); + PrefixManager pm = new DefaultPrefixManager(":"); + OWLClass A = df.getOWLClass("A", pm ); + OWLDataProperty s = df.getOWLDataProperty("s", pm); + OWLDataProperty t = df.getOWLDataProperty("t", pm); + OWLDatatypeRestriction dr1 = df.getOWLDatatypeMinMaxInclusiveRestriction(1.0, 2.0); + OWLDatatypeRestriction dr2 = df.getOWLDatatypeMinMaxInclusiveRestriction(15, 100); + OWLClassExpression ce = df.getOWLObjectIntersectionOf(A, + df.getOWLDataSomeValuesFrom(s, dr1), + df.getOWLDataSomeValuesFrom(t, dr2) + ); + Set<OWLClassExpression> expressions = ce.accept(new ClassExpressionLiteralCombination()); + for (OWLClassExpression expr : expressions) { + System.out.println(expr); + } + } + + +} Added: trunk/components-core/src/main/java/org/dllearner/reasoning/Materialization.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/Materialization.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/Materialization.java 2014-07-29 13:55:31 UTC (rev 4281) @@ -0,0 +1,37 @@ +package org.dllearner.reasoning; + +import java.io.Serializable; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.dllearner.core.owl.Constant; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; + +class Materialization implements Serializable{ + // we use sorted sets (map indices) here, because they have only log(n) + // complexity for checking whether an element is contained in them + // instances of classes + public Map<NamedClass, TreeSet<Individual>> classInstancesPos = new TreeMap<NamedClass, TreeSet<Individual>>(); + public Map<NamedClass, TreeSet<Individual>> classInstancesNeg = new TreeMap<NamedClass, TreeSet<Individual>>(); + // object property mappings + public Map<ObjectProperty, Map<Individual, SortedSet<Individual>>> opPos = new TreeMap<ObjectProperty, Map<Individual, SortedSet<Individual>>>(); + // data property mappings + public Map<DatatypeProperty, Map<Individual, SortedSet<Constant>>> dpPos = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Constant>>>(); + + + // datatype property mappings + // for boolean data properties we have one mapping for true and false for efficiency reasons + public Map<DatatypeProperty, TreeSet<Individual>> bdPos = new TreeMap<DatatypeProperty, TreeSet<Individual>>(); + public Map<DatatypeProperty, TreeSet<Individual>> bdNeg = new TreeMap<DatatypeProperty, TreeSet<Individual>>(); + //double datatype property mappings + public Map<DatatypeProperty, Map<Individual, SortedSet<Double>>> dd = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Double>>>(); + //int datatype property + public Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Integer>>>(); + //string datatype property + public Map<DatatypeProperty, Map<Individual, SortedSet<String>>> sd = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<String>>>(); + } \ No newline at end of file Added: trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/DLSyntaxObjectRenderer.java 2014-07-29 13:55:31 UTC (rev 4281) @@ -0,0 +1,903 @@ +package org.dllearner.utilities.owl; + +/* + * This file is part of the OWL API. + * + * The contents of this file are subject to the LGPL License, Version 3.0. + * + * Copyright (C) 2011, The University of Manchester + * + * This program 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. + * + * This program 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/. + * + * + * Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0 + * in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above. + * + * Copyright 2011, The University of Manchester + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import static org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntax.FACET_RESTRICTION_SEPARATOR; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.AND; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.BOTTOM; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.COMMA; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.COMP; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.DISJOINT_WITH; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.EQUAL; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.EQUIVALENT_TO; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.EXISTS; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.FORALL; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.IMPLIES; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.IN; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.INVERSE; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.MAX; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.MIN; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.NOT; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.NOT_EQUAL; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.OR; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.SELF; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.SUBCLASS; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.TOP; +import static uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax.WEDGE; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.TreeSet; + +import org.semanticweb.owlapi.io.OWLObjectRenderer; +import org.semanticweb.owlapi.model.*; +import org.semanticweb.owlapi.util.IRIShortFormProvider; +import org.semanticweb.owlapi.util.ShortFormProvider; +import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; +import org.semanticweb.owlapi.util.SimpleShortFormProvider; + +import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntax; + +/** + * Extended version of the DLSyntaxObjectRenderer class in OWL API. Extension is + * done for data range facets, e.g. double[<=1.5]. + * + * Renders objects in unicode DL syntax. + * + * @author Matthew Horridge, The University Of Manchester, Bio-Health + * Informatics Group, Date: 10-Feb-2008 + */ +public class DLSyntaxObjectRenderer implements OWLObjectRenderer, OWLObjectVisitor { + + private ShortFormProvider shortFormProvider; + private IRIShortFormProvider iriShortFormProvider; + private StringBuilder buffer; + private OWLObject focusedObject; + + /** default constructor */ + public DLSyntaxObjectRenderer() { + shortFormProvider = new SimpleShortFormProvider(); + iriShortFormProvider = new SimpleIRIShortFormProvider(); + buffer = new StringBuilder(); + } + + /** + * @param focusedObject + * focusedObject + */ + public void setFocusedObject(OWLObject focusedObject) { + this.focusedObject = focusedObject; + } + + /** + * @param obj + * obj + * @return true if focused + */ + public boolean isFocusedObject(OWLObject obj) { + if (focusedObject == null) { + return false; + } + return focusedObject.equals(obj); + } + + @Override + public void setShortFormProvider(ShortFormProvider shortFormProvider) { + this.shortFormProvider = shortFormProvider; + } + + @Override + public String render(OWLObject object) { + buffer = new StringBuilder(); + object.accept(this); + return buffer.toString(); + } + + @Override + public void visit(OWLOntology ontology) { + for (OWLAxiom ax : new TreeSet<OWLAxiom>(ontology.getLogicalAxioms())) { + ax.accept(this); + write("\n"); + } + } + + protected void write(String s) { + buffer.append(s); + } + + protected String renderEntity(OWLEntity entity) { + return shortFormProvider.getShortForm(entity); + } + + protected void writeEntity(OWLEntity entity) { + write(renderEntity(entity)); + } + + protected void write(DLSyntax keyword) { + write(keyword.toString()); + } + + protected void write(int i) { + write(Integer.toString(i)); + } + + protected void writeNested(OWLObject object) { + if (isBracketedIfNested(object)) { + write("("); + } + object.accept(this); + if (isBracketedIfNested(object)) { + write(")"); + } + } + + protected boolean isBracketedIfNested(OWLObject object) { + // if(object instanceof OWLObjectComplementOf) { + // if(!((OWLObjectComplementOf) object).getOperand().isAnonymous()) { + // return false; + // } + // } + // return object instanceof OWLClassExpression && !((OWLClassExpression) + // object).isClassExpressionLiteral(); + return !(object instanceof OWLEntity); + } + + private void writeObject(OWLObject object, boolean nest) { + if (nest) { + writeNested(object); + } else { + object.accept(this); + } + } + + protected void write(Collection<? extends OWLObject> objects, DLSyntax delim, boolean nest) { + if (objects.size() == 2) { + Iterator<? extends OWLObject> it = objects.iterator(); + OWLObject o1 = it.next(); + OWLObject o2 = it.next(); + if (isFocusedObject(o1) || !isFocusedObject(o2)) { + writeObject(o1, nest); + writeSpace(); + write(delim); + writeSpace(); + writeObject(o2, nest); + } else { + writeObject(o2, nest); + writeSpace(); + write(delim); + writeSpace(); + writeObject(o1, nest); + } + } else { + for (Iterator<? extends OWLObject> it = objects.iterator(); it.hasNext();) { + OWLObject o = it.next(); + writeObject(o, nest); + if (it.hasNext()) { + writeSpace(); + write(delim); + writeSpace(); + } + } + } + } + + // protected void write(Collection<? extends OWLObject> objects, DLSyntax + // keyword, boolean nest) { + // write(objects, keyword, nest); + // } + @Override + public void visit(OWLSubClassOfAxiom axiom) { + axiom.getSubClass().accept(this); + writeSpace(); + write(SUBCLASS); + writeSpace(); + axiom.getSuperClass().accept(this); + } + + private void writePropertyAssertion(OWLPropertyAssertionAxiom<?, ?> ax) { + if (ax instanceof OWLNegativeObjectPropertyAssertionAxiom + || ax instanceof OWLNegativeDataPropertyAssertionAxiom) { + write(NOT); + } + ax.getProperty().accept(this); + write("("); + ax.getSubject().accept(this); + write(", "); + ax.getObject().accept(this); + write(")"); + } + + @Override + public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { + write(NOT); + writePropertyAssertion(axiom); + } + + @Override + public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { + } + + @Override + public void visit(OWLReflexiveObjectPropertyAxiom axiom) { + write(TOP); + writeSpace(); + write(SUBCLASS); + writeSpace(); + write(EXISTS); + writeSpace(); + axiom.getProperty().accept(this); + write(" ."); + write(SELF); + } + + @Override + public void visit(OWLDisjointClassesAxiom axiom) { + List<OWLClassExpression> descs = new ArrayList<OWLClassExpression>(axiom.getClassExpressions()); + for (int i = 0; i < descs.size(); i++) { + for (int j = i + 1; j < descs.size(); j++) { + descs.get(i).accept(this); + writeSpace(); + write(DISJOINT_WITH); + writeSpace(); + descs.get(j).accept(this); + if (j < descs.size() - 1) { + write(", "); + } + } + } + // write(axiom.getClassExpressions(), DISJOINT_WITH, true); + } + + private void writeDomainAxiom(OWLPropertyDomainAxiom<?> axiom) { + write(EXISTS); + writeSpace(); + axiom.getProperty().accept(this); + writeRestrictionSeparator(); + write(TOP); + writeSpace(); + write(SUBCLASS); + writeSpace(); + writeNested(axiom.getDomain()); + } + + private void writeRestrictionSeparator() { + write("."); + } + + @Override + public void visit(OWLDataPropertyDomainAxiom axiom) { + writeDomainAxiom(axiom); + } + + @Override + public void visit(OWLObjectPropertyDomainAxiom axiom) { + writeDomainAxiom(axiom); + } + + @Override + public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { + write(axiom.getProperties(), EQUIVALENT_TO, false); + } + + @Override + public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { + write(NOT); + writePropertyAssertion(axiom); + } + + @Override + public void visit(OWLDifferentIndividualsAxiom axiom) { + write(axiom.getIndividuals(), NOT_EQUAL, false); + } + + @Override + public void visit(OWLDisjointDataPropertiesAxiom axiom) { + write(axiom.getProperties(), DISJOINT_WITH, false); + } + + @Override + public void visit(OWLDisjointObjectPropertiesAxiom axiom) { + write(axiom.getProperties(), DISJOINT_WITH, false); + } + + private void writeRangeAxiom(OWLPropertyRangeAxiom<?, ?> axiom) { + write(TOP); + writeSpace(); + write(SUBCLASS); + writeSpace(); + write(FORALL); + writeSpace(); + axiom.getProperty().accept(this); + writeRestrictionSeparator(); + writeNested(axiom.getRange()); + } + + @Override + public void visit(OWLObjectPropertyRangeAxiom axiom) { + writeRangeAxiom(axiom); + } + + @Override + public void visit(OWLObjectPropertyAssertionAxiom axiom) { + writePropertyAssertion(axiom); + } + + private void writeFunctionalProperty(OWLPropertyExpression<?, ?> property) { + write(TOP); + writeSpace(); + write(SUBCLASS); + writeSpace(); + write(MAX); + writeSpace(); + write(1); + writeSpace(); + property.accept(this); + } + + @Override + public void visit(OWLFunctionalObjectPropertyAxiom axiom) { + writeFunctionalProperty(axiom.getProperty()); + } + + @Override + public void visit(OWLSubObjectPropertyOfAxiom axiom) { + axiom.getSubProperty().accept(this); + writeSpace(); + write(SUBCLASS); + writeSpace(); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLDisjointUnionAxiom axiom) { + axiom.getOWLClass().accept(this); + write(EQUAL); + write(axiom.getClassExpressions(), OR, false); + } + + @Override + public void visit(OWLDeclarationAxiom axiom) { + } + + @Override + public void visit(OWLAnnotationAssertionAxiom axiom) { + } + + @Override + public void visit(OWLSymmetricObjectPropertyAxiom axiom) { + axiom.getProperty().accept(this); + writeSpace(); + write(EQUIVALENT_TO); + writeSpace(); + axiom.getProperty().accept(this); + write(INVERSE); + } + + private void writeSpace() { + write(" "); + } + + @Override + public void visit(OWLDataPropertyRangeAxiom axiom) { + writeRangeAxiom(axiom); + } + + @Override + public void visit(OWLFunctionalDataPropertyAxiom axiom) { + writeFunctionalProperty(axiom.getProperty()); + } + + @Override + public void visit(OWLEquivalentDataPropertiesAxiom axiom) { + write(axiom.getProperties(), EQUIVALENT_TO, false); + } + + @Override + public void visit(OWLClassAssertionAxiom axiom) { + if (axiom.getClassExpression().isAnonymous()) { + write("("); + } + axiom.getClassExpression().accept(this); + if (axiom.getClassExpression().isAnonymous()) { + write(")"); + } + write("("); + axiom.getIndividual().accept(this); + write(")"); + } + + @Override + public void visit(OWLEquivalentClassesAxiom axiom) { + write(axiom.getClassExpressions(), EQUIVALENT_TO, false); + } + + @Override + public void visit(OWLDataPropertyAssertionAxiom axiom) { + writePropertyAssertion(axiom); + } + + @Override + public void visit(OWLTransitiveObjectPropertyAxiom axiom) { + axiom.getProperty().accept(this); + writeSpace(); + write(IN); + writeSpace(); + write("R"); + write("\u207A"); + } + + @Override + public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { + write(TOP); + writeSpace(); + write(SUBCLASS); + writeSpace(); + write(NOT); + write(EXISTS); + writeSpace(); + axiom.getProperty().accept(this); + write(" ."); + write(SELF); + } + + @Override + public void visit(OWLSubDataPropertyOfAxiom axiom) { + axiom.getSubProperty().accept(this); + write(SUBCLASS); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { + write(TOP); + writeSpace(); + write(SUBCLASS); + writeSpace(); + write(MAX); + writeSpace(); + write(1); + writeSpace(); + axiom.getProperty().accept(this); + write(INVERSE); + } + + @Override + public void visit(OWLSameIndividualAxiom axiom) { + write(axiom.getIndividuals(), EQUAL, false); + } + + @Override + public void visit(OWLSubPropertyChainOfAxiom axiom) { + write(axiom.getPropertyChain(), COMP, false); + writeSpace(); + write(SUBCLASS); + writeSpace(); + axiom.getSuperProperty().accept(this); + } + + @Override + public void visit(OWLInverseObjectPropertiesAxiom axiom) { + OWLObject o1 = axiom.getFirstProperty(); + OWLObject o2 = axiom.getSecondProperty(); + OWLObject first, second; + if (isFocusedObject(o1) || !isFocusedObject(o2)) { + first = o1; + second = o2; + } else { + first = o2; + second = o1; + } + first.accept(this); + writeSpace(); + write(EQUIVALENT_TO); + writeSpace(); + second.accept(this); + write(INVERSE); + } + + @Override + public void visit(SWRLRule rule) { + write(rule.getHead(), WEDGE, false); + writeSpace(); + write(IMPLIES); + writeSpace(); + write(rule.getBody(), WEDGE, false); + } + + @Override + public void visit(OWLClass desc) { + if (desc.isOWLThing()) { + write(TOP); + } else if (desc.isOWLNothing()) { + write(BOTTOM); + } else { + writeEntity(desc); + } + } + + @Override + public void visit(OWLObjectIntersectionOf desc) { + write(desc.getOperands(), AND, true); + } + + @Override + public void visit(OWLObjectUnionOf desc) { + write(desc.getOperands(), OR, true); + } + + @Override + public void visit(OWLObjectComplementOf desc) { + write(NOT); + writeNested(desc.getOperand()); + } + + private void writeCardinalityRestriction(OWLDataCardinalityRestriction restriction, DLSyntax keyword) { + write(keyword); + writeSpace(); + write(restriction.getCardinality()); + writeSpace(); + restriction.getProperty().accept(this); + // if (restriction.isQualified()) { + writeRestrictionSeparator(); + writeNested(restriction.getFiller()); + // } + } + + private void writeCardinalityRestriction(OWLObjectCardinalityRestriction restriction, DLSyntax keyword) { + write(keyword); + writeSpace(); + write(restriction.getCardinality()); + writeSpace(); + restriction.getProperty().accept(this); + // if (restriction.isQualified()) { + writeRestrictionSeparator(); + writeNested(restriction.getFiller()); + // } + } + + private void writeQuantifiedRestriction(OWLQuantifiedDataRestriction restriction, DLSyntax keyword) { + write(keyword); + writeSpace(); + restriction.getProperty().accept(this); + writeRestrictionSeparator(); + writeNested(restriction.getFiller()); + } + + private void writeQuantifiedRestriction(OWLQuantifiedObjectRestriction restriction, DLSyntax keyword) { + write(keyword); + writeSpace(); + restriction.getProperty().accept(this); + writeRestrictionSeparator(); + writeNested(restriction.getFiller()); + } + + @Override + public void visit(OWLObjectSomeValuesFrom desc) { + writeQuantifiedRestriction(desc, EXISTS); + } + + @Override + public void visit(OWLObjectAllValuesFrom desc) { + writeQuantifiedRestriction(desc, FORALL); + } + + private <R extends OWLPropertyRange, P extends OWLPropertyExpression<R, P>, V extends OWLObject> void writeValueRestriction( + OWLHasValueRestriction<R, P, V> restriction) { + write(EXISTS); + writeSpace(); + restriction.getProperty().accept(this); + writeRestrictionSeparator(); + write("{"); + restriction.getValue().accept(this); + write("}"); + } + + @Override + public void visit(OWLObjectHasValue desc) { + writeValueRestriction(desc); + } + + @Override + public void visit(OWLObjectMinCardinality desc) { + writeCardinalityRestriction(desc, MIN); + } + + @Override + public void visit(OWLObjectExactCardinality desc) { + writeCardinalityRestriction(desc, EQUAL); + } + + @Override + public void visit(OWLObjectMaxCardinality desc) { + writeCardinalityRestriction(desc, MAX); + } + + @Override + public void visit(OWLObjectHasSelf desc) { + write(EXISTS); + writeSpace(); + desc.getProperty().accept(this); + write(" ."); + write(SELF); + } + + @Override + public void visit(OWLObjectOneOf desc) { + for (Iterator<OWLIndividual> it = desc.getIndividuals().iterator(); it.hasNext();) { + write("{"); + it.next().accept(this); + write("}"); + if (it.hasNext()) { + write(" "); + write(OR); + write(" "); + } + } + } + + @Override + public void visit(OWLDataSomeValuesFrom desc) { + writeQuantifiedRestriction(desc, EXISTS); + } + + @Override + public void visit(OWLDataAllValuesFrom desc) { + writeQuantifiedRestriction(desc, FORALL); + } + + @Override + public void visit(OWLDataHasValue desc) { + writeValueRestriction(desc); + } + + @Override + public void visit(OWLDataMinCardinality desc) { + writeCardinalityRestriction(desc, MIN); + } + + @Override + public void visit(OWLDataExactCardinality desc) { + writeCardinalityRestriction(desc, EQUAL); + } + + @Override + public void visit(OWLDataMaxCardinality desc) { + writeCardinalityRestriction(desc, MAX); + } + + // ///////////////////////////////////////////////////////////////////////////////////////////// + // + // Data stuff + // + // ///////////////////////////////////////////////////////////////////////////////////////////// + + public void visit(OWLDataIntersectionOf node) { + write("("); + write(node.getOperands(), AND, false); + write(")"); + } + + public void visit(OWLDataUnionOf node) { + write("("); + write(node.getOperands(), OR, false); + write(")"); + } + + public void visit(OWLDatatypeRestriction node) { + node.getDatatype().accept(this); + write("["); + for (OWLFacetRestriction facetRestriction : node.getFacetRestrictions()) { + facetRestriction.accept(this); + write(" " + FACET_RESTRICTION_SEPARATOR.toString() + " "); + } + write("]"); + } + + public void visit(OWLFacetRestriction node) { + write(node.getFacet().getSymbolicForm()); + writeSpace(); + node.getFacetValue().accept(this); + } + + @Override + public void visit(OWLDatatype node) { + write(shortFormProvider.getShortForm(node)); + } + + @Override + public void visit(OWLDataComplementOf node) { + write(NOT); + node.getDataRange().accept(this); + } + + @Override + public void visit(OWLDataOneOf node) { + for (Iterator<OWLLiteral> it = node.getValues().iterator(); it.hasNext();) { + write("{"); + it.next().accept(this); + write("}"); + if (it.hasNext()) { + write(OR); + } + } + } + + @Override + public void visit(OWLLiteral node) { + write(node.getLiteral()); + } + + @Override + public void visit(OWLObjectProperty property) { + writeEntity(property); + } + + @Override + public void visit(OWLObjectInverseOf property) { + property.getInverse().accept(this); + write(INVERSE); + } + + @Override + public void visit(OWLDataProperty property) { + writeEntity(property); + } + + @Override + public void visit(OWLNamedIndividual individual) { + writeEntity(individual); + } + + @Override + public void visit(OWLDatatypeDefinitionAxiom axiom) { + } + + @Override + public void visit(OWLHasKeyAxiom axiom) { + } + + @Override + public void visit(OWLAnnotationPropertyDomainAxiom axiom) { + } + + @Override + public void visit(OWLAnnotationPropertyRangeAxiom axiom) { + } + + @Override + public void visit(OWLSubAnnotationPropertyOfAxiom axiom) { + } + + @Override + public void visit(OWLAnnotationProperty property) { + } + + @Override + public void visit(OWLAnonymousIndividual individual) { + } + + @Override + public void visit(IRI iri) { + } + + @Override + public void visit(OWLAnnotation node) { + } + + @Override + public void visit(SWRLClassAtom node) { + node.getPredicate().accept(this); + write("("); + node.getArgument().accept(this); + write(")"); + } + + @Override + public void visit(SWRLDataRangeAtom node) { + node.getPredicate().accept(this); + write("("); + node.getArgument().accept(this); + write(")"); + } + + @Override + public void visit(SWRLObjectPropertyAtom node) { + node.getPredicate().accept(this); + write("("); + node.getFirstArgument().accept(this); + write(", "); + node.getSecondArgument().accept(this); + write(")"); + } + + @Override + public void visit(SWRLDataPropertyAtom node) { + node.getPredicate().accept(this); + write("("); + node.getFirstArgument().accept(this); + write(", "); + node.getSecondArgument().accept(this); + write(")"); + } + + @Override + public void visit(SWRLBuiltInAtom node) { + write(node.getPredicate().toString()); + write("("); + write(node.getArguments(), COMMA, true); + write(")"); + } + + @Override + public void visit(SWRLVariable node) { + write("?"); + write(iriShortFormProvider.getShortForm(node.getIRI())); + } + + @Override + public void visit(SWRLIndividualArgument node) { + node.getIndividual().accept(this); + } + + @Override + public void visit(SWRLLiteralArgument node) { + node.getLiteral().accept(this); + } + + @Override + public void visit(SWRLSameIndividualAtom node) { + write("sameAs("); + node.getFirstArgument().accept(this); + write(", "); + node.getSecondArgument().accept(this); + write(")"); + } + + @Override + public void visit(SWRLDifferentIndividualsAtom node) { + write("differentFrom("); + node.getFirstArgument().accept(this); + write(", "); + node.getSecondArgument().accept(this); + write(")"); + } +} Added: trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/test/PunningTest.java 2014-07-29 13:55:31 UTC (rev 4281) @@ -0,0 +1,155 @@ +/** + * + */ +package org.dllearner.test; + +import java.io.ByteArrayInputStream; +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.core.AbstractCELA; +import org.dllearner.core.AbstractLearningProblem; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.owl.Individual; +import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.owl.OWLAPIConverter; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; +import org.junit.Assert; +import org.junit.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLIndividual; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLObjectProperty; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + +import com.google.common.collect.Sets; + +/** + * @author Lorenz Buehmann + * + */ +public class PunningTest { + + + public OWLOntology makeExampleKB() throws OWLOntologyCreationException{ + String kb = "@prefix owl:<http://www.w3.org/2002/07/owl#> . @prefix :<http://foo.org/> ."; + kb += ":p a owl:ObjectProperty ."; + + for (int i = 1; i <= 5; i++) { + kb += ":r" + i + " a owl:ObjectProperty ."; + } + + kb += ":A a owl:Class; :r1 :o1; :r2 :o2 ."; + kb += ":B a owl:Class; :r1 :o3; :r3 :o2 ."; + + for (int i = 1; i <= 10; i++) { + kb += ":x" + i + " a owl:NamedIndividual ."; + } + + int m = 5; + int n = 5; + + //m instances of A + for (int i = 1; i <= m; i++) { + kb += ":x" + i + " a :A ."; + } + + //n instances of B + for (int i = 1; i <= n; i++) { + kb += ":x" + i + " a :A ."; + } + + OWLOntology ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(new ByteArrayInputStream(kb.getBytes())); + return ontology; + } + + public OWLOntology loadExample() throws OWLOntologyCreationException{ + OWLOntology ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(this.getClass().getClassLoader().getResourceAsStream("punning_example.ttl")); + return ontology; + } + + @Test + public void testPunning() throws OWLOntologyCreationException, ComponentInitException{ + OWLOntology ontology = makeExampleKB(); + OWLDataFactory df = new OWLDataFactoryImpl(); + + //check that A and B are both, individual and class + OWLClass clsA = df.getOWLClass(IRI.create("http://foo.org/A")); + OWLClass clsB = df.getOWLClass(IRI.create("http://foo.org/B")); + OWLIndividual indA = df.getOWLNamedIndividual(IRI.create("http://foo.org/A")); + OWLIndividual indB = df.getOWLNamedIndividual(IRI.create("http://foo.org/B")); + + Set<OWLClass> classes = ontology.getClassesInSignature(); + Set<OWLObjectProperty> properties = ontology.getObjectPropertiesInSignature(); + Set<OWLNamedIndividual> individuals = ontology.getIndividualsInSignature(); + + System.out.println("Classes:" + classes); + System.out.println("Properties:" + properties); + System.out.println("Individuals:" + individuals); + + Assert.assertTrue( + ontology.getClassesInSignature().contains(clsA) && + ontology.getClassesInSignature().contains(clsB) && + ontology.getIndividualsInSignature().contains(indA) && + ontology.getIndividualsInSignature().contains(indB) + ); + + KnowledgeSource ks = new OWLAPIOntology(ontology); + ks.init(); + + AbstractReasonerComponent rc = new FastInstanceChecker(ks); + rc.init(); + + AbstractLearningProblem lp = new PosNegLPStandard(rc); + lp.init(); + + AbstractCELA la = new CELOE(lp, rc); + la.init(); + + la.start(); + } + + @Test + public void testPunning2() throws OWLOntologyCreationException, ComponentInitException{ + OWLOntology ontology = loadExample(); + OWLDataFactory df = new OWLDataFactoryImpl(); + + //check that A and B are both, individual and class + Set<Individual> posExamples = new HashSet<Individual>(); + for (String uri : Sets.newHashSet("http://ex.org/TRABANT601#1234", "http://ex.org/S51#2345", "http://ex.org/MIFA23#3456")) { + posExamples.add(new Individual(uri)); + } + Set<Individual> negExamples = new HashSet<Individual>(); + for (String uri : Sets.newHashSet("http://ex.org/CLIPSO90MG#4567", "http://ex.org/SIEMENS425#567", "http://ex.org/TATRAT3#678")) { + negExamples.add(new Individual(uri)); + } + + KnowledgeSource ks = new OWLAPIOntology(ontology); + ks.init(); + + AbstractReasonerComponent rc = new FastInstanceChecker(ks); + rc.init(); + + PosNegLPStandard lp = new PosNegLPStandard(rc); + lp.setPositiveExamples(posExamples); + lp.setNegativeExamples(negExamples); + lp.init(); + + AbstractCELA la = new CELOE(lp, rc); + la.init(); + + la.start(); + } + +} Added: trunk/components-core/src/test/java/org/dllearner/test/junit/PunningTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/junit/PunningTest.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/test/junit/PunningTest.java 2014-07-29 13:55:31 UTC (rev 4281) @@ -0,0 +1,64 @@ +/** + * + */ +package org.dllearner.test.junit; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; + +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.reasoning.FastInstanceChecker; +import org.junit.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLNamedIndividual; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import com.hp.hpl.jena.rdf.model.ModelFactory; + +/** + * @author Lorenz Buehmann + * + */ +public class PunningTest { + + @Test + public void test() throws Exception { + String triples = "@prefix owl:<http://www.w3.org/2002/07/owl#> . @prefix : <http://other.example.org/ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ." + + ":A a owl:NamedIndividual. :A a owl:Class. :A a :B . :B rdfs:subClassOf :A ."; + System.out.println(triples); + ModelFactory.createDefaultModel().read(new ByteArrayInputStream(triples.getBytes()), null, "TURTLE"); + + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory df = man.getOWLDataFactory(); + OWLOntology ontology = man.loadOntologyFromOntologyDocument(new ByteArrayInputStream(triples.getBytes())); + System.out.println(ontology.getIndividualsInSignature()); + System.out.println(ontology.getClassesInSignature()); + OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance(); + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(ontology); + OWLClass c = df.getOWLClass(IRI.create("http://other.example.org/ns#A")); + OWLNamedIndividual i = df.getOWLNamedIndividual(IRI.create("http://other.example.org/ns#A")); + System.out.println(reasoner.getInstances(c, false)); + KnowledgeSource ks = new OWLAPIOntology(ontology); + AbstractReasonerComponent rc = new FastInstanceChecker(ks); + rc.init(); + NamedClass cls = new NamedClass("http://other.example.org/ns#A"); + System.out.println(rc.getIndividuals(cls)); + Individual ind = new Individual("http://other.example.org/ns#A"); + System.out.println(rc.hasType(cls, ind)); + } + +} Added: trunk/components-core/src/test/resources/log4j.properties =================================================================== --- trunk/components-core/src/test/resources/log4j.properties (rev 0) +++ trunk/components-core/src/test/resources/log4j.properties 2014-07-29 13:55:31 UTC (rev 4281) @@ -0,0 +1,20 @@ +# Direct log messages to stdout +# Root logger option +log4j.rootLogger=INFO,stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +#log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %p [%c] %L - %m%n +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} [%c] - %m%n + +#File Appender +log4j.appender.FA=org.apache.log4j.FileAppender +log4j.appender.FA.File=REX.log +log4j.appender.FA.layout=org.apache.log4j.PatternLayout +log4j.appender.FA.layout.ConversionPattern=%d{ABSOLUTE} %p [%c] %L - %m%n + + +log4j.category.org.dllearner.algorithms=INFO +log4j.category.org.dllearner.algorithms.isle=DEBUG +log4j.category.org.dllearner.algorithms.qtl=INFO +log4j.category.org.dllearner.algorithms.qtl.lgg=INFO Property changes on: trunk/components-core/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/components-core/src/test/resources/punning_example.ttl =================================================================== --- trunk/components-core/src/test/resources/punning_example.ttl (rev 0) +++ trunk/components-core/src/test/resources/punning_example.ttl 2014-07-29 13:55:31 UTC (rev 4281) @@ -0,0 +1,67 @@ +#Solution \exists bereifung.\top \sqcap Fahrzeug + +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix ex: <http://ex.org/> . + +ex:Gummireifen a owl:Class . +ex:bereifung a owl:ObjectProperty . + +ex:Transporthilfe a owl:Class . + +ex:Schubkarre + a owl:Class ; + rdfs:subClassOf ex:Transporthilfe . + +ex:Fahrzeug a owl:Class . +ex:Fahrzeug owl:disjointWith ex:Transporthilfe . + +ex:Tram + a owl:Class ; + rdfs:subClassOf ex:Fahrzeug . + +ex:Bahn + a owl:Class ; + rdfs:subClassOf ex:Fahrzeug . + +ex:Auto + a owl:Class ; + rdfs:subClassOf ex:Fahrzeug . + +ex:Moped + a owl:Class ; + rdfs:subClassOf ex:Fahrzeug . + +ex:Fahrrad + a owl:Class ; + rdfs:subClassOf ex:Fahrzeug . + +ex:BRIDGESTONE_XYZ a ex:Gummireifen . +ex:PNEUMANT_4711 a ex:Gummireifen . +ex:HEIDENAU_K36 a ex:Gummireifen . +ex:DEMA_ABC23 a ex:Gummireifen . + +ex:Auto ex:bereifung ex:BRIDGESTONE_XYZ . +ex:Moped ex:bereifung ex:HEIDENAU_K36 . +ex:Fahrrad ex:bereifung ex:PNEUMANT_4711 . +ex:Schubkarre ex:bereifung ex:DEMA_ABC23 . + +# positive individuals +<http://ex.org/TRABANT601#1234> a ex:Auto . +<http://ex.org/S51#2345> a ex:Moped . +<http://ex.org/MIFA23#3456> a ex:Fahrrad . + +# negative individuals +<http://ex.org/CLIPSO90MG#4567> a ex:Schubkarre . +<http://ex.org/SIEMENS425#567> a ex:Bahn . +<http://ex.org/TATRAT3#678> a ex:Tram . + +# punning workaround +ex:p a owl:ObjectProperty . +<http://ex.org/TRABANT601#1234> ex:p ex:Auto . +<http://ex.org/S51#2345> ex:p ex:Moped . +<http://ex.org/MIFA23#3456> ex:p ex:Fahrrad . +<http://ex.org/CLIPSO90MG#4567> ex:p ex:Schubkarre . +<http://ex.org/SIEMENS425#567> ex:p ex:Bahn . +<http://ex.org/TATRAT3#678> ex:p ex:Tram . \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-07-29 13:53:27
|
Revision: 4280 http://sourceforge.net/p/dl-learner/code/4280 Author: lorenz_b Date: 2014-07-29 13:53:19 +0000 (Tue, 29 Jul 2014) Log Message: ----------- Added punning test. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java trunk/components-core/src/main/java/org/dllearner/core/owl/Constant.java trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/ConceptComparator.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLAPIDescriptionConvertVisitor.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/RoleComparator.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestCorpus.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETestNoCorpus.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/metrics/PMIRelevanceMetricTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/metrics/RelevanceMetricsTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/pattern/OWLPatternDetectionTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/GeneralisationTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QTLTest.java trunk/components-core/src/test/java/org/dllearner/test/junit/SomeOnlyReasonerTest.java trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java trunk/pom.xml trunk/scripts/pom.xml trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java trunk/scripts/src/main/java/org/dllearner/scripts/pattern/OWLAxiomPatternUsageEvaluation.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/pom.xml 2014-07-29 13:53:19 UTC (rev 4280) @@ -100,10 +100,10 @@ <artifactId>mysql-connector-java</artifactId> </dependency> - <dependency> + <!-- <dependency> <groupId>net.sourceforge.owlapi</groupId> <artifactId>owlapi-distribution</artifactId> - </dependency> + </dependency> --> <dependency> <groupId>com.clarkparsia</groupId> @@ -152,10 +152,6 @@ <artifactId>hermit</artifactId> </dependency> - <dependency> - <groupId>eu.trowl</groupId> - <artifactId>trowl-core</artifactId> - </dependency> <dependency> <groupId>com.jamonapi</groupId> @@ -249,6 +245,11 @@ <artifactId>jsexp</artifactId> <version>0.1.0</version> </dependency> + <dependency> + <groupId>eu.trowl</groupId> + <artifactId>trowl-core</artifactId> + <version>1.4.0</version> + </dependency> <dependency> <groupId>xerces</groupId> @@ -334,6 +335,16 @@ <artifactId>solr-solrj</artifactId> <version>4.4.0</version> </dependency> + <dependency> + <groupId>nz.ac.waikato.cms.weka</groupId> + <artifactId>weka-dev</artifactId> + <version>3.7.11</version> +</dependency> + <!-- <dependency> + <groupId>nz.ac.waikato.cms.weka</groupId> + <artifactId>weka-stable</artifactId> + <version>3.6.9</version> + </dependency> --> </dependencies> <dependencyManagement> <dependencies> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -32,7 +32,6 @@ import java.util.TreeSet; import org.apache.log4j.Logger; -import org.dllearner.algorithms.elcopy.ELLearningAlgorithm; import org.dllearner.core.AbstractCELA; import org.dllearner.core.AbstractHeuristic; import org.dllearner.core.AbstractKnowledgeSource; @@ -50,7 +49,6 @@ import org.dllearner.core.owl.Restriction; import org.dllearner.core.owl.Thing; import org.dllearner.kb.OWLAPIOntology; -import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyLP; @@ -92,7 +90,7 @@ * */ @ComponentAnn(name="CELOE", shortName="celoe", version=1.0, description="CELOE is an adapted and extended version of the OCEL algorithm applied for the ontology engineering use case. See http://jens-lehmann.org/files/2011/celoe.pdf for reference.") -public class CELOE extends AbstractCELA { +public class CELOE extends AbstractCELA implements Cloneable{ private static Logger logger = Logger.getLogger(CELOE.class); // private CELOEConfigurator configurator; @@ -224,6 +222,39 @@ } + public CELOE(CELOE celoe){ + setReasoner(celoe.reasoner); + setLearningProblem(celoe.learningProblem); + setAllowedConcepts(celoe.getAllowedConcepts()); + setExpandAccuracy100Nodes(celoe.expandAccuracy100Nodes); + setFilterDescriptionsFollowingFromKB(celoe.filterDescriptionsFollowingFromKB); + setHeuristic(celoe.heuristic); + setIgnoredConcepts(celoe.ignoredConcepts); + setLearningProblem(celoe.learningProblem); + setMaxClassExpressionTests(celoe.maxClassExpressionTests); + setMaxClassExpressionTestsAfterImprovement(celoe.maxClassExpressionTestsAfterImprovement); + setMaxDepth(celoe.maxDepth); + setMaxExecutionTimeInSeconds(celoe.maxExecutionTimeInSeconds); + setMaxExecutionTimeInSecondsAfterImprovement(celoe.maxExecutionTimeInSecondsAfterImprovement); + setMaxNrOfResults(celoe.maxNrOfResults); + setNoisePercentage(celoe.noisePercentage); + RhoDRDown op = new RhoDRDown((RhoDRDown)celoe.operator); + try { + op.init(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + setOperator(op); + setReplaceSearchTree(celoe.replaceSearchTree); + setReuseExistingDescription(celoe.reuseExistingDescription); + setSingleSuggestionMode(celoe.singleSuggestionMode); + setStartClass(celoe.startClass); + setStopOnFirstDefinition(celoe.stopOnFirstDefinition); + setTerminateOnNoiseReached(celoe.terminateOnNoiseReached); + setUseMinimizer(celoe.useMinimizer); + setWriteSearchTree(celoe.writeSearchTree); + } + public CELOE(AbstractLearningProblem problem, AbstractReasonerComponent reasoner) { super(problem, reasoner); // configurator = new CELOEConfigurator(this); @@ -529,7 +560,7 @@ treeString += " " + n + "\n"; } } - treeString += startNode.toTreeString(baseURI); + treeString += startNode.toTreeString(baseURI, prefixes); treeString += "\n"; if (replaceSearchTree) @@ -1134,6 +1165,14 @@ public void setExpandAccuracy100Nodes(boolean expandAccuracy100Nodes) { this.expandAccuracy100Nodes = expandAccuracy100Nodes; } + + /* (non-Javadoc) + * @see java.lang.Object#clone() + */ + @Override + public Object clone() throws CloneNotSupportedException { + return new CELOE(this); + } public static void main(String[] args) throws Exception{ String cls = "http://purl.org/procurement/public-contracts#Tender"; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/OENode.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -22,6 +22,7 @@ import java.text.DecimalFormat; import java.util.LinkedList; import java.util.List; +import java.util.Map; import org.dllearner.algorithms.SearchTreeNode; import org.dllearner.algorithms.isle.NLPHeuristic; @@ -119,7 +120,11 @@ } public String getShortDescription(String baseURI) { - String ret = description.toString(baseURI,null) + " ["; + return getShortDescription(baseURI, null); + } + + public String getShortDescription(String baseURI, Map<String, String> prefixes) { + String ret = description.toString(baseURI,prefixes) + " ["; // ret += "score" + NLPHeuristic.getNodeScore(this) + ","; ret += "acc:" + dfPercent.format(accuracy) + ", "; ret += "he:" + horizontalExpansion + ", "; @@ -141,6 +146,10 @@ return toTreeString(0, baseURI).toString(); } + public String toTreeString(String baseURI, Map<String, String> prefixes) { + return toTreeString(0, baseURI, prefixes).toString(); + } + private StringBuilder toTreeString(int depth, String baseURI) { StringBuilder treeString = new StringBuilder(); for(int i=0; i<depth-1; i++) @@ -153,6 +162,19 @@ } return treeString; } + + private StringBuilder toTreeString(int depth, String baseURI, Map<String, String> prefixes) { + StringBuilder treeString = new StringBuilder(); + for(int i=0; i<depth-1; i++) + treeString.append(" "); + if(depth!=0) + treeString.append("|--> "); + treeString.append(getShortDescription(baseURI, prefixes)+"\n"); + for(OENode child : children) { + treeString.append(child.toTreeString(depth+1,baseURI,prefixes)); + } + return treeString; + } /** * @return the refinementCount @@ -166,5 +188,5 @@ */ public void setRefinementCount(int refinementCount) { this.refinementCount = refinementCount; - } + } } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -202,7 +202,7 @@ public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { EvaluatedQueryTree<String> bestSolution = solutions.first(); Description description = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( - bestSolution.getTree().asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION)); + bestSolution.getTree().asOWLClassExpression(LiteralNodeConversionStrategy.MIN_MAX)); return new EvaluatedDescription(description, new AxiomScore(bestSolution.getScore())); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -19,7 +19,6 @@ import org.apache.log4j.Logger; import org.dllearner.algorithms.qtl.cache.QueryTreeCache; import org.dllearner.algorithms.qtl.datastructures.QueryTree; -import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.LiteralNodeConversionStrategy; import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.LiteralNodeSubsumptionStrategy; import org.dllearner.algorithms.qtl.operations.lgg.EvaluatedQueryTree; @@ -42,8 +41,10 @@ import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.QueryTreeScore; import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; +import org.dllearner.utilities.owl.DLSyntaxObjectRenderer; import org.dllearner.utilities.owl.OWLAPIConverter; import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.OWLClassExpression; import org.semanticweb.owlapi.util.SimpleShortFormProvider; import org.springframework.beans.factory.annotation.Autowired; @@ -75,6 +76,7 @@ private Set<Individual> currentNegExamples; private Map<QueryTree<String>, Individual> tree2Individual; + private Map<Individual, QueryTree<String>> individual2Tree; private QueryTreeCache treeCache; @@ -121,7 +123,15 @@ private long partialSolutionStartTime; private double startPosExamplesSize; + private int expressionTests = 0; + LiteralNodeConversionStrategy[] strategies = new LiteralNodeConversionStrategy[]{ + LiteralNodeConversionStrategy.MIN, + LiteralNodeConversionStrategy.MAX, + LiteralNodeConversionStrategy.MIN_MAX, + LiteralNodeConversionStrategy.DATATYPE + }; + public QTL2Disjunctive() {} public QTL2Disjunctive(PosNegLP learningProblem, AbstractReasonerComponent reasoner) throws LearningProblemUnsupportedException{ @@ -154,7 +164,7 @@ */ @Override public void init() throws ComponentInitException { - + ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); if(!(learningProblem instanceof PosNegLP)){ throw new IllegalArgumentException("Only PosNeg learning problems are supported"); } @@ -170,6 +180,7 @@ logger.info("Initializing..."); treeCache = new QueryTreeCache(model); tree2Individual = new HashMap<QueryTree<String>, Individual>(lp.getPositiveExamples().size()+lp.getNegativeExamples().size()); + individual2Tree = new HashMap<Individual, QueryTree<String>>(lp.getPositiveExamples().size()+lp.getNegativeExamples().size()); currentPosExampleTrees = new ArrayList<QueryTree<String>>(lp.getPositiveExamples().size()); currentNegExampleTrees = new ArrayList<QueryTree<String>>(lp.getNegativeExamples().size()); @@ -205,11 +216,13 @@ for (Individual ind : lp.getPositiveExamples()) { queryTree = treeCache.getQueryTree(ind.getName()); tree2Individual.put(queryTree, ind); + individual2Tree.put(ind, queryTree); currentPosExampleTrees.add(queryTree); } for (Individual ind : lp.getNegativeExamples()) { queryTree = treeCache.getQueryTree(ind.getName()); tree2Individual.put(queryTree, ind); + individual2Tree.put(ind, queryTree); currentNegExampleTrees.add(queryTree); } logger.info("...done."); @@ -235,7 +248,7 @@ //compute best (partial) solution computed so far EvaluatedQueryTree<String> bestPartialSolution = computeBestPartialSolution(); - //add if some criteria are satisfied + //add to partial solutions if criteria are satisfied if(bestPartialSolution.getScore() >= minimumTreeScore){ partialSolutions.add(bestPartialSolution); @@ -244,14 +257,14 @@ QueryTree<String> tree; for (Iterator<QueryTree<String>> iterator = currentPosExampleTrees.iterator(); iterator.hasNext();) { tree = iterator.next(); - if(tree.isSubsumedBy(bestPartialSolution.getTree())){ + if(!bestPartialSolution.getFalseNegatives().contains(tree)){//a pos tree that is not covered iterator.remove(); currentPosExamples.remove(tree2Individual.get(tree)); } } for (Iterator<QueryTree<String>> iterator = currentNegExampleTrees.iterator(); iterator.hasNext();) { tree = iterator.next(); - if(tree.isSubsumedBy(bestPartialSolution.getTree())){ + if(bestPartialSolution.getFalsePositives().contains(tree)){//a neg example that is covered iterator.remove(); currentNegExamples.remove(tree2Individual.get(tree)); } @@ -272,8 +285,9 @@ long endTime = System.currentTimeMillis(); logger.info("Finished in " + (endTime-startTime) + "ms."); + logger.info(expressionTests +" descriptions tested"); + logger.info("Combined solution:" + OWLAPIConverter.getOWLAPIDescription(currentBestSolution.getDescription()).toString().replace("\n", "")); - logger.info("Combined solution:" + OWLAPIConverter.getOWLAPIDescription(currentBestSolution.getDescription()).toString().replace("\n", "")); logger.info(currentBestSolution.getScore()); } @@ -291,7 +305,9 @@ logger.trace("TODO list size: " + todoList.size()); //pick best element from todo list currentElement = todoList.poll(); + currentTree = currentElement.getTree(); + logger.info("Next tree: " + currentElement.getTreeScore() + "\n" + OWLAPIConverter.getOWLAPIDescription(currentElement.getEvaluatedDescription().getDescription())); //generate the LGG between the chosen tree and each uncovered positive example Iterator<QueryTree<String>> it = currentElement.getFalseNegatives().iterator(); while (it.hasNext() && !isPartialSolutionTimeExpired() && !isTimeExpired()) { @@ -302,26 +318,29 @@ lggMon.stop(); //evaluate the LGG - Set<EvaluatedQueryTree<String>> solutions = evaluate(lgg, true); + Set<EvaluatedQueryTree<String>> solutions = evaluate2(lgg, true); for (EvaluatedQueryTree<String> solution : solutions) { + expressionTests++; double score = solution.getScore(); double mas = heuristic.getMaximumAchievableScore(solution); if(score >= bestCurrentScore){ - //add to todo list, if not already contained in todo list or solution list - todo(solution); if(score > bestCurrentScore){ logger.info("\tGot better solution:" + solution.getTreeScore()); + logger.info(OWLAPIConverter.getOWLAPIDescription(solution.getEvaluatedDescription().getDescription())); bestCurrentScore = score; bestPartialSolutionTree = solution; } - + //add to todo list, if not already contained in todo list or solution list + todo(solution); } else if(mas >= bestCurrentScore){ todo(solution); } else { + logger.info("Too weak:" + solution.getTreeScore()); // System.out.println("Too general"); // System.out.println("MAS=" + mas + "\nBest=" + bestCurrentScore); } + currentPartialSolutions.add(currentElement); } } @@ -329,7 +348,7 @@ } long endTime = System.currentTimeMillis(); logger.info("...finished in " + (endTime-partialSolutionStartTime) + "ms."); - EvaluatedDescription bestPartialSolution = bestPartialSolutionTree.asEvaluatedDescription(LiteralNodeConversionStrategy.SOME_VALUES_FROM); + EvaluatedDescription bestPartialSolution = bestPartialSolutionTree.getEvaluatedDescription(); logger.info("Best partial solution: " + OWLAPIConverter.getOWLAPIDescription(bestPartialSolution.getDescription()).toString().replace("\n", "") + "\n(" + bestPartialSolution.getScore() + ")"); @@ -410,7 +429,12 @@ Set<EvaluatedQueryTree<String>> evaluatedTrees = new TreeSet<EvaluatedQueryTree<String>>(); LiteralNodeSubsumptionStrategy[] strategies = LiteralNodeSubsumptionStrategy.values(); - strategies = new LiteralNodeSubsumptionStrategy[]{LiteralNodeSubsumptionStrategy.DATATYPE, LiteralNodeSubsumptionStrategy.INTERVAL}; + strategies = new LiteralNodeSubsumptionStrategy[]{ + LiteralNodeSubsumptionStrategy.DATATYPE, + LiteralNodeSubsumptionStrategy.INTERVAL, + LiteralNodeSubsumptionStrategy.MIN, + LiteralNodeSubsumptionStrategy.MAX, + }; for (LiteralNodeSubsumptionStrategy strategy : strategies) { //1. get a score for the coverage = recall oriented List<QueryTree<String>> uncoveredPositiveExampleTrees = new ArrayList<QueryTree<String>>(); @@ -480,18 +504,27 @@ * @param useSpecifity * @return */ - private Set<EvaluatedDescription> evaluate2(QueryTree<String> tree, boolean useSpecifity){ - Set<EvaluatedDescription> evaluatedDescriptions = new TreeSet<EvaluatedDescription>(); + private Set<EvaluatedQueryTree<String>> evaluate2(QueryTree<String> tree, boolean useSpecifity){ + Set<EvaluatedQueryTree<String>> evaluatedTrees = new TreeSet<EvaluatedQueryTree<String>>(); - LiteralNodeConversionStrategy[] strategies = LiteralNodeConversionStrategy.values(); - strategies = new LiteralNodeConversionStrategy[]{LiteralNodeConversionStrategy.SOME_VALUES_FROM, LiteralNodeConversionStrategy.FACET_RESTRICTION}; + //test different strategies on the conversion of literal nodes + Set<OWLClassExpression> combinations = new HashSet<OWLClassExpression>(); + for (LiteralNodeConversionStrategy strategy : strategies) { - Description d = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(tree.asOWLClassExpression(strategy)); + OWLClassExpression ce = tree.asOWLClassExpression(strategy); + combinations.add(ce); + } + //compute all combinations of different types of facets +// OWLClassExpression ce = tree.asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION); +// combinations = ce.accept(new ClassExpressionLiteralCombination()); + for (OWLClassExpression c : combinations) { + Description d = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(c); //convert to individuals SortedSet<Individual> coveredExamples = reasoner.getIndividuals(d); Set<Individual> coveredPosExamples = new TreeSet<Individual>(Sets.intersection(currentPosExamples, coveredExamples)); Set<Individual> uncoveredPosExamples = new TreeSet<Individual>(Sets.difference(currentPosExamples, coveredExamples)); Set<Individual> coveredNegExamples = new TreeSet<Individual>(Sets.intersection(currentNegExamples, coveredExamples)); + Set<Individual> uncoveredNegExamples = new TreeSet<Individual>(Sets.difference(currentNegExamples, coveredExamples)); //compute score double recall = coveredPosExamples.size() / (double)currentPosExamples.size(); @@ -501,7 +534,7 @@ double coverageScore = Heuristics.getFScore(recall, precision, beta); - //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented + //2. get a score for the specificity of the query, i.e. how many edges/nodes = precision oriented int nrOfSpecificNodes = 0; for (QueryTree<String> childNode : tree.getChildrenClosure()) { if(!childNode.getUserObject().equals("?")){ @@ -516,33 +549,38 @@ //3.compute the total score double score = coverageWeight * coverageScore + specifityWeight * specifityScore; - QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, - new TreeSet<Individual>(Sets.difference(currentPosExamples, uncoveredPosExamples)), uncoveredPosExamples, - coveredNegExamples, new TreeSet<Individual>(Sets.difference(currentNegExamples, coveredNegExamples)), + QueryTreeScore queryTreeScore = new QueryTreeScore( + score, coverageScore, + coveredPosExamples, uncoveredPosExamples, + coveredNegExamples, uncoveredNegExamples, specifityScore, nrOfSpecificNodes); //TODO use only the heuristic to compute the score -// score = heuristic.getScore(evaluatedTree); -// queryTreeScore.setScore(score); -// queryTreeScore.setAccuracy(score); -// -// EvaluatedDescription evaluatedDescription = new EvaluatedDescription(d, queryTreeScore); -// -// evaluatedDescriptions.add(evaluatedDescription); + EvaluatedQueryTree<String> evaluatedTree = new EvaluatedQueryTree<String>(tree, + asQueryTrees(uncoveredPosExamples), asQueryTrees(coveredNegExamples), queryTreeScore); + score = heuristic.getScore(evaluatedTree); + queryTreeScore.setScore(score); + queryTreeScore.setAccuracy(score); + + + EvaluatedDescription evaluatedDescription = new EvaluatedDescription(d, queryTreeScore); + + evaluatedTree.setDescription(evaluatedDescription); + + evaluatedTrees.add(evaluatedTree); } - - return evaluatedDescriptions; + return evaluatedTrees; } private EvaluatedDescription buildCombinedSolution(){ EvaluatedDescription bestCombinedSolution = null; double bestScore = Double.NEGATIVE_INFINITY; LiteralNodeConversionStrategy[] strategies = LiteralNodeConversionStrategy.values(); - strategies = new LiteralNodeConversionStrategy[]{LiteralNodeConversionStrategy.SOME_VALUES_FROM}; + strategies = new LiteralNodeConversionStrategy[]{LiteralNodeConversionStrategy.DATATYPE}; for (LiteralNodeConversionStrategy strategy : strategies) { EvaluatedDescription combinedSolution; if(partialSolutions.size() == 1){ - combinedSolution = partialSolutions.get(0).asEvaluatedDescription(strategy); + combinedSolution = partialSolutions.get(0).getEvaluatedDescription(); } else { List<Description> disjuncts = new ArrayList<Description>(); @@ -552,8 +590,7 @@ //build the union of all class expressions Description partialDescription; for (EvaluatedQueryTree<String> partialSolution : partialSolutions) { - partialDescription = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( - partialSolution.getTree().asOWLClassExpression(strategy)); + partialDescription = partialSolution.getEvaluatedDescription().getDescription(); disjuncts.add(partialDescription); posCovered.addAll(partialSolution.getTreeScore().getCoveredPositives()); negCovered.addAll(partialSolution.getTreeScore().getCoveredNegatives()); @@ -679,11 +716,12 @@ return individuals; } - private void asTree(Description d){ - QueryTree<String> tree = new QueryTreeImpl<String>(""); - for (Description child : d.getChildren()) { - + private Set<QueryTree<String>> asQueryTrees(Collection<Individual> individuals){ + Set<QueryTree<String>> trees = new HashSet<QueryTree<String>>(individuals.size()); + for (Individual ind : individuals) { + trees.add(individual2Tree.get(ind)); } + return trees; } /** @@ -802,16 +840,23 @@ private void todo(EvaluatedQueryTree<String> solution){ //check if not already contained in todo list for (EvaluatedQueryTree<String> evTree : todoList) { - if(sameTrees(solution.getTree(), evTree.getTree())){ + //this is a workaround as we have currently no equals method for trees based on the literal conversion strategy +// boolean sameTree = sameTrees(solution.getTree(), evTree.getTree()); + boolean sameTree = OWLAPIConverter.getOWLAPIDescription(evTree.getEvaluatedDescription().getDescription()).toString() + .equals(OWLAPIConverter.getOWLAPIDescription(solution.getEvaluatedDescription().getDescription()).toString()); + if(sameTree){ + logger.warn("Not added to TODO list: Already contained in."); return; } } //check if not already contained in solutions for (EvaluatedQueryTree<String> evTree : currentPartialSolutions) { if(sameTrees(solution.getTree(), evTree.getTree())){ + logger.warn("Not added to partial solutions list: Already contained in."); return; } } + logger.info("Added to TODO list."); todoList.add(solution); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -240,7 +240,7 @@ public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { EvaluatedQueryTree<String> bestSolution = solutions.first(); Description description = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( - bestSolution.getTree().asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION)); + bestSolution.getTree().asOWLClassExpression(LiteralNodeConversionStrategy.MIN_MAX)); return new EvaluatedDescription(description, bestSolution.getTreeScore()); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -118,11 +118,11 @@ /** * Literals as an interval on the datatype, e.g. [>= 5 <=10] */ - FACET_RESTRICTION, + MIN_MAX, /** * Literals as datatype, e.g. xsd:integer */ - SOME_VALUES_FROM, + DATATYPE, MIN, @@ -207,7 +207,7 @@ if(nodeType == NodeType.RESOURCE){ isResourceNode = true; } else if(nodeType == NodeType.LITERAL){ - isResourceNode = true; + isLiteralNode = true; } } @@ -1405,7 +1405,7 @@ * are transformed into existential restrictions. */ public OWLClassExpression asOWLClassExpression(){ - return asOWLClassExpression(LiteralNodeConversionStrategy.SOME_VALUES_FROM); + return asOWLClassExpression(LiteralNodeConversionStrategy.DATATYPE); } /** @@ -1430,7 +1430,7 @@ for(QueryTree<N> child : children){ String childLabel = (String) child.getUserObject(); String predicateString = (String) tree.getEdge(child); - if(predicateString.equals(RDF.type.getURI())){ + if(predicateString.equals(RDF.type.getURI()) || predicateString.equals(RDFS.subClassOf.getURI())){//A if(child.isVarNode()){ classExpressions.addAll(buildOWLClassExpressions(df, child, literalNodeConversionStrategy)); } else { @@ -1438,25 +1438,17 @@ classExpressions.add(df.getOWLClass(IRI.create(childLabel))); } } - } else if(predicateString.equals(RDFS.subClassOf.getURI())){ - if(child.isVarNode()){ - classExpressions.addAll(buildOWLClassExpressions(df, child, literalNodeConversionStrategy)); - } else { - if(!childLabel.equals(OWL.Thing.getURI())){//avoid trivial owl:Thing statements - classExpressions.add(df.getOWLClass(IRI.create(childLabel))); - } - } } else { if(child.isLiteralNode()){ OWLDataProperty p = df.getOWLDataProperty(IRI.create((String) tree.getEdge(child))); - if(childLabel.equals("?")){ + if(childLabel.equals("?")){//p some int Set<Literal> literals = child.getLiterals(); OWLDataRange dataRange = null; if(literals.isEmpty()){//happens if there are heterogeneous datatypes String datatypeURI = OWL2Datatype.RDFS_LITERAL.getURI().toString(); dataRange = df.getOWLDatatype(IRI.create(datatypeURI)); } else { - if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.SOME_VALUES_FROM){ + if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.DATATYPE){ Literal lit = literals.iterator().next(); RDFDatatype datatype = lit.getDatatype(); String datatypeURI; @@ -1468,7 +1460,7 @@ dataRange = df.getOWLDatatype(IRI.create(datatypeURI)); } else if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.DATA_ONE_OF){ dataRange = asDataOneOf(df, literals); - } else if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.FACET_RESTRICTION){ + } else if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.MIN_MAX){ dataRange = asFacet(df, literals); } else if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.MIN){ dataRange = asMinFacet(df, literals); @@ -1477,7 +1469,7 @@ } } classExpressions.add(df.getOWLDataSomeValuesFrom(p, dataRange)); - } else { + } else {//p value 1.2 Set<Literal> literals = child.getLiterals(); Literal lit = literals.iterator().next(); OWLLiteral owlLiteral = asOWLLiteral(df, lit); @@ -1486,7 +1478,7 @@ } else { OWLObjectProperty p = df.getOWLObjectProperty(IRI.create((String) tree.getEdge(child))); OWLClassExpression filler; - if(child.isVarNode()){ + if(child.isVarNode()){//p some C Set<OWLClassExpression> fillerClassExpressions = buildOWLClassExpressions(df, child, literalNodeConversionStrategy); if(fillerClassExpressions.isEmpty()){ filler = df.getOWLThing(); @@ -1496,7 +1488,7 @@ filler = df.getOWLObjectIntersectionOf(fillerClassExpressions); } classExpressions.add(df.getOWLObjectSomeValuesFrom(p, filler)); - } else { + } else {//p value {a} classExpressions.add(df.getOWLObjectHasValue(p, df.getOWLNamedIndividual(IRI.create(childLabel)))); } } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -5,6 +5,7 @@ import org.dllearner.algorithms.qtl.datastructures.QueryTree; import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.LiteralNodeConversionStrategy; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.QueryTreeScore; import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; @@ -18,6 +19,8 @@ private Collection<QueryTree<N>> falsePositives; private QueryTreeScore score; // private ScoreTwoValued score; + + private EvaluatedDescription description; public EvaluatedQueryTree(QueryTree<N> tree, Collection<QueryTree<N>> falseNegatives, Collection<QueryTree<N>> falsePositives, QueryTreeScore score) { @@ -61,7 +64,8 @@ @Override public int compareTo(EvaluatedQueryTree<N> other) { return ComparisonChain.start() - .compare(this.getScore(), other.getScore()) +// .compare(this.getScore(), other.getScore()) + .compare(other.getScore(), this.getScore()) .result(); // double diff = getScore() - other.getScore(); // if(diff == 0){ @@ -73,9 +77,26 @@ // } } + + /** + * @return the description + */ + public EvaluatedDescription getEvaluatedDescription() { + return asEvaluatedDescription(); + } + /** + * @param description the description to set + */ + public void setDescription(EvaluatedDescription description) { + this.description = description; + } + public EvaluatedDescription asEvaluatedDescription(){ - return new EvaluatedDescription(DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( - getTree().asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION)), score); + if(description == null){ + description = new EvaluatedDescription(DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( + getTree().asOWLClassExpression(LiteralNodeConversionStrategy.MIN_MAX)), score); + } + return description; } public EvaluatedDescription asEvaluatedDescription(LiteralNodeConversionStrategy strategy){ Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -4,10 +4,17 @@ package org.dllearner.algorithms.qtl.util; import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; import java.util.Stack; +import javax.xml.bind.DatatypeConverter; + import org.dllearner.algorithms.qtl.datastructures.QueryTree; import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.LiteralNodeConversionStrategy; import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.NodeType; import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.io.ToStringRenderer; @@ -24,11 +31,15 @@ import org.semanticweb.owlapi.model.OWLDataMaxCardinality; import org.semanticweb.owlapi.model.OWLDataMinCardinality; import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataProperty; +import org.semanticweb.owlapi.model.OWLDataRange; import org.semanticweb.owlapi.model.OWLDataRangeVisitor; import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; import org.semanticweb.owlapi.model.OWLDataUnionOf; import org.semanticweb.owlapi.model.OWLDatatype; import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLFacetRestriction; +import org.semanticweb.owlapi.model.OWLLiteral; import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; import org.semanticweb.owlapi.model.OWLObjectComplementOf; import org.semanticweb.owlapi.model.OWLObjectExactCardinality; @@ -38,20 +49,24 @@ import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; import org.semanticweb.owlapi.model.OWLObjectMinCardinality; import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectProperty; import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; import org.semanticweb.owlapi.model.OWLObjectUnionOf; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyChange; import org.semanticweb.owlapi.model.OWLOntologyManager; import org.semanticweb.owlapi.model.PrefixManager; -import org.semanticweb.owlapi.reasoner.OWLReasoner; -import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; import org.semanticweb.owlapi.util.DefaultPrefixManager; +import org.semanticweb.owlapi.vocab.OWL2Datatype; +import org.semanticweb.owlapi.vocab.OWLFacet; +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntaxObjectRenderer; -import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import com.hp.hpl.jena.datatypes.RDFDatatype; +import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; +import com.hp.hpl.jena.rdf.model.Literal; +import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.RDF; +import com.hp.hpl.jena.vocabulary.RDFS; /** * Converts query trees into OWL class expressions and vice versa. @@ -60,6 +75,8 @@ */ public class QueryTreeConverter implements OWLClassExpressionVisitor, OWLDataRangeVisitor{ + OWLDataFactory df = new OWLDataFactoryImpl(); + Stack<QueryTree<String>> stack = new Stack<QueryTree<String>>(); int id = 0; @@ -67,12 +84,213 @@ * Returns a OWL class expression of the union of the given query trees. * @param queryTrees */ - public void asOWLClassExpression(Collection<QueryTree<String>> queryTrees){ - - //check for common paths - + public OWLClassExpression asOWLClassExpression(QueryTree<String> tree){ + Set<OWLClassExpression> classExpressions = asOWLClassExpressions(tree); + OWLClassExpression expression; + if(classExpressions.isEmpty()){ + expression = df.getOWLThing(); + } else if(classExpressions.size() == 1){ + expression = classExpressions.iterator().next(); + } else { + expression = df.getOWLObjectIntersectionOf(classExpressions); + } + return expression; } + /** + * Returns a OWL class expression representation of the given query tree. + * @param queryTrees + */ + public Set<OWLClassExpression> asOWLClassExpressions(QueryTree<String> tree){ + Set<OWLClassExpression> classExpressions = new HashSet<OWLClassExpression>(); + + List<QueryTree<String>> children = tree.getChildren(); + for(QueryTree<String> child : children){ + String childLabel = (String) child.getUserObject(); + String predicateString = (String) tree.getEdge(child); + if(predicateString.equals(RDF.type.getURI()) || predicateString.equals(RDFS.subClassOf.getURI())){//A + if(child.isVarNode()){ + classExpressions.addAll(asOWLClassExpressions(child)); + } else { + if(!childLabel.equals(OWL.Thing.getURI())){//avoid trivial owl:Thing statements + classExpressions.add(df.getOWLClass(IRI.create(childLabel))); + } + } + } else { + if(child.isLiteralNode()){ + OWLDataProperty p = df.getOWLDataProperty(IRI.create((String) tree.getEdge(child))); + if(childLabel.equals("?")){//p some int + Set<Literal> literals = child.getLiterals(); + OWLDataRange dataRange = null; + if(literals.isEmpty()){//happens if there are heterogeneous datatypes + String datatypeURI = OWL2Datatype.RDFS_LITERAL.getURI().toString(); + dataRange = df.getOWLDatatype(IRI.create(datatypeURI)); + } else { + for (LiteralNodeConversionStrategy strategy : LiteralNodeConversionStrategy.values()) { + if(strategy == LiteralNodeConversionStrategy.DATATYPE){ + Literal lit = literals.iterator().next(); + RDFDatatype datatype = lit.getDatatype(); + String datatypeURI; + if(datatype == null){ + datatypeURI = OWL2Datatype.RDF_PLAIN_LITERAL.getURI().toString(); + } else { + datatypeURI = datatype.getURI(); + } + dataRange = df.getOWLDatatype(IRI.create(datatypeURI)); + } else if(strategy == LiteralNodeConversionStrategy.DATA_ONE_OF){ + dataRange = asDataOneOf(df, literals); + } else if(strategy == LiteralNodeConversionStrategy.MIN_MAX){ + dataRange = asFacet(df, literals); + } else if(strategy == LiteralNodeConversionStrategy.MIN){ + dataRange = asMinFacet(df, literals); + } else if(strategy == LiteralNodeConversionStrategy.MAX){ + dataRange = asMaxFacet(df, literals); + } + } + } + classExpressions.add(df.getOWLDataSomeValuesFrom(p, dataRange)); + } else {//p value 1.2 + Set<Literal> literals = child.getLiterals(); + Literal lit = literals.iterator().next(); + OWLLiteral owlLiteral = asOWLLiteral(df, lit); + classExpressions.add(df.getOWLDataHasValue(p, owlLiteral)); + } + } else { + OWLObjectProperty p = df.getOWLObjectProperty(IRI.create((String) tree.getEdge(child))); + OWLClassExpression filler; + if(child.isVarNode()){//p some C + Set<OWLClassExpression> fillerClassExpressions = asOWLClassExpressions(child); + if(fillerClassExpressions.isEmpty()){ + filler = df.getOWLThing(); + } else if(fillerClassExpressions.size() == 1){ + filler = fillerClassExpressions.iterator().next(); + } else { + filler = df.getOWLObjectIntersectionOf(fillerClassExpressions); + } + classExpressions.add(df.getOWLObjectSomeValuesFrom(p, filler)); + } else {//p value {a} + classExpressions.add(df.getOWLObjectHasValue(p, df.getOWLNamedIndividual(IRI.create(childLabel)))); + } + } + } + } + return classExpressions; + } + + private OWLDataRange asFacet(OWLDataFactory df, Set<Literal> literals){ + //return Boolean datatype because it doesn't make sense to return a facet of Boolean values + if(getOWLDatatype(df, literals).equals(df.getBooleanOWLDatatype())){ + return df.getBooleanOWLDatatype(); + } + Literal min = getMin(literals); + Literal max = getMax(literals); + + OWLFacetRestriction minRestriction = df.getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, asOWLLiteral(df, min)); + OWLFacetRestriction maxRestriction = df.getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, asOWLLiteral(df, max)); + + return df.getOWLDatatypeRestriction(getOWLDatatype(df, literals), minRestriction, maxRestriction); + } + + private OWLDataRange asMinFacet(OWLDataFactory df, Set<Literal> literals){ + //return Boolean datatype because it doesn't make sense to return a facet of Boolean values + if(getOWLDatatype(df, literals).equals(df.getBooleanOWLDatatype())){ + return df.getBooleanOWLDatatype(); + } + Literal min = getMin(literals); + + OWLFacetRestriction minRestriction = df.getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, asOWLLiteral(df, min)); + + return df.getOWLDatatypeRestriction(getOWLDatatype(df, literals), minRestriction); + } + + private OWLDataRange asMaxFacet(OWLDataFactory df, Set<Literal> literals){ + //return Boolean datatype because it doesn't make sense to return a facet of Boolean values + if(getOWLDatatype(df, literals).equals(df.getBooleanOWLDatatype())){ + return df.getBooleanOWLDatatype(); + } + Literal max = getMax(literals); + + OWLFacetRestriction maxRestriction = df.getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, asOWLLiteral(df, max)); + + return df.getOWLDatatypeRestriction(getOWLDatatype(df, literals), maxRestriction); + } + + private OWLDataRange asDataOneOf(OWLDataFactory df, Set<Literal> literals){ + //return Boolean datatype because it doesn't make sense to return a enumeration of Boolean values + if(getOWLDatatype(df, literals).equals(df.getBooleanOWLDatatype())){ + return df.getBooleanOWLDatatype(); + } + return df.getOWLDataOneOf(asOWLLiterals(df, literals)); + } + + private Set<OWLLiteral> asOWLLiterals(OWLDataFactory df, Set<Literal> literals){ + Set<OWLLiteral> owlLiterals = new HashSet<OWLLiteral>(literals.size()); + for (Literal literal : literals) { + owlLiterals.add(asOWLLiteral(df, literal)); + } + return owlLiterals; + } + + private OWLLiteral asOWLLiteral(OWLDataFactory df, Literal literal){ + OWLLiteral owlLiteral; + if(literal.getDatatypeURI() == null){ + owlLiteral = df.getOWLLiteral(literal.getLexicalForm(), literal.getLanguage()); + } else { + owlLiteral = df.getOWLLiteral(literal.getLexicalForm(), df.getOWLDatatype(IRI.create(literal.getDatatypeURI()))); + } + return owlLiteral; + } + + private Literal getMin(Set<Literal> literals){ + Iterator<Literal> iter = literals.iterator(); + Literal min = iter.next(); + Literal l; + while(iter.hasNext()){ + l = iter.next(); + if(l.getDatatype() == XSDDatatype.XSDinteger || l.getDatatype() == XSDDatatype.XSDint){ + min = (l.getInt() < min.getInt()) ? l : min; + } else if(l.getDatatype() == XSDDatatype.XSDdouble || l.getDatatype() == XSDDatatype.XSDdecimal){ + min = (l.getDouble() < min.getDouble()) ? l : min; + } else if(l.getDatatype() == XSDDatatype.XSDfloat){ + min = (l.getFloat() < min.getFloat()) ? l : min; + } else if(l.getDatatype() == XSDDatatype.XSDdate){ + min = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(min.getLexicalForm())) == -1) ? l : min; + } + } + return min; + } + + private Literal getMax(Set<Literal> literals){ + Iterator<Literal> iter = literals.iterator(); + Literal max = iter.next(); + Literal l; + while(iter.hasNext()){ + l = iter.next(); + if(l.getDatatype() == XSDDatatype.XSDinteger || l.getDatatype() == XSDDatatype.XSDint){ + max = (l.getInt() > max.getInt()) ? l : max; + } else if(l.getDatatype() == XSDDatatype.XSDdouble || l.getDatatype() == XSDDatatype.XSDdecimal){ + max = (l.getDouble() > max.getDouble()) ? l : max; + } else if(l.getDatatype() == XSDDatatype.XSDfloat){ + max = (l.getFloat() > max.getFloat()) ? l : max; + } else if(l.getDatatype() == XSDDatatype.XSDdate){ + max = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(max.getLexicalForm())) == 1) ? l : max; + } + } + return max; + } + + private OWLDatatype getOWLDatatype(OWLDataFactory df, Set<Literal> literals){ + return df.getOWLDatatype(IRI.create(literals.iterator().next().getDatatypeURI())); + } + + + /** + * Converts a OWL class expression into a query tree, if possible. Note that this is not possible + * for all OWL constructs, e.g. universal restrictions are not allowed. An exceptions is thrown if the conversion + * fails. + * @param expression + * @return + */ public QueryTree<String> asQueryTree(OWLClassExpression expression){ // stack.push(new QueryTreeImpl<String>("?")); reset(); Modified: trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -52,7 +52,7 @@ * @author Jens Lehmann * */ -public abstract class AbstractCELA extends AbstractComponent implements ClassExpressionLearningAlgorithm, StoppableLearningAlgorithm, Cloneable { +public abstract class AbstractCELA extends AbstractComponent implements ClassExpressionLearningAlgorithm, StoppableLearningAlgorithm { protected EvaluatedDescriptionSet bestEvaluatedDescriptions = new EvaluatedDescriptionSet(AbstractCELA.MAX_NR_OF_RESULTS); protected DecimalFormat dfPercent = new DecimalFormat("0.00%"); Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Constant.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/Constant.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/Constant.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -19,17 +19,16 @@ package org.dllearner.core.owl; +import java.io.Serializable; + /** * A constant value. * * @author Jens Lehmann * */ -public abstract class Constant implements KBElement, Comparable<Constant> { +public abstract class Constant implements KBElement, Comparable<Constant>, Serializable { - /** - * - */ private static final long serialVersionUID = 2331790456049452753L; String literal; Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DatatypeProperty.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -31,9 +31,6 @@ */ public class DatatypeProperty implements Comparable<DatatypeProperty>, Property, NamedKBElement, Serializable { - /** - * - */ private static final long serialVersionUID = 8452865438915671952L; protected String name; Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -58,11 +58,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " double[<= " + value + "]"; + return "double[<= " + value + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " double[<= " + value + "]"; + return "double[<= " + value + "]"; } public void accept(KBElementVisitor visitor) { @@ -74,7 +74,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " double[<= " + value + "]"; + return "double[<= " + value + "]"; } /* (non-Javadoc) Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -65,11 +65,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " double[>= " + minValue + " <= " + maxValue + "]"; + return "double[>= " + minValue + ", <= " + maxValue + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " double[>= " + minValue + " <= " + maxValue + "]"; + return "double[>= " + minValue + ", <= " + maxValue + "]"; } public void accept(KBElementVisitor visitor) { @@ -81,7 +81,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " double[>= " + minValue + " <= " + maxValue + "]"; + return "double[>= " + minValue + ", <= " + maxValue + "]"; } /* (non-Javadoc) Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -58,11 +58,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " double[>= " + value + "]"; + return "double[>= " + value + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " double[>= " + value + "]"; + return "double[>= " + value + "]"; } public void accept(KBElementVisitor visitor) { @@ -74,7 +74,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " double[>= " + value + "]"; + return "double[>= " + value + "]"; } /* (non-Javadoc) Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -19,6 +19,7 @@ package org.dllearner.core.owl; +import java.io.Serializable; import java.net.URI; import java.util.Map; @@ -31,7 +32,7 @@ * @author Jens Lehmann * */ -public class ObjectProperty extends ObjectPropertyExpression implements Property, Comparable<ObjectProperty>{ +public class ObjectProperty extends ObjectPropertyExpression implements Property, Comparable<ObjectProperty>, Serializable{ private static final long serialVersionUID = -3343070247923446690L; Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/TypedConstant.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -29,9 +29,6 @@ */ public class TypedConstant extends Constant { - /** - * - */ private static final long serialVersionUID = -9135242138291085300L; private Datatype datatype; Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -6,6 +6,7 @@ import java.io.ByteArrayInputStream; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.Stack; @@ -81,27 +82,55 @@ private Map<OWLClass, Set<OWLClassExpression>> map = new HashMap<>(); Stack<Set<OWLClassExpression>> stack = new Stack<Set<OWLClassExpression>>(); OWLDataFactory df; + boolean onlyIfExistentialOnPath = true; + + int indent = 0; public SuperClassFinder() { df = ontology.getOWLOntologyManager().getOWLDataFactory(); } public Set<OWLClassExpression> getSuperClasses(OWLClass cls){ +// System.out.println("#################"); map.clear(); computeSuperClasses(cls); Set<OWLClassExpression> superClasses = map.get(cls); superClasses.remove(cls); + + //filter out non existential superclasses + if(onlyIfExistentialOnPath){ + for (Iterator<OWLClassExpression> iterator = superClasses.iterator(); iterator.hasNext();) { + OWLClassExpression sup = iterator.next(); + if (!(sup instanceof OWLObjectSomeValuesFrom || sup instanceof OWLDataAllValuesFrom)) { + iterator.remove(); + } + } + } return superClasses; } private void computeSuperClasses(OWLClass cls){ + String s = ""; + for(int i = 0; i < indent; i++){ + s += " "; + } +// System.out.println(s + cls); + indent++; Set<OWLClassExpression> superClasses = new HashSet<OWLClassExpression>(); superClasses.add(cls); + + //get the directly asserted super classes Set<OWLClassExpression> superClassExpressions = cls.getSuperClasses(ontology); + + //omit trivial super class + superClassExpressions.remove(cls); + + //go subsumption hierarchy up for each directly asserted super class for (OWLClassExpression sup : superClassExpressions) { sup.accept(this); superClasses.addAll(stack.pop()); } + stack.push(superClasses); map.put(cls, superClasses); } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java 2014-07-02 06:31:52 UTC (rev 4279) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java 2014-07-29 13:53:19 UTC (rev 4280) @@ -59,6 +59,7 @@ import ... [truncated message content] |
From: <lor...@us...> - 2014-07-02 06:31:55
|
Revision: 4279 http://sourceforge.net/p/dl-learner/code/4279 Author: lorenz_b Date: 2014-07-02 06:31:52 +0000 (Wed, 02 Jul 2014) Log Message: ----------- Added constructor. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2014-06-25 10:06:50 UTC (rev 4278) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2014-07-02 06:31:52 UTC (rev 4279) @@ -54,14 +54,12 @@ import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeProperty; -import org.dllearner.core.owl.DatatypePropertyHierarchy; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.Property; import org.dllearner.core.owl.Thing; import org.dllearner.kb.LocalModelBasedSparqlEndpointKS; @@ -82,7 +80,6 @@ import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.RDFNode; @@ -122,6 +119,15 @@ this(ks, (String)null); } + public SPARQLReasoner(QueryExecutionFactory qef) { + this.qef = qef; + + classPopularityMap = new HashMap<NamedClass, Integer>(); + objectPropertyPopularityMap = new HashMap<ObjectProperty, Integer>(); + dataPropertyPopularityMap = new HashMap<DatatypeProperty, Integer>(); + individualPopularityMap = new HashMap<Individual, Integer>(); + } + public SPARQLReasoner(SparqlEndpointKS ks, String cacheDirectory) { this.ks = ks; @@ -140,9 +146,9 @@ CacheEx cacheFrontend = new CacheExImpl(cacheBackend); qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); } catch (ClassNotFoundException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } catch (SQLException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } } // qef = new QueryExecutionFactoryPaginated(qef, 10000); @@ -177,7 +183,7 @@ qef = new QueryExecutionFactoryModel(((LocalModelBasedSparqlEndpointKS)ks).getModel()); } } - + public SPARQLReasoner(SparqlEndpointKS ks, ExtractionDBCache cache) { this(ks, cache.getCacheDirectory()); } @@ -1871,6 +1877,10 @@ */ @Override public void init() throws ComponentInitException { + classPopularityMap = new HashMap<NamedClass, Integer>(); + objectPropertyPopularityMap = new HashMap<ObjectProperty, Integer>(); + dataPropertyPopularityMap = new HashMap<DatatypeProperty, Integer>(); + individualPopularityMap = new HashMap<Individual, Integer>(); } /* (non-Javadoc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ki...@us...> - 2014-06-25 10:07:02
|
Revision: 4278 http://sourceforge.net/p/dl-learner/code/4278 Author: kirdie Date: 2014-06-25 10:06:50 +0000 (Wed, 25 Jun 2014) Log Message: ----------- QTL bugfix and formatting improvement. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java 2014-06-24 09:35:44 UTC (rev 4277) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL.java 2014-06-25 10:06:50 UTC (rev 4278) @@ -33,7 +33,6 @@ import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.TimeUnit; - import org.aksw.jena_sparql_api.cache.core.QueryExecutionFactoryCacheEx; import org.aksw.jena_sparql_api.cache.extra.CacheCoreEx; import org.aksw.jena_sparql_api.cache.extra.CacheCoreH2; @@ -54,6 +53,7 @@ import org.dllearner.algorithms.qtl.operations.NBR; import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; +import org.aksw.jena_sparql_api.core.QueryExecutionFactory; import org.dllearner.algorithms.qtl.util.SPARQLEndpointEx; import org.dllearner.core.AbstractCELA; import org.dllearner.core.AbstractLearningProblem; @@ -101,39 +101,39 @@ */ @ComponentAnn(name="query tree learner", shortName="qtl", version=0.8) public class QTL extends AbstractCELA implements SparqlQueryLearningAlgorithm { - + private static final Logger logger = Logger.getLogger(QTL.class); - + private LearningProblem learningProblem; private SparqlEndpointKS endpointKS; -// private QTLConfigurator configurator; - + // private QTLConfigurator configurator; + private SparqlEndpoint endpoint; private Model model; - private org.aksw.jena_sparql_api.core.QueryExecutionFactory qef; + private QueryExecutionFactory qef; private String cacheDirectory; - + private QueryTreeCache treeCache; - + private LGGGenerator<String> lggGenerator; private NBR<String> nbr; - + private List<String> posExamples; private List<String> negExamples; - + private List<QueryTree<String>> posExampleTrees; private List<QueryTree<String>> negExampleTrees; - + private QueryTreeFilter queryTreeFilter; - + private ConciseBoundedDescriptionGenerator cbdGenerator; - + private int maxExecutionTimeInSeconds = 60; private int maxQueryTreeDepth = 2; - + private QueryTree<String> lgg; private SortedSet<String> lggInstances; - + private Set<String> objectNamespacesToIgnore = new HashSet<String>(); private Set<String> allowedNamespaces = new HashSet<String>(); private Map<String, String> prefixes = new HashMap<String, String>(); @@ -145,14 +145,14 @@ options.add(new IntegerConfigOption("maxQueryTreeDepth", "recursion depth of query tree extraction", 2)); return options; } - - public QTL() { - } - + + // public QTL() { + // } + public QTL(AbstractLearningProblem learningProblem, SparqlEndpointKS endpointKS) throws LearningProblemUnsupportedException{ this(learningProblem, endpointKS, null); } - + public QTL(AbstractLearningProblem learningProblem, SparqlEndpointKS endpointKS, String cacheDirectory) throws LearningProblemUnsupportedException{ if(!(learningProblem instanceof PosOnlyLP || learningProblem instanceof PosNegLP)){ throw new LearningProblemUnsupportedException(learningProblem.getClass(), getClass()); @@ -161,69 +161,69 @@ this.endpointKS = endpointKS; this.cacheDirectory = cacheDirectory; } - + public QTL(SPARQLEndpointEx endpoint, String cacheDirectory) { this.endpoint = endpoint; this.cacheDirectory = cacheDirectory; - + treeCache = new QueryTreeCache(); cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(endpoint, cacheDirectory)); cbdGenerator.setRecursionDepth(maxQueryTreeDepth); - + lggGenerator = new LGGGeneratorImpl<String>(); nbr = new NBR<String>(endpoint, cacheDirectory); nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); - + posExampleTrees = new ArrayList<QueryTree<String>>(); negExampleTrees = new ArrayList<QueryTree<String>>(); } - + public QTL(SparqlEndpointKS endpointKS, String cacheDirectory) { this.endpointKS = endpointKS; this.cacheDirectory = cacheDirectory; - + treeCache = new QueryTreeCache(); cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(endpoint, cacheDirectory)); cbdGenerator.setRecursionDepth(maxQueryTreeDepth); - + lggGenerator = new LGGGeneratorImpl<String>(); nbr = new NBR<String>(endpoint, cacheDirectory); nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); - + posExampleTrees = new ArrayList<QueryTree<String>>(); negExampleTrees = new ArrayList<QueryTree<String>>(); } - + public QTL(Model model) { this.model = model; - + treeCache = new QueryTreeCache(); cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(model)); cbdGenerator.setRecursionDepth(maxQueryTreeDepth); - + lggGenerator = new LGGGeneratorImpl<String>(); nbr = new NBR<String>(model); nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); - + posExampleTrees = new ArrayList<QueryTree<String>>(); negExampleTrees = new ArrayList<QueryTree<String>>(); } - + public String getQuestion(List<String> posExamples, List<String> negExamples) throws EmptyLGGException, NegativeTreeCoverageExecption, TimeOutException { this.posExamples = posExamples; this.negExamples = negExamples; - + generatePositiveExampleTrees(); generateNegativeExampleTrees(); - + if(negExamples.isEmpty()){ QueryTree<String> dummyNegTree = new QueryTreeImpl<String>("?"); dummyNegTree.addChild(new QueryTreeImpl<String>("?"), "dummy"); negExampleTrees.add(dummyNegTree); } - + lgg = lggGenerator.getLGG(posExampleTrees); - + if(queryTreeFilter != null){ lgg = queryTreeFilter.getFilteredQueryTree(lgg); } @@ -233,86 +233,86 @@ if(lgg.isEmpty()){ throw new EmptyLGGException(); } - + int index = coversNegativeQueryTree(lgg); if(index != -1){ throw new NegativeTreeCoverageExecption(negExamples.get(index)); } - + lggInstances = getResources(lgg); nbr.setLGGInstances(lggInstances); - + String question; if(negExamples.isEmpty()){ question = nbr.getQuestion(lgg, negExampleTrees, getKnownResources()); } else { question = nbr.getQuestion(lgg, negExampleTrees, getKnownResources()); } - - + + return question; } - + public void setExamples(List<String> posExamples, List<String> negExamples){ this.posExamples = posExamples; this.negExamples = negExamples; } - + public void addStatementFilter(Filter<Statement> filter){ treeCache.setStatementFilter(filter); } - + public void addQueryTreeFilter(QueryTreeFilter queryTreeFilter){ this.queryTreeFilter = queryTreeFilter; } - + public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds){ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); } - + public void setMaxQueryTreeDepth(int maxQueryTreeDepth){ this.maxQueryTreeDepth = maxQueryTreeDepth; -// cbdGenerator.setRecursionDepth(maxQueryTreeDepth); + // cbdGenerator.setRecursionDepth(maxQueryTreeDepth); } - + public int getMaxQueryTreeDepth() { return maxQueryTreeDepth; } - + public void setPrefixes(Map<String, String> prefixes) { this.prefixes = prefixes; } - + public Map<String, String> getPrefixes() { return prefixes; } - + public String getSPARQLQuery(){ if(lgg == null){ lgg = lggGenerator.getLGG(getQueryTrees(posExamples)); } return lgg.toSPARQLQueryString(); } - + public void setObjectNamespacesToIgnore(Set<String> namespacesToIgnore){ this.objectNamespacesToIgnore = namespacesToIgnore; } - + public void setRestrictToNamespaces(List<String> namespaces){ cbdGenerator.setRestrictToNamespaces(namespaces); } - + private void generatePositiveExampleTrees(){ posExampleTrees.clear(); posExampleTrees.addAll(getQueryTrees(posExamples)); } - + private void generateNegativeExampleTrees(){ negExampleTrees.clear(); negExampleTrees.addAll(getQueryTrees(negExamples)); } - + private List<QueryTree<String>> getQueryTrees(List<String> resources){ List<QueryTree<String>> trees = new ArrayList<QueryTree<String>>(); Model model; @@ -326,7 +326,7 @@ if(logger.isDebugEnabled()){ logger.debug("Tree for resource " + resource); logger.debug(tree.getStringRepresentation()); - + } trees.add(tree); } catch (Exception e) { @@ -335,7 +335,7 @@ } return trees; } - + private void applyFilters(Model model){ Statement st; for(StmtIterator iter = model.listStatements(); iter.hasNext();){ @@ -348,20 +348,20 @@ } } } - + private List<String> getKnownResources(){ return ListUtils.union(posExamples, negExamples); } - -// private boolean coversNegativeQueryTree(QueryTree<String> tree){ -// for(QueryTree<String> negTree : negExampleTrees){ -// if(negTree.isSubsumedBy(tree)){ -// return true; -// } -// } -// return false; -// } - + + // private boolean coversNegativeQueryTree(QueryTree<String> tree){ + // for(QueryTree<String> negTree : negExampleTrees){ + // if(negTree.isSubsumedBy(tree)){ + // return true; + // } + // } + // return false; + // } + private int coversNegativeQueryTree(QueryTree<String> tree){ for(int i = 0; i < negExampleTrees.size(); i++){ if(negExampleTrees.get(i).isSubsumedBy(tree)){ @@ -370,13 +370,13 @@ } return -1; } - + private SortedSet<String> getResources(QueryTree<String> tree){ SortedSet<String> resources = new TreeSet<String>(); String query = getDistinctSPARQLQuery(tree); QueryExecution qe = qef.createQueryExecution(query); ResultSet rs = qe.execSelect(); - + QuerySolution qs; while(rs.hasNext()){ qs = rs.next(); @@ -385,35 +385,35 @@ qe.close(); return resources; } - + private String getDistinctSPARQLQuery(QueryTree<String> tree){ String query = tree.toSPARQLQueryString(); -// query = "SELECT DISTINCT " + query.substring(7); + // query = "SELECT DISTINCT " + query.substring(7); return query; } -// @Override -// public void start(){ -// generatePositiveExampleTrees(); -// -// lgg = lggGenerator.getLGG(posExampleTrees); -// -// if(queryTreeFilter != null){ -// lgg = queryTreeFilter.getFilteredQueryTree(lgg); -// } -// if(logger.isDebugEnabled()){ -// logger.debug("LGG: \n" + lgg.getStringRepresentation()); -// } -// if(logger.isInfoEnabled()){ -// logger.info("Generated SPARQL query:\n" + lgg.toSPARQLQueryString(true, enableNumericLiteralFilters, prefixes)); -// } -// } - + // @Override + // public void start(){ + // generatePositiveExampleTrees(); + // + // lgg = lggGenerator.getLGG(posExampleTrees); + // + // if(queryTreeFilter != null){ + // lgg = queryTreeFilter.getFilteredQueryTree(lgg); + // } + // if(logger.isDebugEnabled()){ + // logger.debug("LGG: \n" + lgg.getStringRepresentation()); + // } + // if(logger.isInfoEnabled()){ + // logger.info("Generated SPARQL query:\n" + lgg.toSPARQLQueryString(true, enableNumericLiteralFilters, prefixes)); + // } + // } + @Override public void start(){ //build the query trees for the positive examples generatePositiveExampleTrees(); - + //compute the LGG lgg = lggGenerator.getLGG(posExampleTrees); if(queryTreeFilter != null){ @@ -425,21 +425,21 @@ if(logger.isInfoEnabled()){ logger.info("Generated SPARQL query:\n" + lgg.toSPARQLQueryString(true, enableNumericLiteralFilters, prefixes)); } - + //build the query trees for the negative examples if(!negExamples.isEmpty()){ generateNegativeExampleTrees(); - + try { //check if the LGG covers a negative example int index = coversNegativeQueryTree(lgg); if(index != -1){ throw new NegativeTreeCoverageExecption(negExamples.get(index)); } - + lggInstances = getResources(lgg); nbr.setLGGInstances(lggInstances); - + String question; if(negExamples.isEmpty()){ question = nbr.getQuestion(lgg, negExampleTrees, getKnownResources()); @@ -454,15 +454,15 @@ } } } - + public void setEnableNumericLiteralFilters(boolean enableNumericLiteralFilters) { this.enableNumericLiteralFilters = enableNumericLiteralFilters; } - + public boolean isEnableNumericLiteralFilters() { return enableNumericLiteralFilters; } - + @Override public List<String> getCurrentlyBestSPARQLQueries(int nrOfSPARQLQueries) { return Collections.singletonList(getBestSPARQLQuery()); @@ -473,29 +473,39 @@ return lgg.toSPARQLQueryString(); } - public void init() { - if(endpointKS.isRemote()){ - SparqlEndpoint endpoint = endpointKS.getEndpoint(); - qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); - if(cacheDirectory != null){ - try { - long timeToLive = TimeUnit.DAYS.toMillis(30); - CacheCoreEx cacheBackend = CacheCoreH2.create(cacheDirectory, timeToLive, true); - CacheEx cacheFrontend = new CacheExImpl(cacheBackend); - qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (SQLException e) { - e.printStackTrace(); + public void init() {// TODO: further improve code quality + // private QTL() { + if(endpointKS==null) + { + qef = new QueryExecutionFactoryModel(this.model); + cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(model)); + nbr = new NBR<String>(model); + } + else + { + if(endpointKS.isRemote()) + { + SparqlEndpoint endpoint = endpointKS.getEndpoint(); + QueryExecutionFactory qef = new QueryExecutionFactoryHttp(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()); + if(cacheDirectory != null){ + try { + long timeToLive = TimeUnit.DAYS.toMillis(30); + CacheCoreEx cacheBackend = CacheCoreH2.create(cacheDirectory, timeToLive, true); + CacheEx cacheFrontend = new CacheExImpl(cacheBackend); + qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } } + // qef = new QueryExecutionFactoryPaginated(qef, 10000); + } else + { + qef = new QueryExecutionFactoryModel(((LocalModelBasedSparqlEndpointKS)endpointKS).getModel()); } -// qef = new QueryExecutionFactoryPaginated(qef, 10000); - - } else { - qef = new QueryExecutionFactoryModel(((LocalModelBasedSparqlEndpointKS)endpointKS).getModel()); - } - - + } + if(learningProblem instanceof PosOnlyLP){ this.posExamples = convert(((PosOnlyLP)learningProblem).getPositiveExamples()); this.negExamples = new ArrayList<String>(); @@ -505,23 +515,30 @@ } treeCache = new QueryTreeCache(); treeCache.addAllowedNamespaces(allowedNamespaces); - - if(endpointKS instanceof LocalModelBasedSparqlEndpointKS){ - cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(((LocalModelBasedSparqlEndpointKS) endpointKS).getModel())); - } else { - endpoint = endpointKS.getEndpoint(); - cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(endpoint, endpointKS.getCache())); + + if(endpointKS==null) {} + else + { + nbr = new NBR<String>(endpoint); + nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + + if(endpointKS instanceof LocalModelBasedSparqlEndpointKS){ + cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(((LocalModelBasedSparqlEndpointKS) endpointKS).getModel())); + } else { + endpoint = endpointKS.getEndpoint(); + cbdGenerator = new CachingConciseBoundedDescriptionGenerator(new ConciseBoundedDescriptionGeneratorImpl(endpoint, endpointKS.getCache())); + } } cbdGenerator.setRecursionDepth(maxQueryTreeDepth); - + lggGenerator = new LGGGeneratorImpl<String>(); - nbr = new NBR<String>(endpoint); - nbr.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + + posExampleTrees = new ArrayList<QueryTree<String>>(); negExampleTrees = new ArrayList<QueryTree<String>>(); } - + private List<String> convert(Set<Individual> individuals){ List<String> list = new ArrayList<String>(); for(Individual ind : individuals){ @@ -529,11 +546,11 @@ } return list; } - + public QueryTree<String> getLgg() { return lgg; } - + @Autowired public void setLearningProblem(LearningProblem learningProblem) { this.learningProblem = learningProblem; @@ -578,7 +595,7 @@ public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { return null; } - + /** * @param allowedNamespaces the allowedNamespaces to set */ @@ -590,7 +607,7 @@ Set<String> positiveExamples = new HashSet<String>(); positiveExamples.add("http://dbpedia.org/resource/Liverpool_F.C."); positiveExamples.add("http://dbpedia.org/resource/Chelsea_F.C."); - + SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()); ks.init(); PosOnlyLP lp = new PosOnlyLP(); @@ -604,5 +621,5 @@ System.out.println(query); System.out.println(qtl.getCurrentlyBestDescription()); } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ki...@us...> - 2014-06-24 09:35:48
|
Revision: 4277 http://sourceforge.net/p/dl-learner/code/4277 Author: kirdie Date: 2014-06-24 09:35:44 +0000 (Tue, 24 Jun 2014) Log Message: ----------- dl-learner works again by removing plugin version. clearer exception message in one case. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java Modified: trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2014-06-23 12:57:22 UTC (rev 4276) +++ trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2014-06-24 09:35:44 UTC (rev 4277) @@ -154,6 +154,11 @@ public void setSupportsSPARQL_1_1(boolean supportsSPARQL_1_1) { this.supportsSPARQL_1_1 = supportsSPARQL_1_1; + } + + @Override public String toString() + { + return endpoint.toString(); } } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2014-06-23 12:57:22 UTC (rev 4276) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2014-06-24 09:35:44 UTC (rev 4277) @@ -33,7 +33,6 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.concurrent.TimeUnit; - import org.aksw.jena_sparql_api.cache.core.QueryExecutionFactoryCacheEx; import org.aksw.jena_sparql_api.cache.extra.CacheCoreEx; import org.aksw.jena_sparql_api.cache.extra.CacheCoreH2; @@ -75,7 +74,6 @@ import org.dllearner.utilities.owl.OWLClassExpressionToSPARQLConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import com.clarkparsia.owlapiv3.XSD; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; @@ -89,6 +87,7 @@ import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; +import com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP; import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL2; import com.hp.hpl.jena.vocabulary.RDF; @@ -1758,8 +1757,15 @@ private ResultSet executeSelectQuery(String query){ logger.trace("Sending query \n {}", query); QueryExecution qe = qef.createQueryExecution(query); + try + { ResultSet rs = qe.execSelect(); return rs; + } + catch(QueryExceptionHTTP e) + { + throw new QueryExceptionHTTP("Error sending query \""+query+"\" to endpoint "+ks,e); + } } private ResultSet executeSelectQuery(String query, long timeout){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ki...@us...> - 2014-06-23 12:57:30
|
Revision: 4276 http://sourceforge.net/p/dl-learner/code/4276 Author: kirdie Date: 2014-06-23 12:57:22 +0000 (Mon, 23 Jun 2014) Log Message: ----------- made components-core and -ext compile again by removing version number of maven exec plugin. also fixed some warnings in the poms about duplicate info which is already contained in the parent. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-ext/pom.xml Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2014-05-27 13:03:09 UTC (rev 4275) +++ trunk/components-core/pom.xml 2014-06-23 12:57:22 UTC (rev 4276) @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.dllearner</groupId> + <!-- <groupId>org.dllearner</groupId> --> <artifactId>components-core</artifactId> <name>DL Learner Core Components</name> Modified: trunk/components-ext/pom.xml =================================================================== --- trunk/components-ext/pom.xml 2014-05-27 13:03:09 UTC (rev 4275) +++ trunk/components-ext/pom.xml 2014-06-23 12:57:22 UTC (rev 4276) @@ -2,12 +2,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.dllearner</groupId> + <!-- <groupId>org.dllearner</groupId> --> <artifactId>components-ext</artifactId> <packaging>jar</packaging> <name>components-ext</name> - <version>1.0-SNAPSHOT</version> + <!-- <version>1.0-SNAPSHOT</version> --> <url>http://aksw.org/Projects/DLLearner</url> <parent> @@ -192,7 +192,7 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> - <version>1.2.1</version> + <!-- <version>1.2.1</version> --> <executions> <execution> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-27 13:03:16
|
Revision: 4275 http://sourceforge.net/p/dl-learner/code/4275 Author: lorenz_b Date: 2014-05-27 13:03:09 +0000 (Tue, 27 May 2014) Log Message: ----------- Added simple materialization util for existential restrictions that can be used in the FastInstanceChecker.. Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java Added: trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/ExistentialRestrictionMaterialization.java 2014-05-27 13:03:09 UTC (rev 4275) @@ -0,0 +1,290 @@ +/** + * + */ +package org.dllearner.reasoning; + +import java.io.ByteArrayInputStream; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.Stack; + +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter; + +import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntaxObjectRenderer; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; + +/** + * @author Lorenz Buehmann + * + */ +public class ExistentialRestrictionMaterialization { + + + private OWLOntology ontology; + private OWLReasoner reasoner; + private OWLDataFactory df; + + public ExistentialRestrictionMaterialization(OWLOntology ontology) { + this.ontology = ontology; + + OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance(); + reasoner = reasonerFactory.createNonBufferingReasoner(ontology); + + df = ontology.getOWLOntologyManager().getOWLDataFactory(); + } + + private Set<OWLClassExpression> getSuperClasses(OWLClass cls){ + return new SuperClassFinder().getSuperClasses(cls); + } + + public Set<OWLClassExpression> materialize(String classIRI){ + return materialize(df.getOWLClass(IRI.create(classIRI))); + } + + public Set<OWLClassExpression> materialize(OWLClass cls){ + Set<OWLClassExpression> superClasses = getSuperClasses(cls); + return superClasses; + } + + class SuperClassFinder extends OWLClassExpressionVisitorAdapter{ + + private Map<OWLClass, Set<OWLClassExpression>> map = new HashMap<>(); + Stack<Set<OWLClassExpression>> stack = new Stack<Set<OWLClassExpression>>(); + OWLDataFactory df; + + public SuperClassFinder() { + df = ontology.getOWLOntologyManager().getOWLDataFactory(); + } + + public Set<OWLClassExpression> getSuperClasses(OWLClass cls){ + map.clear(); + computeSuperClasses(cls); + Set<OWLClassExpression> superClasses = map.get(cls); + superClasses.remove(cls); + return superClasses; + } + + private void computeSuperClasses(OWLClass cls){ + Set<OWLClassExpression> superClasses = new HashSet<OWLClassExpression>(); + superClasses.add(cls); + Set<OWLClassExpression> superClassExpressions = cls.getSuperClasses(ontology); + for (OWLClassExpression sup : superClassExpressions) { + sup.accept(this); + superClasses.addAll(stack.pop()); + } + stack.push(superClasses); + map.put(cls, superClasses); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLClass) + */ + @Override + public void visit(OWLClass ce) { + computeSuperClasses(ce); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectIntersectionOf) + */ + @Override + public void visit(OWLObjectIntersectionOf ce) { + Set<OWLClassExpression> newIntersections = new HashSet<OWLClassExpression>(); + Set<OWLClassExpression> operands = ce.getOperands(); + for (OWLClassExpression op : operands) { + op.accept(this); + Set<OWLClassExpression> operandSuperClassExpressions = stack.pop(); + Set<OWLClassExpression> newOperands = new HashSet<OWLClassExpression>(operands); + newOperands.remove(op); + for (OWLClassExpression opSup : operandSuperClassExpressions) { + newOperands.add(opSup); + newIntersections.add(df.getOWLObjectIntersectionOf(newOperands)); + newOperands.remove(opSup); + } + } + stack.push(newIntersections); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectUnionOf) + */ + @Override + public void visit(OWLObjectUnionOf ce) { + Set<OWLClassExpression> operands = ce.getOperands(); + for (OWLClassExpression op : operands) { + op.accept(this); + } + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectComplementOf) + */ + @Override + public void visit(OWLObjectComplementOf ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom) + */ + @Override + public void visit(OWLObjectSomeValuesFrom ce) { + Set<OWLClassExpression> newRestrictions = new HashSet<OWLClassExpression>(); + newRestrictions.add(ce); + OWLClassExpression filler = ce.getFiller(); + filler.accept(this); + Set<OWLClassExpression> fillerSuperClassExpressions = stack.pop(); + for (OWLClassExpression fillerSup : fillerSuperClassExpressions) { + newRestrictions.add(df.getOWLObjectSomeValuesFrom(ce.getProperty(), fillerSup)); + } + stack.push(newRestrictions); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectAllValuesFrom) + */ + @Override + public void visit(OWLObjectAllValuesFrom ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectHasValue) + */ + @Override + public void visit(OWLObjectHasValue ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectMinCardinality) + */ + @Override + public void visit(OWLObjectMinCardinality ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectExactCardinality) + */ + @Override + public void visit(OWLObjectExactCardinality ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectMaxCardinality) + */ + @Override + public void visit(OWLObjectMaxCardinality ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectHasSelf) + */ + @Override + public void visit(OWLObjectHasSelf ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectOneOf) + */ + @Override + public void visit(OWLObjectOneOf ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataSomeValuesFrom) + */ + @Override + public void visit(OWLDataSomeValuesFrom ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataAllValuesFrom) + */ + @Override + public void visit(OWLDataAllValuesFrom ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataHasValue) + */ + @Override + public void visit(OWLDataHasValue ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataMinCardinality) + */ + @Override + public void visit(OWLDataMinCardinality ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataExactCardinality) + */ + @Override + public void visit(OWLDataExactCardinality ce) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataMaxCardinality) + */ + @Override + public void visit(OWLDataMaxCardinality ce) { + } + } + + + public static void main(String[] args) throws Exception{ + ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); + String s = "@prefix : <http://example.org/> ." + + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ." + + "@prefix owl: <http://www.w3.org/2002/07/owl#> ." + + "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ." + + ":A a owl:Class . " + + ":B a owl:Class . " + + ":C a owl:Class . " + + ":D a owl:Class . " + + ":r a owl:ObjectProperty . " + + ":A rdfs:subClassOf [ a owl:Restriction; owl:onProperty :r; owl:someValuesFrom :B]." + + ":B rdfs:subClassOf :C." + + ":C rdfs:subClassOf [ a owl:Restriction; owl:onProperty :r; owl:someValuesFrom :D]." + + ":a a :A."; + + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = man.loadOntologyFromOntologyDocument(new ByteArrayInputStream(s.getBytes())); + ExistentialRestrictionMaterialization mat = new ExistentialRestrictionMaterialization(ontology); + Set<OWLClassExpression> superClassExpressions = mat.materialize("http://example.org/A"); + for (OWLClassExpression sup : superClassExpressions) { + System.out.println(sup); + } + } + +} Added: trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/MaterializableFastInstanceChecker.java 2014-05-27 13:03:09 UTC (rev 4275) @@ -0,0 +1,1237 @@ +/** + * Copyright (C) 2007-2011, 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.reasoning; + +import java.io.File; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.apache.log4j.Logger; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.ComponentAnn; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasoningMethodUnsupportedException; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.owl.Axiom; +import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.Constant; +import org.dllearner.core.owl.DataRange; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypeSomeRestriction; +import org.dllearner.core.owl.DatatypeValueRestriction; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DoubleMaxValue; +import org.dllearner.core.owl.DoubleMinValue; +import org.dllearner.core.owl.Entity; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.ObjectCardinalityRestriction; +import org.dllearner.core.owl.ObjectMaxCardinalityRestriction; +import org.dllearner.core.owl.ObjectMinCardinalityRestriction; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyExpression; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.ObjectValueRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.Union; +import org.dllearner.parser.ParseException; +import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.ConceptTransformation; +import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; +import org.dllearner.utilities.owl.OWLAPIConverter; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.propertyeditors.StringTrimmerEditor; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; + +/** + * Reasoner for fast instance checks. It works by completely dematerialising the + * knowledge base to speed up later reasoning requests. It then continues by + * only considering one model of the knowledge base (TODO: more explanation), + * which is neither correct nor complete, but sufficient in many cases. A big + * advantage of the algorithm is that it does not need even need to perform any + * set modifications (union, intersection, difference), so it avoids any Java + * object creation, which makes it extremely fast compared to standard + * reasoners. + * + * Meanwhile, the algorithm has been extended to also perform fast retrieval + * operations. However, those need write access to memory and potentially have + * to deal with all individuals in a knowledge base. For many knowledge bases, + * they should still be reasonably fast. + * + * @author Jens Lehmann + * + */ +@ComponentAnn(name = "fast instance checker", shortName = "fic", version = 0.9) +public class MaterializableFastInstanceChecker extends AbstractReasonerComponent { + + private static Logger logger = Logger.getLogger(MaterializableFastInstanceChecker.class); + +// private boolean defaultNegation = true; + + private Set<NamedClass> atomicConcepts; + private Set<ObjectProperty> atomicRoles; + private SortedSet<DatatypeProperty> datatypeProperties; + private SortedSet<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + private SortedSet<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + private SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); + private SortedSet<DatatypeProperty> stringDatatypeProperties = new TreeSet<DatatypeProperty>(); + private TreeSet<Individual> individuals; + + // private ReasonerComponent rs; + + private OWLAPIReasoner rc; + + // we use sorted sets (map indices) here, because they have only log(n) + // complexity for checking whether an element is contained in them + // instances of classes + private Map<NamedClass, TreeSet<Individual>> classInstancesPos = new TreeMap<NamedClass, TreeSet<Individual>>(); + private Map<NamedClass, TreeSet<Individual>> classInstancesNeg = new TreeMap<NamedClass, TreeSet<Individual>>(); + // object property mappings + private Map<ObjectProperty, Map<Individual, SortedSet<Individual>>> opPos = new TreeMap<ObjectProperty, Map<Individual, SortedSet<Individual>>>(); + // data property mappings + private Map<DatatypeProperty, Map<Individual, SortedSet<Constant>>> dpPos = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Constant>>>(); + + + // datatype property mappings + // we have one mapping for true and false for efficiency reasons + private Map<DatatypeProperty, TreeSet<Individual>> bdPos = new TreeMap<DatatypeProperty, TreeSet<Individual>>(); + private Map<DatatypeProperty, TreeSet<Individual>> bdNeg = new TreeMap<DatatypeProperty, TreeSet<Individual>>(); + // for int and double we assume that a property can have several values, + // althoug this should be rare, + // e.g. hasValue(object,2) and hasValue(object,3) + private Map<DatatypeProperty, Map<Individual, SortedSet<Double>>> dd = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Double>>>(); + private Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Integer>>>(); + private Map<DatatypeProperty, Map<Individual, SortedSet<String>>> sd = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<String>>>(); + + @ConfigOption(name="defaultNegation", description = "Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.", defaultValue = "true", required = false) + private boolean defaultNegation = true; + + @ConfigOption(name = "forAllRetrievalSemantics", description = "This option controls how to interpret the all quantifier in forall r.C. The standard option is" + + "to return all those which do not have an r-filler not in C. The domain semantics is to use those" + + "which are in the domain of r and do not have an r-filler not in C. The forallExists semantics is to"+ + "use those which have at least one r-filler and do not have an r-filler not in C.",defaultValue = "standard",propertyEditorClass = StringTrimmerEditor.class) + private ForallSemantics forallSemantics = ForallSemantics.Standard; + + private boolean materializeExistentialRestrictions = true; + + + public enum ForallSemantics { + Standard, // standard all quantor + NonEmpty, // p only C for instance a returns false if there is no fact p(a,x) for any x + SomeOnly // p only C for instance a returns false if there is no fact p(a,x) with x \ in C + } + + /** + * Creates an instance of the fast instance checker. + */ + public MaterializableFastInstanceChecker() { + } + + public MaterializableFastInstanceChecker(TreeSet<Individual> individuals, + Map<NamedClass, TreeSet<Individual>> classInstancesPos, + Map<ObjectProperty, Map<Individual, SortedSet<Individual>>> opPos, + Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id, + Map<DatatypeProperty, TreeSet<Individual>> bdPos, + Map<DatatypeProperty, TreeSet<Individual>> bdNeg, + KnowledgeSource... sources) { + super(new HashSet<KnowledgeSource>(Arrays.asList(sources))); + this.individuals = individuals; + this.classInstancesPos = classInstancesPos; + this.opPos = opPos; + this.id = id; + this.bdPos = bdPos; + this.bdNeg = bdNeg; + + if(rc == null){ + rc = new OWLAPIReasoner(new HashSet<KnowledgeSource>(Arrays.asList(sources))); + try { + rc.init(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + + atomicConcepts = rc.getNamedClasses(); + datatypeProperties = rc.getDatatypeProperties(); + booleanDatatypeProperties = rc.getBooleanDatatypeProperties(); + doubleDatatypeProperties = rc.getDoubleDatatypeProperties(); + intDatatypeProperties = rc.getIntDatatypeProperties(); + stringDatatypeProperties = rc.getStringDatatypeProperties(); + atomicRoles = rc.getObjectProperties(); + + for (NamedClass atomicConcept : rc.getNamedClasses()) { + TreeSet<Individual> pos = classInstancesPos.get(atomicConcept); + if(pos != null){ + classInstancesNeg.put(atomicConcept, (TreeSet<Individual>) Helper.difference(individuals, pos)); + } else { + classInstancesPos.put(atomicConcept, new TreeSet<Individual>()); + classInstancesNeg.put(atomicConcept, individuals); + } + } + for(ObjectProperty p : atomicRoles){ + if(opPos.get(p) == null){ + opPos.put(p, new HashMap<Individual, SortedSet<Individual>>()); + } + } + + for (DatatypeProperty dp : booleanDatatypeProperties) { + if(bdPos.get(dp) == null){ + bdPos.put(dp, new TreeSet<Individual>()); + } + if(bdNeg.get(dp) == null){ + bdNeg.put(dp, new TreeSet<Individual>()); + } + + } + } + + public MaterializableFastInstanceChecker(Set<KnowledgeSource> sources) { + super(sources); + } + + public MaterializableFastInstanceChecker(KnowledgeSource... sources) { + super(new HashSet<KnowledgeSource>(Arrays.asList(sources))); + } + + /** + * @return The name of this component. + */ + public static String getName() { + return "fast instance checker"; + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.Component#init() + */ + @Override + public void init() throws ComponentInitException { + + if (rc == null) { + rc = new OWLAPIReasoner(sources); + rc.init(); + } + atomicConcepts = rc.getNamedClasses(); + datatypeProperties = rc.getDatatypeProperties(); + booleanDatatypeProperties = rc.getBooleanDatatypeProperties(); + doubleDatatypeProperties = rc.getDoubleDatatypeProperties(); + intDatatypeProperties = rc.getIntDatatypeProperties(); + stringDatatypeProperties = rc.getStringDatatypeProperties(); + atomicRoles = rc.getObjectProperties(); + individuals = (TreeSet<Individual>) rc.getIndividuals(); + + dematerialize(); + } + + private void dematerialize(){ + long dematStartTime = System.currentTimeMillis(); + + //atomic concepts + logger.debug("dematerialising concepts"); + for (NamedClass atomicConcept : rc.getNamedClasses()) { + SortedSet<Individual> pos = rc.getIndividuals(atomicConcept); + classInstancesPos.put(atomicConcept, (TreeSet<Individual>) pos); + + if (isDefaultNegation()) { + classInstancesNeg.put(atomicConcept, (TreeSet<Individual>) Helper.difference(individuals, pos)); + } else { + // Pellet needs approximately infinite time to answer + // negated queries + // on the carcinogenesis data set (and probably others), so + // we have to + // be careful here + Negation negatedAtomicConcept = new Negation(atomicConcept); + classInstancesNeg.put(atomicConcept, (TreeSet<Individual>) rc.getIndividuals(negatedAtomicConcept)); + } + } + + //atomic object properties + logger.debug("dematerialising object properties"); + for (ObjectProperty atomicRole : atomicRoles) { + opPos.put(atomicRole, rc.getPropertyMembers(atomicRole)); + } + + //atomic datatype properties + logger.debug("dematerialising datatype properties"); + for (DatatypeProperty atomicRole : datatypeProperties) { + dpPos.put(atomicRole, rc.getDatatypeMembers(atomicRole)); + } + + //boolean datatype properties + for (DatatypeProperty dp : booleanDatatypeProperties) { + bdPos.put(dp, (TreeSet<Individual>) rc.getTrueDatatypeMembers(dp)); + bdNeg.put(dp, (TreeSet<Individual>) rc.getFalseDatatypeMembers(dp)); + } + + //integer datatype properties + for (DatatypeProperty dp : intDatatypeProperties) { + id.put(dp, rc.getIntDatatypeMembers(dp)); + } + + //double datatype properties + for (DatatypeProperty dp : doubleDatatypeProperties) { + dd.put(dp, rc.getDoubleDatatypeMembers(dp)); + } + + //String datatype properties + for (DatatypeProperty dp : stringDatatypeProperties) { + sd.put(dp, rc.getStringDatatypeMembers(dp)); + } + + if(materializeExistentialRestrictions){ + ExistentialRestrictionMaterialization materialization = new ExistentialRestrictionMaterialization(rc.getReasoner().getRootOntology()); + for (NamedClass cls : atomicConcepts) { + TreeSet<Individual> individuals = classInstancesPos.get(cls); + Set<OWLClassExpression> superClass = materialization.materialize(cls.getName()); + for (OWLClassExpression sup : superClass) { + fill(individuals, DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(sup)); + } + } + } + + long dematDuration = System.currentTimeMillis() - dematStartTime; + logger.debug("TBox dematerialised in " + dematDuration + " ms"); + } + + private void fill(SortedSet<Individual> individuals, Description d){ + if(d instanceof Intersection){ + List<Description> children = d.getChildren(); + for (Description child : children) { + fill(individuals, child); + } + } else if(d instanceof ObjectSomeRestriction){ + ObjectProperty role = (ObjectProperty) ((ObjectSomeRestriction) d).getRole(); + Map<Individual, SortedSet<Individual>> map = opPos.get(role); + //create new individual as object value for each individual + SortedSet<Individual> newIndividuals = new TreeSet<Individual>(); + int i = 0; + for (Individual individual : individuals) { + Individual newIndividual = new Individual("http://dllearner.org#genInd_" + i++); + newIndividuals.add(newIndividual); + SortedSet<Individual> values = map.get(individual); + if(values == null){ + values = new TreeSet<Individual>(); + map.put(individual, values); + } + values.add(newIndividual); + } + fill(newIndividuals, d.getChild(0)); + + } else if(d instanceof NamedClass){ + classInstancesPos.get(d).addAll(individuals); + } else { + throw new UnsupportedOperationException("Should not happen."); + } + } + + @Override + public boolean hasTypeImpl(Description description, Individual individual) + throws ReasoningMethodUnsupportedException { + +// System.out.println("FIC: " + description + " " + individual); + + if (description instanceof NamedClass) { + if(((NamedClass) description).getURI().equals(Thing.instance.getURI())){ + return true; + } else + if(!atomicConcepts.contains(description)) { + throw new ReasoningMethodUnsupportedException("Class " + description + " is not contained in knowledge base."); + } + return classInstancesPos.get((NamedClass) description).contains(individual); + } else if (description instanceof Negation) { + Description child = description.getChild(0); + if (child instanceof NamedClass) { + return classInstancesNeg.get((NamedClass) child).contains(individual); + } else { + // default negation + if(isDefaultNegation()) { + return !hasTypeImpl(child, individual); + } else { + logger.debug("Converting description to negation normal form in fast instance check (should be avoided if possible)."); + Description nnf = ConceptTransformation.transformToNegationNormalForm(child); + return hasTypeImpl(nnf, individual); + } +// throw new ReasoningMethodUnsupportedException("Instance check for description " +// + description +// + " unsupported. Description needs to be in negation normal form."); + } + } else if (description instanceof Thing) { + return true; + } else if (description instanceof Nothing) { + return false; + } else if (description instanceof Union) { + // if the individual is instance of any of the subdescription of + // the union, we return true + List<Description> children = description.getChildren(); + for (Description child : children) { + if (hasTypeImpl(child, individual)) { + return true; + } + } + return false; + } else if (description instanceof Intersection) { + // if the individual is instance of all of the subdescription of + // the union, we return true + List<Description> children = description.getChildren(); + for (Description child : children) { + if (!hasTypeImpl(child, individual)) { + return false; + } + } + return true; + } else if (description instanceof ObjectSomeRestriction) { + ObjectPropertyExpression ope = ((ObjectSomeRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + + if (mapping == null) { + logger.warn("Instance check of a description with an undefined property (" + op + + ")."); + return false; + } + SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + if (roleFillers == null) { + return false; + } + for (Individual roleFiller : roleFillers) { + if (hasTypeImpl(child, roleFiller)) { + return true; + } + } + return false; + } else if (description instanceof ObjectAllRestriction) { + ObjectPropertyExpression ope = ((ObjectAllRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + + if (mapping == null) { + logger.warn("Instance check of a description with an undefinied property (" + op + + ")."); + return true; + } + SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + + if (roleFillers == null) { + if(forallSemantics == ForallSemantics.Standard) { + return true; + } else { + return false; + } + } + boolean hasCorrectFiller = false; + for (Individual roleFiller : roleFillers) { + if (hasTypeImpl(child, roleFiller)) { + hasCorrectFiller = true; + } else { + return false; + } + } + + if(forallSemantics == ForallSemantics.SomeOnly) { + return hasCorrectFiller; + } else { + return true; + } + } else if (description instanceof ObjectMinCardinalityRestriction) { + ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + + if (mapping == null) { + logger.warn("Instance check of a description with an undefinied property (" + op + + ")."); + return true; + } + + int number = ((ObjectCardinalityRestriction) description).getNumber(); + int nrOfFillers = 0; + +// SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + SortedSet<Individual> roleFillers = mapping.get(individual); +// System.out.println(roleFillers); + + // special case: there are always at least zero fillers + if (number == 0) { + return true; + } + // return false if there are none or not enough role fillers + if (roleFillers == null || roleFillers.size() < number) { + return false; + } + + int index = 0; + for (Individual roleFiller : roleFillers) { + index++; + if (hasTypeImpl(child, roleFiller)) { + nrOfFillers++; + if (nrOfFillers == number) { + return true; + } + // early abort: e.g. >= 10 hasStructure.Methyl; + // if there are 11 fillers and 2 are not Methyl, the result + // is false + } else { + if (roleFillers.size() - index < number) { + return false; + } + } + } + return false; + } else if (description instanceof ObjectMaxCardinalityRestriction) { + ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + + if (mapping == null) { + logger.warn("Instance check of a description with an undefinied property (" + op + + ")."); + return true; + } + + int number = ((ObjectCardinalityRestriction) description).getNumber(); + int nrOfFillers = 0; + + SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + // return true if there are none or not enough role fillers + if (roleFillers == null || roleFillers.size() < number) { + return true; + } + + int index = 0; + for (Individual roleFiller : roleFillers) { + index++; + if (hasTypeImpl(child, roleFiller)) { + nrOfFillers++; + if (nrOfFillers > number) { + return false; + } + // early abort: e.g. <= 5 hasStructure.Methyl; + // if there are 6 fillers and 2 are not Methyl, the result + // is true + } else { + if (roleFillers.size() - index <= number) { + return true; + } + } + } + return true; + } else if (description instanceof ObjectValueRestriction) { + Individual i = ((ObjectValueRestriction)description).getIndividual(); + ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)description).getRestrictedPropertyExpression(); + + Set<Individual> inds = opPos.get(op).get(individual); + return inds == null ? false : inds.contains(i); + } else if (description instanceof BooleanValueRestriction) { + DatatypeProperty dp = ((BooleanValueRestriction) description) + .getRestrictedPropertyExpression(); + boolean value = ((BooleanValueRestriction) description).getBooleanValue(); + + if (value) { + // check whether the individual is in the set of individuals + // mapped + // to true by this datatype property + return bdPos.get(dp).contains(individual); + } else { + return bdNeg.get(dp).contains(individual); + } + } else if (description instanceof DatatypeSomeRestriction) { + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; + DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); + DataRange dr = dsr.getDataRange(); + if(dr.isDatatype() +// && ((Datatype)dr).isTopDatatype() + ){ + if(dpPos.get(dp).containsKey(individual)){ + return true; + } else { + return false; + } + } + SortedSet<Double> values = dd.get(dp).get(individual); + + // if there is no filler for this individual and property we + // need to return false + if (values == null) { + return false; + } + + if (dr instanceof DoubleMaxValue) { + return (values.first() <= ((DoubleMaxValue) dr).getValue()); + } else if (dr instanceof DoubleMinValue) { + return (values.last() >= ((DoubleMinValue) dr).getValue()); + } + } else if (description instanceof DatatypeValueRestriction) { + String i = ((DatatypeValueRestriction)description).getValue().getLiteral(); + DatatypeProperty dp = ((DatatypeValueRestriction)description).getRestrictedPropertyExpression(); + + Set<String> inds = sd.get(dp).get(individual); + return inds == null ? false : inds.contains(i); + } + + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported."); + } + + @Override + public SortedSet<Individual> getIndividualsImpl(Description concept) throws ReasoningMethodUnsupportedException { + return getIndividualsImplFast(concept); + } + + public SortedSet<Individual> getIndividualsImplStandard(Description concept) + throws ReasoningMethodUnsupportedException { + if (concept instanceof NamedClass) { + return classInstancesPos.get((NamedClass) concept); + } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { + return classInstancesNeg.get((NamedClass) concept.getChild(0)); + } + + // return rs.retrieval(concept); + SortedSet<Individual> inds = new TreeSet<Individual>(); + for (Individual i : individuals) { + if (hasType(concept, i)) { + inds.add(i); + } + } + return inds; + } + + @SuppressWarnings("unchecked") + public SortedSet<Individual> getIndividualsImplFast(Description description) + throws ReasoningMethodUnsupportedException { + // policy: returned sets are clones, i.e. can be modified + // (of course we only have to clone the leafs of a class description tree) + if (description instanceof NamedClass) { + if(classInstancesPos.containsKey((NamedClass) description)){ + return (TreeSet<Individual>) classInstancesPos.get((NamedClass) description).clone(); + } else { + return new TreeSet<Individual>(); + } + } else if (description instanceof Negation) { + if(description.getChild(0) instanceof NamedClass) { + return (TreeSet<Individual>) classInstancesNeg.get((NamedClass) description.getChild(0)).clone(); + } + // implement retrieval as default negation + return Helper.difference((TreeSet<Individual>) individuals.clone(), getIndividualsImpl(description.getChild(0))); + } else if (description instanceof Thing) { + return (TreeSet<Individual>) individuals.clone(); + } else if (description instanceof Nothing) { + return new TreeSet<Individual>(); + } else if (description instanceof Union) { + // copy instances of first element and then subtract all others + SortedSet<Individual> ret = getIndividualsImpl(description.getChild(0)); + int childNr = 0; + for(Description child : description.getChildren()) { + if(childNr != 0) { + ret.addAll(getIndividualsImpl(child)); + } + childNr++; + } + return ret; + } else if (description instanceof Intersection) { + // copy instances of first element and then subtract all others + SortedSet<Individual> ret = getIndividualsImpl(description.getChild(0)); + int childNr = 0; + for(Description child : description.getChildren()) { + if(childNr != 0) { + ret.retainAll(getIndividualsImpl(child)); + } + childNr++; + } + return ret; + } else if (description instanceof ObjectSomeRestriction) { + SortedSet<Individual> targetSet = getIndividualsImpl(description.getChild(0)); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); + + ObjectPropertyExpression ope = ((ObjectSomeRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Retrieval for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + + // each individual is connected to a set of individuals via the property; + // we loop through the complete mapping + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + SortedSet<Individual> inds = entry.getValue(); + for(Individual ind : inds) { + if(targetSet.contains(ind)) { + returnSet.add(entry.getKey()); + // once we found an individual, we do not need to check the others + continue; + } + } + } + return returnSet; + } else if (description instanceof ObjectAllRestriction) { + // \forall restrictions are difficult to handle; assume we want to check + // \forall hasChild.male with domain(hasChild)=Person; then for all non-persons + // this is satisfied trivially (all of their non-existing children are male) +// if(!configurator.getForallRetrievalSemantics().equals("standard")) { +// throw new Error("Only forallExists semantics currently implemented."); +// } + + // problem: we need to make sure that \neg \exists r.\top \equiv \forall r.\bot + // can still be reached in an algorithm (\forall r.\bot \equiv \bot under forallExists + // semantics) + + SortedSet<Individual> targetSet = getIndividualsImpl(description.getChild(0)); + + ObjectPropertyExpression ope = ((ObjectAllRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); +// SortedSet<Individual> returnSet = new TreeSet<Individual>(mapping.keySet()); + SortedSet<Individual> returnSet = (SortedSet<Individual>) individuals.clone(); + + // each individual is connected to a set of individuals via the property; + // we loop through the complete mapping + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + SortedSet<Individual> inds = entry.getValue(); + for(Individual ind : inds) { + if(!targetSet.contains(ind)) { + returnSet.remove(entry.getKey()); + continue; + } + } + } + return returnSet; + } else if (description instanceof ObjectMinCardinalityRestriction) { + ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + SortedSet<Individual> targetSet = getIndividualsImpl(child); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); + + int number = ((ObjectCardinalityRestriction) description).getNumber(); + + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + int nrOfFillers = 0; + int index = 0; + SortedSet<Individual> inds = entry.getValue(); + + // we do not need to run tests if there are not sufficiently many fillers + if(inds.size() < number) { + continue; + } + + for(Individual ind : inds) { + // stop inner loop when nr of fillers is reached + if(nrOfFillers >= number) { + returnSet.add(entry.getKey()); + break; + } + // early abort when too many instance checks failed + if (inds.size() - index < number) { + break; + } + if(targetSet.contains(ind)) { + nrOfFillers++; + } + index++; + } + } + + return returnSet; + } else if (description instanceof ObjectMaxCardinalityRestriction) { + ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + SortedSet<Individual> targetSet = getIndividualsImpl(child); + // initially all individuals are in the return set and we then remove those + // with too many fillers + SortedSet<Individual> returnSet = (SortedSet<Individual>) individuals.clone(); + + int number = ((ObjectCardinalityRestriction) description).getNumber(); + + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + int nrOfFillers = 0; + int index = 0; + SortedSet<Individual> inds = entry.getValue(); + + // we do not need to run tests if there are not sufficiently many fillers + if(number < inds.size()) { + returnSet.add(entry.getKey()); + continue; + } + + for(Individual ind : inds) { + // stop inner loop when nr of fillers is reached + if(nrOfFillers >= number) { + break; + } + // early abort when too many instance are true already + if (inds.size() - index < number) { + returnSet.add(entry.getKey()); + break; + } + if(targetSet.contains(ind)) { + nrOfFillers++; + } + index++; + } + } + + return returnSet; + } else if (description instanceof ObjectValueRestriction) { + Individual i = ((ObjectValueRestriction)description).getIndividual(); + ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)description).getRestrictedPropertyExpression(); + + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); + + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + if(entry.getValue().contains(i)) { + returnSet.add(entry.getKey()); + } + } + return returnSet; + } else if (description instanceof BooleanValueRestriction) { + DatatypeProperty dp = ((BooleanValueRestriction) description) + .getRestrictedPropertyExpression(); + boolean value = ((BooleanValueRestriction) description).getBooleanValue(); + + if (value) { + return (TreeSet<Individual>) bdPos.get(dp).clone(); + } else { + return (TreeSet<Individual>) bdNeg.get(dp).clone(); + } + } else if (description instanceof DatatypeSomeRestriction) { + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; + DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); + DataRange dr = dsr.getDataRange(); + + Map<Individual, SortedSet<Double>> mapping = dd.get(dp); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); + + if (dr instanceof DoubleMaxValue) { + for(Entry<Individual, SortedSet<Double>> entry : mapping.entrySet()) { + if(entry.getValue().first() <= ((DoubleMaxValue)dr).getValue()) { + returnSet.add(entry.getKey()); + } + } + } else if (dr instanceof DoubleMinValue) { + for(Entry<Individual, SortedSet<Double>> entry : mapping.entrySet()) { + if(entry.getValue().last() >= ((DoubleMinValue)dr).getValue()) { + returnSet.add(entry.getKey()); + } + } + } + } + + throw new ReasoningMethodUnsupportedException("Retrieval for description " + + description + " unsupported."); + + // return rs.retrieval(concept); +// SortedSet<Individual> inds = new TreeSet<Individual>(); +// for (Individual i : individuals) { +// if (hasType(concept, i)) { +// inds.add(i); +// } +// } +// return inds; + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.Reasoner#getAtomicConcepts() + */ + @Override + public Set<NamedClass> getNamedClasses() { + return atomicConcepts; + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.Reasoner#getAtomicRoles() + */ + @Override + public Set<ObjectProperty> getObjectProperties() { + return atomicRoles; + } + + @Override + public SortedSet<DatatypeProperty> getDatatypePropertiesImpl() { + return datatypeProperties; + } + + @Override + public SortedSet<DatatypeProperty> getBooleanDatatypePropertiesImpl() { + return booleanDatatypeProperties; + } + + @Override + public SortedSet<DatatypeProperty> getDoubleDatatypePropertiesImpl() { + return doubleDatatypeProperties; + } + + @Override + public SortedSet<DatatypeProperty> getIntDatatypePropertiesImpl() { + return intDatatypeProperties; + } + + @Override + public SortedSet<DatatypeProperty> getStringDatatypePropertiesImpl() { + return stringDatatypeProperties; + } + + @Override + protected SortedSet<Description> getSuperClassesImpl(Description concept) throws ReasoningMethodUnsupportedException { + return rc.getSuperClassesImpl(concept); + } + + @Override + protected SortedSet<Description> getSubClassesImpl(Description concept) throws ReasoningMethodUnsupportedException { + return rc.getSubClassesImpl(concept); + } + + @Override + protected SortedSet<ObjectProperty> getSuperPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { + return rc.getSuperPropertiesImpl(role); + } + + @Override + protected SortedSet<ObjectProperty> getSubPropertiesImpl(ObjectProperty role) throws ReasoningMethodUnsupportedException { + return rc.getSubPropertiesImpl(role); + } + + @Override + protected SortedSet<DatatypeProperty> getSuperPropertiesImpl(DatatypeProperty role) throws ReasoningMethodUnsupportedException { + return rc.getSuperPropertiesImpl(role); + } + + @Override + protected SortedSet<DatatypeProperty> getSubPropertiesImpl(DatatypeProperty role) throws ReasoningMethodUnsupportedException { + return rc.getSubPropertiesImpl(role); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.Reasoner#getIndividuals() + */ + @Override + public SortedSet<Individual> getIndividuals() { + return individuals; + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.Reasoner#getReasonerType() + */ + @Override + public ReasonerType getReasonerType() { + return ReasonerType.FAST_INSTANCE_CHECKER; + } + +// @Override +// public ClassHierarchy getClassHierarchy() { +// return rc.getClassHierarchy(); +// } + +// @Override +// public void prepareRoleHierarchyImpl(Set<ObjectProperty> allowedRoles) { +// rc.prepareRoleHierarchy(allowedRoles); +// } + +// @Override +// public ObjectPropertyHierarchy getRoleHierarchy() { +// return rc.getRoleHierarchy(); +// } + +// @Override +// public void prepareDatatypePropertyHierarchyImpl(Set<DatatypeProperty> allowedRoles) { +// rc.prepareDatatypePropertyHierarchyImpl(allowedRoles); +// } + +// @Override +// public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { +// return rc.getDatatypePropertyHierarchy(); +// } + + @Override + public boolean isSuperClassOfImpl(Description superConcept, Description subConcept) { + // Negation neg = new Negation(subConcept); + // Intersection c = new Intersection(neg,superConcept); + // return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); + return rc.isSuperClassOfImpl(superConcept, subConcept); + } + + /** + * Test method for fast instance checker. + * + * @param args + * No arguments supported. + * @throws ComponentInitException Component cannot be initialised. + * @throws ParseException File cannot be parsed. + * @throws ReasoningMethodUnsupportedException Reasoning method not supported. + */ + public static void main(String[] args) throws Exception, + ReasoningMethodUnsupportedException { + + String ontologyURL = "/home/me/tools/pellet/test/data/modularity/koala.owl"; + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory dataFactory = man.getOWLDataFactory(); + OWLOntology ontology = man.loadOntologyFromOntologyDocument(new File(ontologyURL)); + OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance(); + OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(ontology); + OWLClass cls = dataFactory.getOWLClass(IRI.create("http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#Koala")); + Set<OWLClassExpression> superClasses = cls.getSuperClasses(ontology); + System.out.println(superClasses); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.Reasoner#getBaseURI() + */ + @Override + public String getBaseURI() { + return rc.getBaseURI(); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.Reasoner#getPrefixes() + */ + @Override + public Map<String, String> getPrefixes() { + return rc.getPrefixes(); + } + + public void setPrefixes(Map<String, String> prefixes) { + rc.setPrefixes(prefixes); + } + + /** + * @param baseURI the baseURI to set + */ + public void setBaseURI(String baseURI) { + rc.setBaseURI(baseURI); + } + + @Override + public Description getDomainImpl(ObjectProperty objectProperty) { + return rc.getDomain(objectProperty); + } + + @Override + public Description getDomainImpl(DatatypeProperty datatypeProperty) { + return rc.getDomain(datatypeProperty); + } + + @Override + public Description getRangeImpl(ObjectProperty objectProperty) { + return rc.getRange(objectProperty); + } + + @Override + public DataRange getRangeImpl(DatatypeProperty datatypeProperty) { + return rc.getRange(datatypeProperty); + } + + @Override + public Map<Individual, SortedSet<Individual>> getPropertyMembersImpl(ObjectProperty atomicRole) { + return opPos.get(atomicRole); + } + + @Override + public final SortedSet<Individual> getTrueDatatypeMembersImpl(DatatypeProperty datatypeProperty) { + return bdPos.get(datatypeProperty); + } + + @Override + public final SortedSet<Individual> getFalseDatatypeMembersImpl(DatatypeProperty datatypeProperty) { + return bdNeg.get(datatypeProperty); + } + + @Override + public Map<Individual, SortedSet<Integer>> getIntDatatypeMembersImpl( + DatatypeProperty datatypeProperty) { + return id.get(datatypeProperty); + } + + @Override + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembersImpl( + DatatypeProperty datatypeProperty) { + return dd.get(datatypeProperty); + } + + @Override + public Map<Individual, SortedSet<Constant>> getDatatypeMembersImpl( + DatatypeProperty datatypeProperty) { + return dpPos.get(datatypeProperty); +// return rc.getDatatypeMembersImpl(datatypeProperty); + } + + @Override + public Set<Individual> getRelatedIndividualsImpl(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + return rc.getRelatedIndividuals(individual, objectProperty); + } + + @Override + protected Map<ObjectProperty,Set<Individual>> getObjectPropertyRelationshipsImpl(Individual individual) { + return rc.getObjectPropertyRelationships(individual); + } + + @Override + public Set<Constant> getRelatedValuesImpl(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + return rc.getRelatedValues(individual, datatypeProperty); + } + + @Override + public boolean isSatisfiableImpl() { + return rc.isSatisfiable(); + } + + @Override + public Set<Constant> getLabelImpl(Entity entity) throws ReasoningMethodUnsupportedException { + return rc.getLabel(entity); + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.ReasonerComponent#releaseKB() + */ + @Override + public void releaseKB() { + rc.releaseKB(); + } + +// @Override +// public boolean hasDatatypeSupport() { +// return true; +// } + + /* (non-Javadoc) + * @see org.dllearner.core.ReasonerComponent#getTypesImpl(org.dllearner.core.owl.Individual) + */ + @Override + protected Set<NamedClass> getTypesImpl(Individual individual) { + return rc.getTypesImpl(individual); + } + + /* (non-Javadoc) + * @see org.dllearner.core.BaseReasoner#remainsSatisfiable(org.dllearner.core.owl.Axiom) + */ + @Override + public boolean remainsSatisfiableImpl(Axiom axiom) { + return rc.remainsSatisfiableImpl(axiom); + } + + @Override + protected Set<Description> getAssertedDefinitionsImpl(NamedClass nc) { + return rc.getAssertedDefinitionsImpl(nc); + } + + public OWLAPIReasoner getReasonerComponent() { + return rc; + } + + @Autowired(required = false) + public void setReasonerComponent(OWLAPIReasoner rc) { + this.rc = rc; + } + + public boolean isDefaultNegation() { + return defaultNegation; + } + + public void setDefaultNegation(boolean defaultNegation) { + this.defaultNegation = defaultNegation; + } + + public ForallSemantics getForAllSemantics() { + return forallSemantics; + } + + public void setForAllSemantics(ForallSemantics forallSemantics) { + this.forallSemantics = forallSemantics; + } + + /** + * @param materializeExistentialRestrictions the materializeExistentialRestrictions to set + */ + public void setMaterializeExistentialRestrictions(boolean materializeExistentialRestrictions) { + this.materializeExistentialRestrictions = materializeExistentialRestrictions; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-27 12:58:43
|
Revision: 4274 http://sourceforge.net/p/dl-learner/code/4274 Author: lorenz_b Date: 2014-05-27 12:58:39 +0000 (Tue, 27 May 2014) Log Message: ----------- Added equals for complex descriptions. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/rendering/Edge.java trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectValueRestriction.java trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-27 12:57:42 UTC (rev 4273) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-27 12:58:39 UTC (rev 4274) @@ -1581,7 +1581,7 @@ for (QueryTree<N> child : children) { Vertex childVertex = new Vertex(child.getId(), prefixed(prefixes, child.getUserObject().toString())); graph.addVertex(childVertex); - Edge edge = new Edge(Integer.valueOf(parent.getId() + "000" + childVertex.getId()), prefixed(prefixes, tree.getEdge(child).toString())); + Edge edge = new Edge(Long.valueOf(parent.getId() + "0" + childVertex.getId()), prefixed(prefixes, tree.getEdge(child).toString())); graph.addEdge(parent, childVertex, edge); buildGraph(graph, child); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/rendering/Edge.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/rendering/Edge.java 2014-05-27 12:57:42 UTC (rev 4273) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/rendering/Edge.java 2014-05-27 12:58:39 UTC (rev 4274) @@ -1,10 +1,10 @@ package org.dllearner.algorithms.qtl.datastructures.rendering; public class Edge { - int id; + long id; String label; - public Edge(int id, String label) { + public Edge(long id, String label) { this.id = id; this.label = label; } @@ -12,7 +12,7 @@ /** * @return the id */ - public int getId() { + public long getId() { return id; } @@ -27,7 +27,7 @@ public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + id; + result = prime * result + (int) (id ^ (id >>> 32)); return result; } @@ -44,4 +44,6 @@ return false; return true; } + + } \ No newline at end of file Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java 2014-05-27 12:57:42 UTC (rev 4273) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/NamedClass.java 2014-05-27 12:58:39 UTC (rev 4274) @@ -111,6 +111,8 @@ return true; if (obj == null) return false; + if(obj==Thing.instance && name.equals(Thing.uri.toString())) + return true; if (getClass() != obj.getClass()) return false; NamedClass other = (NamedClass) obj; Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java 2014-05-27 12:57:42 UTC (rev 4273) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectProperty.java 2014-05-27 12:58:39 UTC (rev 4274) @@ -33,9 +33,6 @@ */ public class ObjectProperty extends ObjectPropertyExpression implements Property, Comparable<ObjectProperty>{ - /** - * - */ private static final long serialVersionUID = -3343070247923446690L; public ObjectProperty(String name) { Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java 2014-05-27 12:57:42 UTC (rev 4273) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectSomeRestriction.java 2014-05-27 12:58:39 UTC (rev 4274) @@ -61,5 +61,37 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getChild(0) == null) ? 0 : getChild(0).hashCode()); + result = prime * result + ((getRole() == null) ? 0 : getRole().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ObjectSomeRestriction other = (ObjectSomeRestriction) obj; + if (getChild(0) == null) { + if (other.getChild(0) != null) + return false; + } else if (!getChild(0).equals(other.getChild(0))) + return false; + if (getRole() == null) { + if (other.getRole() != null) + return false; + } else if (!getRole().equals(other.getRole())) + return false; + return true; } + } Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectValueRestriction.java 2014-05-27 12:57:42 UTC (rev 4273) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ObjectValueRestriction.java 2014-05-27 12:58:39 UTC (rev 4274) @@ -30,9 +30,6 @@ */ public class ObjectValueRestriction extends ValueRestriction { - /** - * - */ private static final long serialVersionUID = 2437223709767096950L; /** @@ -87,5 +84,36 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getRestrictedPropertyExpression() == null) ? 0 : getRestrictedPropertyExpression().hashCode()); + result = prime * result + ((getValue() == null) ? 0 : getValue().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ObjectValueRestriction other = (ObjectValueRestriction) obj; + if (getRestrictedPropertyExpression() == null) { + if (other.getRestrictedPropertyExpression() != null) + return false; + } else if (!getRestrictedPropertyExpression().equals(other.getRestrictedPropertyExpression())) + return false; + if (getValue() == null) { + if (other.getValue() != null) + return false; + } else if (!getValue().equals(other.getValue())) + return false; + return true; } } Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java 2014-05-27 12:57:42 UTC (rev 4273) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/Thing.java 2014-05-27 12:58:39 UTC (rev 4274) @@ -37,9 +37,6 @@ */ public class Thing extends Description { - /** - * - */ private static final long serialVersionUID = -880276915058868775L; public static final Thing instance = new Thing(); @@ -87,5 +84,25 @@ visitor.visit(this); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if(obj.getClass() == getClass()){ + return true; + } + if (obj.getClass() == NamedClass.class && ((NamedClass)obj).getName().equals(uri.toString())) + return true; + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-27 12:57:45
|
Revision: 4273 http://sourceforge.net/p/dl-learner/code/4273 Author: lorenz_b Date: 2014-05-27 12:57:42 +0000 (Tue, 27 May 2014) Log Message: ----------- Added some trivial subclass checks. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java 2014-05-23 13:20:53 UTC (rev 4272) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java 2014-05-27 12:57:42 UTC (rev 4273) @@ -30,6 +30,7 @@ import org.dllearner.core.owl.IntMaxValue; import org.dllearner.core.owl.IntMinValue; import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.ObjectAllRestriction; @@ -50,6 +51,8 @@ * */ public class DescriptionMinimizer { + + private static final NamedClass OWL_THING = new NamedClass(Thing.uri); private AbstractReasonerComponent reasoner; private ConceptComparator conceptComparator = new ConceptComparator(); @@ -152,7 +155,16 @@ if(description instanceof Intersection) { for(int i=0; i<children.size(); i++) { - for(int j=0; j<children.size(); j++) { + for(int j=0; j<children.size(); j++) { +// if(children.get(j) instanceof ObjectSomeRestriction && children.get(i) instanceof ObjectSomeRestriction){ +// System.out.println(children.get(j) + "::::" + children.get(i)); +//// System.out.println(children.get(j).getClass().getSimpleName() + "::::" + children.get(i).getClass().getSimpleName()); +// System.out.println(children.get(j).getChild(0).getClass().getSimpleName() + "::::" + children.get(i).getChild(0).getClass().getSimpleName()); +// Description d1 = children.get(j); +// Description d2 = children.get(i); +// boolean subclassOf = isSubclassOf(d1, d2); +// System.out.println(subclassOf); +// } if(i != j && isSubclassOf(children.get(j), children.get(i))) { // remove element because it is super class of another element children.remove(i); @@ -253,6 +265,8 @@ return ((IntMaxValue)dr1).getValue() <= ((IntMaxValue)dr2).getValue(); } } + if(d1.equals(d2)) return true; + if(d2 == Thing.instance || d2.equals(OWL_THING)) return true; if(!(d1.isNamedClass() && d2.isNamedClass())) return false; // check whether we have cached this query Map<Description,Boolean> tmp = cachedSubclassOf.get(d1); @@ -275,4 +289,11 @@ return tmp2; } } + + public static void main(String[] args) throws Exception { + Description d1 = new ObjectSomeRestriction(new ObjectProperty("r"), Thing.instance); + Description d2 = new ObjectSomeRestriction(new ObjectProperty("r"), new NamedClass(Thing.uri.toString())); + + System.out.println(d1.equals(d2)); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-23 13:20:56
|
Revision: 4272 http://sourceforge.net/p/dl-learner/code/4272 Author: lorenz_b Date: 2014-05-23 13:20:53 +0000 (Fri, 23 May 2014) Log Message: ----------- Updated RA Challenge script. Modified Paths: -------------- trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java Modified: trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java 2014-05-23 12:03:39 UTC (rev 4271) +++ trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java 2014-05-23 13:20:53 UTC (rev 4272) @@ -14,12 +14,15 @@ import java.net.URL; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.SortedSet; import java.util.TreeSet; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFDataMgr; import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.algorithms.celoe.OEHeuristicRuntime; import org.dllearner.algorithms.elcopy.ELLearningAlgorithm; @@ -50,6 +53,9 @@ import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl; +import com.hp.hpl.jena.graph.Triple; +import com.hp.hpl.jena.query.Dataset; +import com.hp.hpl.jena.query.DatasetFactory; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QuerySolution; @@ -59,9 +65,8 @@ import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.rdf.model.StmtIterator; -import com.hp.hpl.jena.vocabulary.OWL; -import com.hp.hpl.jena.vocabulary.RDF; +import com.hp.hpl.jena.sparql.core.Quad; +import com.hp.hpl.jena.sparql.util.ModelUtils; /** * @author Lorenz Buehmann @@ -96,16 +101,32 @@ File[] files = dataDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { - return name.endsWith(".nt") || name.endsWith(".ttl") || name.endsWith(".rdf") || name.endsWith(".owl"); + return name.endsWith(".nt") || name.endsWith(".ttl") || name.endsWith(".rdf") || name.endsWith(".owl") || name.endsWith(".nq"); } }); System.out.println("loading data..."); Model model = ModelFactory.createDefaultModel(); for (File file : files) { - model.read(new FileInputStream(file), null, "TURTLE"); + if(file.getName().endsWith(".nq")){ + Dataset ds = DatasetFactory.createMem() ; + RDFDataMgr.read(ds, new FileInputStream(file), Lang.NQUADS) ; +// Model subModel = ds.getNamedModel("http://bio2rdf.org/bio2rdf.dataset:bio2rdf-ra.challenge-R3"); +// model.add(subModel); + Iterator<Quad> find = ds.asDatasetGraph().find(); + Triple t; + while(find.hasNext()){ + t = find.next().asTriple(); + Statement st = model.asStatement(t); + model.add(st); + } + } else { + model.read(new FileInputStream(file), null, "TURTLE"); + } + } + System.out.println("done. loaded " + model.size() + " triples."); - analyzeData(model); +// analyzeData(model); //get the positive and negative examples via SPARQL //<http://bio2rdf.org/ra.challenge:1877000> <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> . @@ -132,7 +153,12 @@ System.out.println("#neg examples: " + negExamples.size()); //remove triples with property non-responder + System.out.println("Pruning data..."); model.remove(model.listStatements(null, model.createProperty("http://bio2rdf.org/ra.challenge_vocabulary:non-responder"), (RDFNode)null)); + model.remove(model.listStatements(null, model.createProperty("http://rdfs.org/ns/void#inDataset"), (RDFNode)null)); + model.remove(model.listStatements(null, model.createProperty("http://purl.org/dc/terms/description"), (RDFNode)null)); + model.remove(model.listStatements(null, model.createProperty("http://www.w3.org/2000/01/rdf-schema#label"), (RDFNode)null)); + System.out.println("done. remaining " + model.size() + " triples."); //enrich with additional data enrich(model); @@ -177,7 +203,7 @@ } else { OEHeuristicRuntime heuristic = new OEHeuristicRuntime(); heuristic.setExpansionPenaltyFactor(0.1); - la = new CELOE(lp, rc); + la = new CELOE(lp, baseReasoner); ((CELOE) la).setHeuristic(heuristic); ((CELOE) la).setMaxExecutionTimeInSeconds(100); ((CELOE) la).setNoisePercentage(50); @@ -188,7 +214,7 @@ RhoDRDown op = new RhoDRDown(); op.setUseHasValueConstructor(true); op.setUseObjectValueNegation(true); - op.setReasoner(rc); + op.setReasoner(baseReasoner); op.init(); // ((CELOE) la).setOperator(op); } @@ -239,6 +265,12 @@ qe = QueryExecutionFactory.create(query, model); rs = qe.execSelect(); System.out.println(ResultSetFormatter.asText(rs)); + + query = "SELECT * WHERE {<http://bio2rdf.org/ra.challenge:825000> ?p ?o. " + + "OPTIONAL{?o ?p1 ?o1.OPTIONAL{?o1 ?p2 ?o2. OPTIONAL{?o2 ?p3 ?o3.OPTIONAL{?o3 ?p4 ?o4.}}}}}"; + qe = QueryExecutionFactory.create(query, model); + rs = qe.execSelect(); + System.out.println(ResultSetFormatter.asText(rs)); } private static void computeLGG(Model model, SortedSet<Individual> posExamples){ @@ -293,7 +325,7 @@ drugbankData.write(new FileOutputStream("drugbank.ttl"), "TURTLE", null); model.add(drugbankData); + System.out.println("done. remaining " + model.size() + " triples."); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-23 12:03:42
|
Revision: 4271 http://sourceforge.net/p/dl-learner/code/4271 Author: lorenz_b Date: 2014-05-23 12:03:39 +0000 (Fri, 23 May 2014) Log Message: ----------- Added support for inter min max datarange. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/core/owl/IntMaxValue.java trunk/components-core/src/main/java/org/dllearner/core/owl/IntMinValue.java trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/IntMaxValue.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/IntMaxValue.java 2014-05-22 11:04:32 UTC (rev 4270) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/IntMaxValue.java 2014-05-23 12:03:39 UTC (rev 4271) @@ -58,11 +58,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " <= " + value; + return "integer[<= " + value + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " <= " + value; + return "integer[<= " + value + "]"; } public void accept(KBElementVisitor visitor) { @@ -74,7 +74,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " <= " + value; + return "integer[<= " + value + "]"; } /* (non-Javadoc) @@ -85,4 +85,12 @@ return false; } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return toString(null, null); + } + } Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/IntMinValue.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/IntMinValue.java 2014-05-22 11:04:32 UTC (rev 4270) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/IntMinValue.java 2014-05-23 12:03:39 UTC (rev 4271) @@ -58,11 +58,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " >= " + value; + return "integer[>= " + value + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " >= " + value; + return "integer[>= " + value + "]"; } public void accept(KBElementVisitor visitor) { @@ -74,7 +74,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " >= " + value; + return "integer[>= " + value + "]"; } /* (non-Javadoc) @@ -84,4 +84,12 @@ public boolean isDatatype() { return false; } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return toString(null, null); + } } Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java 2014-05-22 11:04:32 UTC (rev 4270) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java 2014-05-23 12:03:39 UTC (rev 4271) @@ -53,6 +53,8 @@ import org.dllearner.core.owl.DoubleMinValue; import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.IntMaxValue; +import org.dllearner.core.owl.IntMinValue; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; @@ -73,8 +75,6 @@ import org.dllearner.parser.ParseException; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptTransformation; -import org.semanticweb.owlapi.owllink.builtin.requests.IsDataPropertySatisfiable; -import org.semanticweb.owlapi.vocab.OWL2Datatype; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.propertyeditors.StringTrimmerEditor; @@ -563,22 +563,39 @@ } else { return false; } - } - SortedSet<Double> values = dd.get(dp).get(individual); + } else { + if(dr instanceof IntMaxValue || dr instanceof IntMinValue){ + SortedSet<Integer> values = id.get(dp).get(individual); - // if there is no filler for this individual and property we - // need to return false - if (values == null) { - return false; - } + // if there is no filler for this individual and property we + // need to return false + if (values == null) { + return false; + } + if (dr instanceof IntMaxValue) { + return (values.first() <= ((IntMaxValue) dr).getValue()); + } else if (dr instanceof IntMinValue) { + return (values.last() >= ((IntMinValue) dr).getValue()); + } + } else { + SortedSet<Double> values = dd.get(dp).get(individual); - if (dr instanceof DoubleMaxValue) { - return (values.first() <= ((DoubleMaxValue) dr).getValue()); - } else if (dr instanceof DoubleMinValue) { - return (values.last() >= ((DoubleMinValue) dr).getValue()); - } else if (dr instanceof DoubleMinMaxRange){ - return (values.first() <= ((DoubleMinMaxRange) dr).getMaxValue()) && (values.last() >= ((DoubleMinMaxRange) dr).getMinValue()); + // if there is no filler for this individual and property we + // need to return false + if (values == null) { + return false; + } + if (dr instanceof DoubleMaxValue) { + return (values.first() <= ((DoubleMaxValue) dr).getValue()); + } else if (dr instanceof DoubleMinValue) { + return (values.last() >= ((DoubleMinValue) dr).getValue()); + } else if (dr instanceof DoubleMinMaxRange){ + return (values.first() <= ((DoubleMinMaxRange) dr).getMaxValue()) && (values.last() >= ((DoubleMinMaxRange) dr).getMinValue()); + } + } + } + } else if (description instanceof DatatypeValueRestriction) { Constant value = ((DatatypeValueRestriction)description).getValue(); DatatypeProperty dp = ((DatatypeValueRestriction)description).getRestrictedPropertyExpression(); Modified: trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java 2014-05-22 11:04:32 UTC (rev 4270) +++ trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java 2014-05-23 12:03:39 UTC (rev 4271) @@ -53,6 +53,8 @@ import org.dllearner.core.owl.DoubleMaxValue; import org.dllearner.core.owl.DoubleMinValue; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.IntMaxValue; +import org.dllearner.core.owl.IntMinValue; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; @@ -96,8 +98,10 @@ public class RhoDRDown extends RefinementOperatorAdapter implements Component, CustomHierarchyRefinementOperator, CustomStartRefinementOperator, ReasoningBasedRefinementOperator { private static Logger logger = Logger - .getLogger(RhoDRDown.class); + .getLogger(RhoDRDown.class); + private static final NamedClass OWL_THING = new NamedClass(Thing.uri); + private AbstractReasonerComponent reasoner; // hierarchies @@ -152,18 +156,21 @@ private Map<NamedClass, Set<DatatypeProperty>> appBD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); private Map<NamedClass, Set<DatatypeProperty>> appDD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); private Map<NamedClass, Set<DatatypeProperty>> appSD = new TreeMap<NamedClass, Set<DatatypeProperty>>(); + private Map<NamedClass, Set<DatatypeProperty>> appID = new TreeMap<NamedClass, Set<DatatypeProperty>>(); // most general applicable properties private Map<NamedClass,Set<ObjectProperty>> mgr = new TreeMap<NamedClass,Set<ObjectProperty>>(); private Map<NamedClass,Set<DatatypeProperty>> mgbd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); private Map<NamedClass,Set<DatatypeProperty>> mgdd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); private Map<NamedClass,Set<DatatypeProperty>> mgsd = new TreeMap<NamedClass,Set<DatatypeProperty>>(); + private Map<NamedClass,Set<DatatypeProperty>> mgid = new TreeMap<NamedClass,Set<DatatypeProperty>>(); // concept comparator private ConceptComparator conceptComparator = new ConceptComparator(); - // splits for double datatype properties in ascening order + // splits for double datatype properties in ascending order private Map<DatatypeProperty,List<Double>> splits = new TreeMap<DatatypeProperty,List<Double>>(); + private Map<DatatypeProperty,List<Integer>> splitsInt = new TreeMap<DatatypeProperty,List<Integer>>(); private int maxNrOfSplits = 10; // data structure for a simple frequent pattern matching preprocessing phase @@ -330,6 +337,11 @@ computeSplits(dp); } + // compute splits for integer datatype properties + for (DatatypeProperty dp : reasoner.getIntDatatypeProperties()) { + computeSplitsInt(dp); + } + // determine the maximum number of fillers for each role // (up to a specified cardinality maximum) if(useCardinalityRestrictions) { @@ -457,7 +469,7 @@ tmp = subHierarchy.getSuperClasses(description.getChild(0)); for(Description c : tmp) { - if(!(c instanceof Thing)) + if(!(c instanceof Thing) && !c.equals(OWL_THING)) refinements.add(new Negation(c)); } @@ -674,6 +686,31 @@ DatatypeSomeRestriction newDSR = new DatatypeSomeRestriction(dp,min); refinements.add(newDSR); } + } if(dr instanceof IntMaxValue) { + int value = ((IntMaxValue)dr).getValue(); + // find out which split value was used + int splitIndex = splitsInt.get(dp).lastIndexOf(value); + if(splitIndex == -1) + throw new Error("split error"); + int newSplitIndex = splitIndex - 1; + if(newSplitIndex >= 0) { + IntMaxValue max = new IntMaxValue(splitsInt.get(dp).get(newSplitIndex)); + DatatypeSomeRestriction newDSR = new DatatypeSomeRestriction(dp,max); + refinements.add(newDSR); +// System.out.println(description + " => " + newDSR); + } + } else if(dr instanceof IntMinValue) { + int value = ((IntMinValue)dr).getValue(); + // find out which split value was used + int splitIndex = splitsInt.get(dp).lastIndexOf(value); + if(splitIndex == -1) + throw new Error("split error"); + int newSplitIndex = splitIndex + 1; + if(newSplitIndex < splitsInt.get(dp).size()) { + IntMinValue min = new IntMinValue(splitsInt.get(dp).get(newSplitIndex)); + DatatypeSomeRestriction newDSR = new DatatypeSomeRestriction(dp,min); + refinements.add(newDSR); + } } } else if (description instanceof StringValueRestriction) { StringValueRestriction svr = (StringValueRestriction) description; @@ -786,6 +823,10 @@ TreeSet<DatatypeProperty> occuredDP = new TreeSet<DatatypeProperty>(); // rule 4: no double occurences of hasValue restrictions TreeSet<ObjectProperty> occuredVR = new TreeSet<ObjectProperty>(); + // rule 5: max. restrictions at most once + boolean maxIntOccurence = false; + // rule 6: min restrictions at most once + boolean minIntOccurence = false; for(Description child : intersection.getChildren()) { if(child instanceof DatatypeSomeRestriction) { @@ -800,6 +841,16 @@ return false; else minDoubleOccurence = true; + } else if(dr instanceof IntMaxValue) { + if(maxIntOccurence) + return false; + else + maxIntOccurence = true; + } else if(dr instanceof IntMinValue) { + if(minIntOccurence) + return false; + else + minIntOccurence = true; } } else if(child instanceof BooleanValueRestriction) { DatatypeProperty dp = (DatatypeProperty) ((BooleanValueRestriction)child).getRestrictedPropertyExpression(); @@ -978,7 +1029,7 @@ if(useNegation) { Set<Description> m2tmp = subHierarchy.getSuperClasses(new Nothing()); for(Description c : m2tmp) { - if(!(c instanceof Thing)) { + if(!(c instanceof Thing) && !c.equals(OWL_THING)) { m2.add(new Negation(c)); } } @@ -1024,6 +1075,18 @@ } } + if(useIntDatatypes) { + Set<DatatypeProperty> intDPs = reasoner.getIntDatatypeProperties(); + for(DatatypeProperty dp : intDPs) { + if(splitsInt.get(dp).size() > 0) { + IntMaxValue max = new IntMaxValue(splitsInt.get(dp).get(splitsInt.get(dp).size()-1)); + IntMinValue min = new IntMinValue(splitsInt.get(dp).get(0)); + m3.add(new DatatypeSomeRestriction(dp,max)); + m3.add(new DatatypeSomeRestriction(dp,min)); + } + } + } + if(useDataHasValueConstructor) { Set<DatatypeProperty> stringDPs = reasoner.getStringDatatypeProperties(); for(DatatypeProperty dp : stringDPs) { @@ -1161,8 +1224,21 @@ m3.add(new DatatypeSomeRestriction(dp,min)); } } - } + } + if(useIntDatatypes) { + Set<DatatypeProperty> intDPs = mgid.get(nc); + + for(DatatypeProperty dp : intDPs) { + if(splitsInt.get(dp).size() > 0) { + IntMaxValue max = new IntMaxValue(splitsInt.get(dp).get(splitsInt.get(dp).size()-1)); + IntMinValue min = new IntMinValue(splitsInt.get(dp).get(0)); + m3.add(new DatatypeSomeRestriction(dp,max)); + m3.add(new DatatypeSomeRestriction(dp,min)); + } + } + } + if(useDataHasValueConstructor) { Set<DatatypeProperty> stringDPs = mgsd.get(nc); for(DatatypeProperty dp : stringDPs) { @@ -1257,7 +1333,7 @@ // System.out.println("index " + index + " lower class " + lowerClass); for(Description candidate : subHierarchy.getSuperClasses(lowerClass)) { - if(!(candidate instanceof Thing)) { + if(!(candidate instanceof Thing) && !candidate.equals(OWL_THING)) { // System.out.println("candidate: " + candidate); // check disjointness with index/range (should not be disjoint otherwise not useful) if(!isDisjoint(new Negation(candidate),index)) { @@ -1293,6 +1369,7 @@ mgbd.put(domain, new TreeSet<DatatypeProperty>()); mgdd.put(domain, new TreeSet<DatatypeProperty>()); mgsd.put(domain, new TreeSet<DatatypeProperty>()); + mgid.put(domain, new TreeSet<DatatypeProperty>()); SortedSet<ObjectProperty> mostGeneral = reasoner.getMostGeneralProperties(); computeMgrRecursive(domain, mostGeneral, mgr.get(domain)); @@ -1302,9 +1379,11 @@ Set<DatatypeProperty> mostGeneralBDP = Helper.intersection(mostGeneralDP, reasoner.getBooleanDatatypeProperties()); Set<DatatypeProperty> mostGeneralDDP = Helper.intersection(mostGeneralDP, reasoner.getDoubleDatatypeProperties()); Set<DatatypeProperty> mostGeneralSDP = Helper.intersection(mostGeneralDP, reasoner.getStringDatatypeProperties()); + Set<DatatypeProperty> mostGeneralIDP = Helper.intersection(mostGeneralDP, reasoner.getIntDatatypeProperties()); computeMgbdRecursive(domain, mostGeneralBDP, mgbd.get(domain)); computeMgddRecursive(domain, mostGeneralDDP, mgdd.get(domain)); computeMgsdRecursive(domain, mostGeneralSDP, mgsd.get(domain)); + computeMgidRecursive(domain, mostGeneralIDP, mgid.get(domain)); } private void computeMgrRecursive(NamedClass domain, Set<ObjectProperty> currProperties, Set<ObjectProperty> mgrTmp) { @@ -1343,6 +1422,15 @@ } } + private void computeMgidRecursive(NamedClass domain, Set<DatatypeProperty> currProperties, Set<DatatypeProperty> mgidTmp) { + for(DatatypeProperty prop : currProperties) { + if(appID.get(domain).contains(prop)) + mgidTmp.add(prop); + else + computeMgidRecursive(domain, reasoner.getSubProperties(prop), mgidTmp); + } + } + // computes the set of applicable properties for a given class private void computeApp(NamedClass domain) { // object properties @@ -1390,7 +1478,19 @@ if(!isDisjoint(domain,d)) applicableSDPs.add(role); } - appSD.put(domain, applicableSDPs); + appSD.put(domain, applicableSDPs); + + // integer datatype properties + Set<DatatypeProperty> mostGeneralIDPs = reasoner.getIntDatatypeProperties(); + Set<DatatypeProperty> applicableIDPs = new TreeSet<DatatypeProperty>(); + for(DatatypeProperty role : mostGeneralIDPs) { +// Description d = (NamedClass) rs.getDomain(role); + Description d = reasoner.getDomain(role); +// System.out.println("domain: " + d); + if(!isDisjoint(domain,d)) + applicableIDPs.add(role); + } + appID.put(domain, applicableIDPs); } // returns true of the intersection contains elements disjoint @@ -1541,6 +1641,37 @@ // System.out.println(splits); // System.exit(0); } + + private void computeSplitsInt(DatatypeProperty dp) { + Set<Integer> valuesSet = new TreeSet<Integer>(); +// Set<Individual> individuals = rs.getIndividuals(); + Map<Individual,SortedSet<Integer>> valueMap = reasoner.getIntDatatypeMembers(dp); + // add all values to the set (duplicates will be remove automatically) + for(Entry<Individual,SortedSet<Integer>> e : valueMap.entrySet()) + valuesSet.addAll(e.getValue()); + // convert set to a list where values are sorted + List<Integer> values = new LinkedList<Integer>(valuesSet); + Collections.sort(values); + + int nrOfValues = values.size(); + // create split set + List<Integer> splitsDP = new LinkedList<Integer>(); + for(int splitNr=0; splitNr < Math.min(maxNrOfSplits,nrOfValues-1); splitNr++) { + int index; + if(nrOfValues<=maxNrOfSplits) + index = splitNr; + else + index = (int) Math.floor(splitNr * (double)nrOfValues/(maxNrOfSplits+1)); + + int value = values.get(index); + splitsDP.add(value); + } + splitsInt.put(dp, splitsDP); + +// System.out.println(values); +// System.out.println(splits); +// System.exit(0); + } public int getFrequencyThreshold() { return frequencyThreshold; Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java 2014-05-22 11:04:32 UTC (rev 4270) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/DescriptionMinimizer.java 2014-05-23 12:03:39 UTC (rev 4271) @@ -24,9 +24,12 @@ import java.util.TreeMap; import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.owl.DataRange; +import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.IntMaxValue; +import org.dllearner.core.owl.IntMinValue; import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.ObjectAllRestriction; @@ -59,7 +62,7 @@ } /** - * Method which minimzes the input description. The algorithm does not + * Method which minimizes the input description. The algorithm does not * replace subdescriptions with named classes, e.g. * if the description "male \sqcap \exists hasChild.\top" is passed to the * algorithm and a class "father" is defined in the obvious way @@ -241,6 +244,15 @@ } private boolean isSubclassOf(Description d1, Description d2) { + if(beautify && (d1 instanceof DatatypeSomeRestriction) && (d2 instanceof DatatypeSomeRestriction)){ + DataRange dr1 = ((DatatypeSomeRestriction)d1).getDataRange(); + DataRange dr2 = ((DatatypeSomeRestriction)d2).getDataRange(); + if(dr1 instanceof IntMinValue && dr2 instanceof IntMinValue){ + return ((IntMinValue)dr1).getValue() >= ((IntMinValue)dr2).getValue(); + } else if(dr1 instanceof IntMaxValue && dr2 instanceof IntMaxValue){ + return ((IntMaxValue)dr1).getValue() <= ((IntMaxValue)dr2).getValue(); + } + } if(!(d1.isNamedClass() && d2.isNamedClass())) return false; // check whether we have cached this query Map<Description,Boolean> tmp = cachedSubclassOf.get(d1); @@ -249,7 +261,8 @@ tmp2 = tmp.get(d2); if(tmp2==null) { - Boolean result = reasoner.isSuperClassOf(d2, d1); + + Boolean result = reasoner.isSuperClassOf(d2, d1); // create new entry if necessary Map<Description,Boolean> map1 = new TreeMap<Description,Boolean>(conceptComparator); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-22 11:04:35
|
Revision: 4270 http://sourceforge.net/p/dl-learner/code/4270 Author: lorenz_b Date: 2014-05-22 11:04:32 +0000 (Thu, 22 May 2014) Log Message: ----------- Added QTL example. Added Paths: ----------- trunk/test/qtl/heart/ trunk/test/qtl/heart/files/ trunk/test/qtl/heart/files/heart.dat trunk/test/qtl/heart/heart.owl trunk/test/qtl/heart/train.conf Added: trunk/test/qtl/heart/files/heart.dat =================================================================== --- trunk/test/qtl/heart/files/heart.dat (rev 0) +++ trunk/test/qtl/heart/files/heart.dat 2014-05-22 11:04:32 UTC (rev 4270) @@ -0,0 +1,270 @@ +70.0,1.0,4.0,130.0,322.0,0.0,2.0,109.0,0.0,2.4,2.0,3.0,3.0,2 +67.0,0.0,3.0,115.0,564.0,0.0,2.0,160.0,0.0,1.6,2.0,0.0,7.0,1 +57.0,1.0,2.0,124.0,261.0,0.0,0.0,141.0,0.0,0.3,1.0,0.0,7.0,2 +64.0,1.0,4.0,128.0,263.0,0.0,0.0,105.0,1.0,0.2,2.0,1.0,7.0,1 +74.0,0.0,2.0,120.0,269.0,0.0,2.0,121.0,1.0,0.2,1.0,1.0,3.0,1 +65.0,1.0,4.0,120.0,177.0,0.0,0.0,140.0,0.0,0.4,1.0,0.0,7.0,1 +56.0,1.0,3.0,130.0,256.0,1.0,2.0,142.0,1.0,0.6,2.0,1.0,6.0,2 +59.0,1.0,4.0,110.0,239.0,0.0,2.0,142.0,1.0,1.2,2.0,1.0,7.0,2 +60.0,1.0,4.0,140.0,293.0,0.0,2.0,170.0,0.0,1.2,2.0,2.0,7.0,2 +63.0,0.0,4.0,150.0,407.0,0.0,2.0,154.0,0.0,4.0,2.0,3.0,7.0,2 +59.0,1.0,4.0,135.0,234.0,0.0,0.0,161.0,0.0,0.5,2.0,0.0,7.0,1 +53.0,1.0,4.0,142.0,226.0,0.0,2.0,111.0,1.0,0.0,1.0,0.0,7.0,1 +44.0,1.0,3.0,140.0,235.0,0.0,2.0,180.0,0.0,0.0,1.0,0.0,3.0,1 +61.0,1.0,1.0,134.0,234.0,0.0,0.0,145.0,0.0,2.6,2.0,2.0,3.0,2 +57.0,0.0,4.0,128.0,303.0,0.0,2.0,159.0,0.0,0.0,1.0,1.0,3.0,1 +71.0,0.0,4.0,112.0,149.0,0.0,0.0,125.0,0.0,1.6,2.0,0.0,3.0,1 +46.0,1.0,4.0,140.0,311.0,0.0,0.0,120.0,1.0,1.8,2.0,2.0,7.0,2 +53.0,1.0,4.0,140.0,203.0,1.0,2.0,155.0,1.0,3.1,3.0,0.0,7.0,2 +64.0,1.0,1.0,110.0,211.0,0.0,2.0,144.0,1.0,1.8,2.0,0.0,3.0,1 +40.0,1.0,1.0,140.0,199.0,0.0,0.0,178.0,1.0,1.4,1.0,0.0,7.0,1 +67.0,1.0,4.0,120.0,229.0,0.0,2.0,129.0,1.0,2.6,2.0,2.0,7.0,2 +48.0,1.0,2.0,130.0,245.0,0.0,2.0,180.0,0.0,0.2,2.0,0.0,3.0,1 +43.0,1.0,4.0,115.0,303.0,0.0,0.0,181.0,0.0,1.2,2.0,0.0,3.0,1 +47.0,1.0,4.0,112.0,204.0,0.0,0.0,143.0,0.0,0.1,1.0,0.0,3.0,1 +54.0,0.0,2.0,132.0,288.0,1.0,2.0,159.0,1.0,0.0,1.0,1.0,3.0,1 +48.0,0.0,3.0,130.0,275.0,0.0,0.0,139.0,0.0,0.2,1.0,0.0,3.0,1 +46.0,0.0,4.0,138.0,243.0,0.0,2.0,152.0,1.0,0.0,2.0,0.0,3.0,1 +51.0,0.0,3.0,120.0,295.0,0.0,2.0,157.0,0.0,0.6,1.0,0.0,3.0,1 +58.0,1.0,3.0,112.0,230.0,0.0,2.0,165.0,0.0,2.5,2.0,1.0,7.0,2 +71.0,0.0,3.0,110.0,265.0,1.0,2.0,130.0,0.0,0.0,1.0,1.0,3.0,1 +57.0,1.0,3.0,128.0,229.0,0.0,2.0,150.0,0.0,0.4,2.0,1.0,7.0,2 +66.0,1.0,4.0,160.0,228.0,0.0,2.0,138.0,0.0,2.3,1.0,0.0,6.0,1 +37.0,0.0,3.0,120.0,215.0,0.0,0.0,170.0,0.0,0.0,1.0,0.0,3.0,1 +59.0,1.0,4.0,170.0,326.0,0.0,2.0,140.0,1.0,3.4,3.0,0.0,7.0,2 +50.0,1.0,4.0,144.0,200.0,0.0,2.0,126.0,1.0,0.9,2.0,0.0,7.0,2 +48.0,1.0,4.0,130.0,256.0,1.0,2.0,150.0,1.0,0.0,1.0,2.0,7.0,2 +61.0,1.0,4.0,140.0,207.0,0.0,2.0,138.0,1.0,1.9,1.0,1.0,7.0,2 +59.0,1.0,1.0,160.0,273.0,0.0,2.0,125.0,0.0,0.0,1.0,0.0,3.0,2 +42.0,1.0,3.0,130.0,180.0,0.0,0.0,150.0,0.0,0.0,1.0,0.0,3.0,1 +48.0,1.0,4.0,122.0,222.0,0.0,2.0,186.0,0.0,0.0,1.0,0.0,3.0,1 +40.0,1.0,4.0,152.0,223.0,0.0,0.0,181.0,0.0,0.0,1.0,0.0,7.0,2 +62.0,0.0,4.0,124.0,209.0,0.0,0.0,163.0,0.0,0.0,1.0,0.0,3.0,1 +44.0,1.0,3.0,130.0,233.0,0.0,0.0,179.0,1.0,0.4,1.0,0.0,3.0,1 +46.0,1.0,2.0,101.0,197.0,1.0,0.0,156.0,0.0,0.0,1.0,0.0,7.0,1 +59.0,1.0,3.0,126.0,218.0,1.0,0.0,134.0,0.0,2.2,2.0,1.0,6.0,2 +58.0,1.0,3.0,140.0,211.0,1.0,2.0,165.0,0.0,0.0,1.0,0.0,3.0,1 +49.0,1.0,3.0,118.0,149.0,0.0,2.0,126.0,0.0,0.8,1.0,3.0,3.0,2 +44.0,1.0,4.0,110.0,197.0,0.0,2.0,177.0,0.0,0.0,1.0,1.0,3.0,2 +66.0,1.0,2.0,160.0,246.0,0.0,0.0,120.0,1.0,0.0,2.0,3.0,6.0,2 +65.0,0.0,4.0,150.0,225.0,0.0,2.0,114.0,0.0,1.0,2.0,3.0,7.0,2 +42.0,1.0,4.0,136.0,315.0,0.0,0.0,125.0,1.0,1.8,2.0,0.0,6.0,2 +52.0,1.0,2.0,128.0,205.0,1.0,0.0,184.0,0.0,0.0,1.0,0.0,3.0,1 +65.0,0.0,3.0,140.0,417.0,1.0,2.0,157.0,0.0,0.8,1.0,1.0,3.0,1 +63.0,0.0,2.0,140.0,195.0,0.0,0.0,179.0,0.0,0.0,1.0,2.0,3.0,1 +45.0,0.0,2.0,130.0,234.0,0.0,2.0,175.0,0.0,0.6,2.0,0.0,3.0,1 +41.0,0.0,2.0,105.0,198.0,0.0,0.0,168.0,0.0,0.0,1.0,1.0,3.0,1 +61.0,1.0,4.0,138.0,166.0,0.0,2.0,125.0,1.0,3.6,2.0,1.0,3.0,2 +60.0,0.0,3.0,120.0,178.0,1.0,0.0,96.0,0.0,0.0,1.0,0.0,3.0,1 +59.0,0.0,4.0,174.0,249.0,0.0,0.0,143.0,1.0,0.0,2.0,0.0,3.0,2 +62.0,1.0,2.0,120.0,281.0,0.0,2.0,103.0,0.0,1.4,2.0,1.0,7.0,2 +57.0,1.0,3.0,150.0,126.0,1.0,0.0,173.0,0.0,0.2,1.0,1.0,7.0,1 +51.0,0.0,4.0,130.0,305.0,0.0,0.0,142.0,1.0,1.2,2.0,0.0,7.0,2 +44.0,1.0,3.0,120.0,226.0,0.0,0.0,169.0,0.0,0.0,1.0,0.0,3.0,1 +60.0,0.0,1.0,150.0,240.0,0.0,0.0,171.0,0.0,0.9,1.0,0.0,3.0,1 +63.0,1.0,1.0,145.0,233.0,1.0,2.0,150.0,0.0,2.3,3.0,0.0,6.0,1 +57.0,1.0,4.0,150.0,276.0,0.0,2.0,112.0,1.0,0.6,2.0,1.0,6.0,2 +51.0,1.0,4.0,140.0,261.0,0.0,2.0,186.0,1.0,0.0,1.0,0.0,3.0,1 +58.0,0.0,2.0,136.0,319.0,1.0,2.0,152.0,0.0,0.0,1.0,2.0,3.0,2 +44.0,0.0,3.0,118.0,242.0,0.0,0.0,149.0,0.0,0.3,2.0,1.0,3.0,1 +47.0,1.0,3.0,108.0,243.0,0.0,0.0,152.0,0.0,0.0,1.0,0.0,3.0,2 +61.0,1.0,4.0,120.0,260.0,0.0,0.0,140.0,1.0,3.6,2.0,1.0,7.0,2 +57.0,0.0,4.0,120.0,354.0,0.0,0.0,163.0,1.0,0.6,1.0,0.0,3.0,1 +70.0,1.0,2.0,156.0,245.0,0.0,2.0,143.0,0.0,0.0,1.0,0.0,3.0,1 +76.0,0.0,3.0,140.0,197.0,0.0,1.0,116.0,0.0,1.1,2.0,0.0,3.0,1 +67.0,0.0,4.0,106.0,223.0,0.0,0.0,142.0,0.0,0.3,1.0,2.0,3.0,1 +45.0,1.0,4.0,142.0,309.0,0.0,2.0,147.0,1.0,0.0,2.0,3.0,7.0,2 +45.0,1.0,4.0,104.0,208.0,0.0,2.0,148.0,1.0,3.0,2.0,0.0,3.0,1 +39.0,0.0,3.0,94.0,199.0,0.0,0.0,179.0,0.0,0.0,1.0,0.0,3.0,1 +42.0,0.0,3.0,120.0,209.0,0.0,0.0,173.0,0.0,0.0,2.0,0.0,3.0,1 +56.0,1.0,2.0,120.0,236.0,0.0,0.0,178.0,0.0,0.8,1.0,0.0,3.0,1 +58.0,1.0,4.0,146.0,218.0,0.0,0.0,105.0,0.0,2.0,2.0,1.0,7.0,2 +35.0,1.0,4.0,120.0,198.0,0.0,0.0,130.0,1.0,1.6,2.0,0.0,7.0,2 +58.0,1.0,4.0,150.0,270.0,0.0,2.0,111.0,1.0,0.8,1.0,0.0,7.0,2 +41.0,1.0,3.0,130.0,214.0,0.0,2.0,168.0,0.0,2.0,2.0,0.0,3.0,1 +57.0,1.0,4.0,110.0,201.0,0.0,0.0,126.0,1.0,1.5,2.0,0.0,6.0,1 +42.0,1.0,1.0,148.0,244.0,0.0,2.0,178.0,0.0,0.8,1.0,2.0,3.0,1 +62.0,1.0,2.0,128.0,208.0,1.0,2.0,140.0,0.0,0.0,1.0,0.0,3.0,1 +59.0,1.0,1.0,178.0,270.0,0.0,2.0,145.0,0.0,4.2,3.0,0.0,7.0,1 +41.0,0.0,2.0,126.0,306.0,0.0,0.0,163.0,0.0,0.0,1.0,0.0,3.0,1 +50.0,1.0,4.0,150.0,243.0,0.0,2.0,128.0,0.0,2.6,2.0,0.0,7.0,2 +59.0,1.0,2.0,140.0,221.0,0.0,0.0,164.0,1.0,0.0,1.0,0.0,3.0,1 +61.0,0.0,4.0,130.0,330.0,0.0,2.0,169.0,0.0,0.0,1.0,0.0,3.0,2 +54.0,1.0,4.0,124.0,266.0,0.0,2.0,109.0,1.0,2.2,2.0,1.0,7.0,2 +54.0,1.0,4.0,110.0,206.0,0.0,2.0,108.0,1.0,0.0,2.0,1.0,3.0,2 +52.0,1.0,4.0,125.0,212.0,0.0,0.0,168.0,0.0,1.0,1.0,2.0,7.0,2 +47.0,1.0,4.0,110.0,275.0,0.0,2.0,118.0,1.0,1.0,2.0,1.0,3.0,2 +66.0,1.0,4.0,120.0,302.0,0.0,2.0,151.0,0.0,0.4,2.0,0.0,3.0,1 +58.0,1.0,4.0,100.0,234.0,0.0,0.0,156.0,0.0,0.1,1.0,1.0,7.0,2 +64.0,0.0,3.0,140.0,313.0,0.0,0.0,133.0,0.0,0.2,1.0,0.0,7.0,1 +50.0,0.0,2.0,120.0,244.0,0.0,0.0,162.0,0.0,1.1,1.0,0.0,3.0,1 +44.0,0.0,3.0,108.0,141.0,0.0,0.0,175.0,0.0,0.6,2.0,0.0,3.0,1 +67.0,1.0,4.0,120.0,237.0,0.0,0.0,71.0,0.0,1.0,2.0,0.0,3.0,2 +49.0,0.0,4.0,130.0,269.0,0.0,0.0,163.0,0.0,0.0,1.0,0.0,3.0,1 +57.0,1.0,4.0,165.0,289.0,1.0,2.0,124.0,0.0,1.0,2.0,3.0,7.0,2 +63.0,1.0,4.0,130.0,254.0,0.0,2.0,147.0,0.0,1.4,2.0,1.0,7.0,2 +48.0,1.0,4.0,124.0,274.0,0.0,2.0,166.0,0.0,0.5,2.0,0.0,7.0,2 +51.0,1.0,3.0,100.0,222.0,0.0,0.0,143.0,1.0,1.2,2.0,0.0,3.0,1 +60.0,0.0,4.0,150.0,258.0,0.0,2.0,157.0,0.0,2.6,2.0,2.0,7.0,2 +59.0,1.0,4.0,140.0,177.0,0.0,0.0,162.0,1.0,0.0,1.0,1.0,7.0,2 +45.0,0.0,2.0,112.0,160.0,0.0,0.0,138.0,0.0,0.0,2.0,0.0,3.0,1 +55.0,0.0,4.0,180.0,327.0,0.0,1.0,117.0,1.0,3.4,2.0,0.0,3.0,2 +41.0,1.0,2.0,110.0,235.0,0.0,0.0,153.0,0.0,0.0,1.0,0.0,3.0,1 +60.0,0.0,4.0,158.0,305.0,0.0,2.0,161.0,0.0,0.0,1.0,0.0,3.0,2 +54.0,0.0,3.0,135.0,304.0,1.0,0.0,170.0,0.0,0.0,1.0,0.0,3.0,1 +42.0,1.0,2.0,120.0,295.0,0.0,0.0,162.0,0.0,0.0,1.0,0.0,3.0,1 +49.0,0.0,2.0,134.0,271.0,0.0,0.0,162.0,0.0,0.0,2.0,0.0,3.0,1 +46.0,1.0,4.0,120.0,249.0,0.0,2.0,144.0,0.0,0.8,1.0,0.0,7.0,2 +56.0,0.0,4.0,200.0,288.0,1.0,2.0,133.0,1.0,4.0,3.0,2.0,7.0,2 +66.0,0.0,1.0,150.0,226.0,0.0,0.0,114.0,0.0,2.6,3.0,0.0,3.0,1 +56.0,1.0,4.0,130.0,283.0,1.0,2.0,103.0,1.0,1.6,3.0,0.0,7.0,2 +49.0,1.0,3.0,120.0,188.0,0.0,0.0,139.0,0.0,2.0,2.0,3.0,7.0,2 +54.0,1.0,4.0,122.0,286.0,0.0,2.0,116.0,1.0,3.2,2.0,2.0,3.0,2 +57.0,1.0,4.0,152.0,274.0,0.0,0.0,88.0,1.0,1.2,2.0,1.0,7.0,2 +65.0,0.0,3.0,160.0,360.0,0.0,2.0,151.0,0.0,0.8,1.0,0.0,3.0,1 +54.0,1.0,3.0,125.0,273.0,0.0,2.0,152.0,0.0,0.5,3.0,1.0,3.0,1 +54.0,0.0,3.0,160.0,201.0,0.0,0.0,163.0,0.0,0.0,1.0,1.0,3.0,1 +62.0,1.0,4.0,120.0,267.0,0.0,0.0,99.0,1.0,1.8,2.0,2.0,7.0,2 +52.0,0.0,3.0,136.0,196.0,0.0,2.0,169.0,0.0,0.1,2.0,0.0,3.0,1 +52.0,1.0,2.0,134.0,201.0,0.0,0.0,158.0,0.0,0.8,1.0,1.0,3.0,1 +60.0,1.0,4.0,117.0,230.0,1.0,0.0,160.0,1.0,1.4,1.0,2.0,7.0,2 +63.0,0.0,4.0,108.0,269.0,0.0,0.0,169.0,1.0,1.8,2.0,2.0,3.0,2 +66.0,1.0,4.0,112.0,212.0,0.0,2.0,132.0,1.0,0.1,1.0,1.0,3.0,2 +42.0,1.0,4.0,140.0,226.0,0.0,0.0,178.0,0.0,0.0,1.0,0.0,3.0,1 +64.0,1.0,4.0,120.0,246.0,0.0,2.0,96.0,1.0,2.2,3.0,1.0,3.0,2 +54.0,1.0,3.0,150.0,232.0,0.0,2.0,165.0,0.0,1.6,1.0,0.0,7.0,1 +46.0,0.0,3.0,142.0,177.0,0.0,2.0,160.0,1.0,1.4,3.0,0.0,3.0,1 +67.0,0.0,3.0,152.0,277.0,0.0,0.0,172.0,0.0,0.0,1.0,1.0,3.0,1 +56.0,1.0,4.0,125.0,249.0,1.0,2.0,144.0,1.0,1.2,2.0,1.0,3.0,2 +34.0,0.0,2.0,118.0,210.0,0.0,0.0,192.0,0.0,0.7,1.0,0.0,3.0,1 +57.0,1.0,4.0,132.0,207.0,0.0,0.0,168.0,1.0,0.0,1.0,0.0,7.0,1 +64.0,1.0,4.0,145.0,212.0,0.0,2.0,132.0,0.0,2.0,2.0,2.0,6.0,2 +59.0,1.0,4.0,138.0,271.0,0.0,2.0,182.0,0.0,0.0,1.0,0.0,3.0,1 +50.0,1.0,3.0,140.0,233.0,0.0,0.0,163.0,0.0,0.6,2.0,1.0,7.0,2 +51.0,1.0,1.0,125.0,213.0,0.0,2.0,125.0,1.0,1.4,1.0,1.0,3.0,1 +54.0,1.0,2.0,192.0,283.0,0.0,2.0,195.0,0.0,0.0,1.0,1.0,7.0,2 +53.0,1.0,4.0,123.0,282.0,0.0,0.0,95.0,1.0,2.0,2.0,2.0,7.0,2 +52.0,1.0,4.0,112.0,230.0,0.0,0.0,160.0,0.0,0.0,1.0,1.0,3.0,2 +40.0,1.0,4.0,110.0,167.0,0.0,2.0,114.0,1.0,2.0,2.0,0.0,7.0,2 +58.0,1.0,3.0,132.0,224.0,0.0,2.0,173.0,0.0,3.2,1.0,2.0,7.0,2 +41.0,0.0,3.0,112.0,268.0,0.0,2.0,172.0,1.0,0.0,1.0,0.0,3.0,1 +41.0,1.0,3.0,112.0,250.0,0.0,0.0,179.0,0.0,0.0,1.0,0.0,3.0,1 +50.0,0.0,3.0,120.0,219.0,0.0,0.0,158.0,0.0,1.6,2.0,0.0,3.0,1 +54.0,0.0,3.0,108.0,267.0,0.0,2.0,167.0,0.0,0.0,1.0,0.0,3.0,1 +64.0,0.0,4.0,130.0,303.0,0.0,0.0,122.0,0.0,2.0,2.0,2.0,3.0,1 +51.0,0.0,3.0,130.0,256.0,0.0,2.0,149.0,0.0,0.5,1.0,0.0,3.0,1 +46.0,0.0,2.0,105.0,204.0,0.0,0.0,172.0,0.0,0.0,1.0,0.0,3.0,1 +55.0,1.0,4.0,140.0,217.0,0.0,0.0,111.0,1.0,5.6,3.0,0.0,7.0,2 +45.0,1.0,2.0,128.0,308.0,0.0,2.0,170.0,0.0,0.0,1.0,0.0,3.0,1 +56.0,1.0,1.0,120.0,193.0,0.0,2.0,162.0,0.0,1.9,2.0,0.0,7.0,1 +66.0,0.0,4.0,178.0,228.0,1.0,0.0,165.0,1.0,1.0,2.0,2.0,7.0,2 +38.0,1.0,1.0,120.0,231.0,0.0,0.0,182.0,1.0,3.8,2.0,0.0,7.0,2 +62.0,0.0,4.0,150.0,244.0,0.0,0.0,154.0,1.0,1.4,2.0,0.0,3.0,2 +55.0,1.0,2.0,130.0,262.0,0.0,0.0,155.0,0.0,0.0,1.0,0.0,3.0,1 +58.0,1.0,4.0,128.0,259.0,0.0,2.0,130.0,1.0,3.0,2.0,2.0,7.0,2 +43.0,1.0,4.0,110.0,211.0,0.0,0.0,161.0,0.0,0.0,1.0,0.0,7.0,1 +64.0,0.0,4.0,180.0,325.0,0.0,0.0,154.0,1.0,0.0,1.0,0.0,3.0,1 +50.0,0.0,4.0,110.0,254.0,0.0,2.0,159.0,0.0,0.0,1.0,0.0,3.0,1 +53.0,1.0,3.0,130.0,197.0,1.0,2.0,152.0,0.0,1.2,3.0,0.0,3.0,1 +45.0,0.0,4.0,138.0,236.0,0.0,2.0,152.0,1.0,0.2,2.0,0.0,3.0,1 +65.0,1.0,1.0,138.0,282.0,1.0,2.0,174.0,0.0,1.4,2.0,1.0,3.0,2 +69.0,1.0,1.0,160.0,234.0,1.0,2.0,131.0,0.0,0.1,2.0,1.0,3.0,1 +69.0,1.0,3.0,140.0,254.0,0.0,2.0,146.0,0.0,2.0,2.0,3.0,7.0,2 +67.0,1.0,4.0,100.0,299.0,0.0,2.0,125.0,1.0,0.9,2.0,2.0,3.0,2 +68.0,0.0,3.0,120.0,211.0,0.0,2.0,115.0,0.0,1.5,2.0,0.0,3.0,1 +34.0,1.0,1.0,118.0,182.0,0.0,2.0,174.0,0.0,0.0,1.0,0.0,3.0,1 +62.0,0.0,4.0,138.0,294.0,1.0,0.0,106.0,0.0,1.9,2.0,3.0,3.0,2 +51.0,1.0,4.0,140.0,298.0,0.0,0.0,122.0,1.0,4.2,2.0,3.0,7.0,2 +46.0,1.0,3.0,150.0,231.0,0.0,0.0,147.0,0.0,3.6,2.0,0.0,3.0,2 +67.0,1.0,4.0,125.0,254.0,1.0,0.0,163.0,0.0,0.2,2.0,2.0,7.0,2 +50.0,1.0,3.0,129.0,196.0,0.0,0.0,163.0,0.0,0.0,1.0,0.0,3.0,1 +42.0,1.0,3.0,120.0,240.0,1.0,0.0,194.0,0.0,0.8,3.0,0.0,7.0,1 +56.0,0.0,4.0,134.0,409.0,0.0,2.0,150.0,1.0,1.9,2.0,2.0,7.0,2 +41.0,1.0,4.0,110.0,172.0,0.0,2.0,158.0,0.0,0.0,1.0,0.0,7.0,2 +42.0,0.0,4.0,102.0,265.0,0.0,2.0,122.0,0.0,0.6,2.0,0.0,3.0,1 +53.0,1.0,3.0,130.0,246.0,1.0,2.0,173.0,0.0,0.0,1.0,3.0,3.0,1 +43.0,1.0,3.0,130.0,315.0,0.0,0.0,162.0,0.0,1.9,1.0,1.0,3.0,1 +56.0,1.0,4.0,132.0,184.0,0.0,2.0,105.0,1.0,2.1,2.0,1.0,6.0,2 +52.0,1.0,4.0,108.0,233.0,1.0,0.0,147.0,0.0,0.1,1.0,3.0,7.0,1 +62.0,0.0,4.0,140.0,394.0,0.0,2.0,157.0,0.0,1.2,2.0,0.0,3.0,1 +70.0,1.0,3.0,160.0,269.0,0.0,0.0,112.0,1.0,2.9,2.0,1.0,7.0,2 +54.0,1.0,4.0,140.0,239.0,0.0,0.0,160.0,0.0,1.2,1.0,0.0,3.0,1 +70.0,1.0,4.0,145.0,174.0,0.0,0.0,125.0,1.0,2.6,3.0,0.0,7.0,2 +54.0,1.0,2.0,108.0,309.0,0.0,0.0,156.0,0.0,0.0,1.0,0.0,7.0,1 +35.0,1.0,4.0,126.0,282.0,0.0,2.0,156.0,1.0,0.0,1.0,0.0,7.0,2 +48.0,1.0,3.0,124.0,255.0,1.0,0.0,175.0,0.0,0.0,1.0,2.0,3.0,1 +55.0,0.0,2.0,135.0,250.0,0.0,2.0,161.0,0.0,1.4,2.0,0.0,3.0,1 +58.0,0.0,4.0,100.0,248.0,0.0,2.0,122.0,0.0,1.0,2.0,0.0,3.0,1 +54.0,0.0,3.0,110.0,214.0,0.0,0.0,158.0,0.0,1.6,2.0,0.0,3.0,1 +69.0,0.0,1.0,140.0,239.0,0.0,0.0,151.0,0.0,1.8,1.0,2.0,3.0,1 +77.0,1.0,4.0,125.0,304.0,0.0,2.0,162.0,1.0,0.0,1.0,3.0,3.0,2 +68.0,1.0,3.0,118.0,277.0,0.0,0.0,151.0,0.0,1.0,1.0,1.0,7.0,1 +58.0,1.0,4.0,125.0,300.0,0.0,2.0,171.0,0.0,0.0,1.0,2.0,7.0,2 +60.0,1.0,4.0,125.0,258.0,0.0,2.0,141.0,1.0,2.8,2.0,1.0,7.0,2 +51.0,1.0,4.0,140.0,299.0,0.0,0.0,173.0,1.0,1.6,1.0,0.0,7.0,2 +55.0,1.0,4.0,160.0,289.0,0.0,2.0,145.0,1.0,0.8,2.0,1.0,7.0,2 +52.0,1.0,1.0,152.0,298.0,1.0,0.0,178.0,0.0,1.2,2.0,0.0,7.0,1 +60.0,0.0,3.0,102.0,318.0,0.0,0.0,160.0,0.0,0.0,1.0,1.0,3.0,1 +58.0,1.0,3.0,105.0,240.0,0.0,2.0,154.0,1.0,0.6,2.0,0.0,7.0,1 +64.0,1.0,3.0,125.0,309.0,0.0,0.0,131.0,1.0,1.8,2.0,0.0,7.0,2 +37.0,1.0,3.0,130.0,250.0,0.0,0.0,187.0,0.0,3.5,3.0,0.0,3.0,1 +59.0,1.0,1.0,170.0,288.0,0.0,2.0,159.0,0.0,0.2,2.0,0.0,7.0,2 +51.0,1.0,3.0,125.0,245.0,1.0,2.0,166.0,0.0,2.4,2.0,0.0,3.0,1 +43.0,0.0,3.0,122.0,213.0,0.0,0.0,165.0,0.0,0.2,2.0,0.0,3.0,1 +58.0,1.0,4.0,128.0,216.0,0.0,2.0,131.0,1.0,2.2,2.0,3.0,7.0,2 +29.0,1.0,2.0,130.0,204.0,0.0,2.0,202.0,0.0,0.0,1.0,0.0,3.0,1 +41.0,0.0,2.0,130.0,204.0,0.0,2.0,172.0,0.0,1.4,1.0,0.0,3.0,1 +63.0,0.0,3.0,135.0,252.0,0.0,2.0,172.0,0.0,0.0,1.0,0.0,3.0,1 +51.0,1.0,3.0,94.0,227.0,0.0,0.0,154.0,1.0,0.0,1.0,1.0,7.0,1 +54.0,1.0,3.0,120.0,258.0,0.0,2.0,147.0,0.0,0.4,2.0,0.0,7.0,1 +44.0,1.0,2.0,120.0,220.0,0.0,0.0,170.0,0.0,0.0,1.0,0.0,3.0,1 +54.0,1.0,4.0,110.0,239.0,0.0,0.0,126.0,1.0,2.8,2.0,1.0,7.0,2 +65.0,1.0,4.0,135.0,254.0,0.0,2.0,127.0,0.0,2.8,2.0,1.0,7.0,2 +57.0,1.0,3.0,150.0,168.0,0.0,0.0,174.0,0.0,1.6,1.0,0.0,3.0,1 +63.0,1.0,4.0,130.0,330.0,1.0,2.0,132.0,1.0,1.8,1.0,3.0,7.0,2 +35.0,0.0,4.0,138.0,183.0,0.0,0.0,182.0,0.0,1.4,1.0,0.0,3.0,1 +41.0,1.0,2.0,135.0,203.0,0.0,0.0,132.0,0.0,0.0,2.0,0.0,6.0,1 +62.0,0.0,3.0,130.0,263.0,0.0,0.0,97.0,0.0,1.2,2.0,1.0,7.0,2 +43.0,0.0,4.0,132.0,341.0,1.0,2.0,136.0,1.0,3.0,2.0,0.0,7.0,2 +58.0,0.0,1.0,150.0,283.0,1.0,2.0,162.0,0.0,1.0,1.0,0.0,3.0,1 +52.0,1.0,1.0,118.0,186.0,0.0,2.0,190.0,0.0,0.0,2.0,0.0,6.0,1 +61.0,0.0,4.0,145.0,307.0,0.0,2.0,146.0,1.0,1.0,2.0,0.0,7.0,2 +39.0,1.0,4.0,118.0,219.0,0.0,0.0,140.0,0.0,1.2,2.0,0.0,7.0,2 +45.0,1.0,4.0,115.0,260.0,0.0,2.0,185.0,0.0,0.0,1.0,0.0,3.0,1 +52.0,1.0,4.0,128.0,255.0,0.0,0.0,161.0,1.0,0.0,1.0,1.0,7.0,2 +62.0,1.0,3.0,130.0,231.0,0.0,0.0,146.0,0.0,1.8,2.0,3.0,7.0,1 +62.0,0.0,4.0,160.0,164.0,0.0,2.0,145.0,0.0,6.2,3.0,3.0,7.0,2 +53.0,0.0,4.0,138.0,234.0,0.0,2.0,160.0,0.0,0.0,1.0,0.0,3.0,1 +43.0,1.0,4.0,120.0,177.0,0.0,2.0,120.0,1.0,2.5,2.0,0.0,7.0,2 +47.0,1.0,3.0,138.0,257.0,0.0,2.0,156.0,0.0,0.0,1.0,0.0,3.0,1 +52.0,1.0,2.0,120.0,325.0,0.0,0.0,172.0,0.0,0.2,1.0,0.0,3.0,1 +68.0,1.0,3.0,180.0,274.0,1.0,2.0,150.0,1.0,1.6,2.0,0.0,7.0,2 +39.0,1.0,3.0,140.0,321.0,0.0,2.0,182.0,0.0,0.0,1.0,0.0,3.0,1 +53.0,0.0,4.0,130.0,264.0,0.0,2.0,143.0,0.0,0.4,2.0,0.0,3.0,1 +62.0,0.0,4.0,140.0,268.0,0.0,2.0,160.0,0.0,3.6,3.0,2.0,3.0,2 +51.0,0.0,3.0,140.0,308.0,0.0,2.0,142.0,0.0,1.5,1.0,1.0,3.0,1 +60.0,1.0,4.0,130.0,253.0,0.0,0.0,144.0,1.0,1.4,1.0,1.0,7.0,2 +65.0,1.0,4.0,110.0,248.0,0.0,2.0,158.0,0.0,0.6,1.0,2.0,6.0,2 +65.0,0.0,3.0,155.0,269.0,0.0,0.0,148.0,0.0,0.8,1.0,0.0,3.0,1 +60.0,1.0,3.0,140.0,185.0,0.0,2.0,155.0,0.0,3.0,2.0,0.0,3.0,2 +60.0,1.0,4.0,145.0,282.0,0.0,2.0,142.0,1.0,2.8,2.0,2.0,7.0,2 +54.0,1.0,4.0,120.0,188.0,0.0,0.0,113.0,0.0,1.4,2.0,1.0,7.0,2 +44.0,1.0,2.0,130.0,219.0,0.0,2.0,188.0,0.0,0.0,1.0,0.0,3.0,1 +44.0,1.0,4.0,112.0,290.0,0.0,2.0,153.0,0.0,0.0,1.0,1.0,3.0,2 +51.0,1.0,3.0,110.0,175.0,0.0,0.0,123.0,0.0,0.6,1.0,0.0,3.0,1 +59.0,1.0,3.0,150.0,212.0,1.0,0.0,157.0,0.0,1.6,1.0,0.0,3.0,1 +71.0,0.0,2.0,160.0,302.0,0.0,0.0,162.0,0.0,0.4,1.0,2.0,3.0,1 +61.0,1.0,3.0,150.0,243.0,1.0,0.0,137.0,1.0,1.0,2.0,0.0,3.0,1 +55.0,1.0,4.0,132.0,353.0,0.0,0.0,132.0,1.0,1.2,2.0,1.0,7.0,2 +64.0,1.0,3.0,140.0,335.0,0.0,0.0,158.0,0.0,0.0,1.0,0.0,3.0,2 +43.0,1.0,4.0,150.0,247.0,0.0,0.0,171.0,0.0,1.5,1.0,0.0,3.0,1 +58.0,0.0,3.0,120.0,340.0,0.0,0.0,172.0,0.0,0.0,1.0,0.0,3.0,1 +60.0,1.0,4.0,130.0,206.0,0.0,2.0,132.0,1.0,2.4,2.0,2.0,7.0,2 +58.0,1.0,2.0,120.0,284.0,0.0,2.0,160.0,0.0,1.8,2.0,0.0,3.0,2 +49.0,1.0,2.0,130.0,266.0,0.0,0.0,171.0,0.0,0.6,1.0,0.0,3.0,1 +48.0,1.0,2.0,110.0,229.0,0.0,0.0,168.0,0.0,1.0,3.0,0.0,7.0,2 +52.0,1.0,3.0,172.0,199.0,1.0,0.0,162.0,0.0,0.5,1.0,0.0,7.0,1 +44.0,1.0,2.0,120.0,263.0,0.0,0.0,173.0,0.0,0.0,1.0,0.0,7.0,1 +56.0,0.0,2.0,140.0,294.0,0.0,2.0,153.0,0.0,1.3,2.0,0.0,3.0,1 +57.0,1.0,4.0,140.0,192.0,0.0,0.0,148.0,0.0,0.4,2.0,0.0,6.0,1 +67.0,1.0,4.0,160.0,286.0,0.0,2.0,108.0,1.0,1.5,2.0,3.0,3.0,2 \ No newline at end of file Added: trunk/test/qtl/heart/heart.owl =================================================================== --- trunk/test/qtl/heart/heart.owl (rev 0) +++ trunk/test/qtl/heart/heart.owl 2014-05-22 11:04:32 UTC (rev 4270) @@ -0,0 +1,5968 @@ +<?xml version="1.0"?> +<rdf:RDF xmlns="http://dl-learner.org/heart#" + xml:base="http://dl-learner.org/heart" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:heart="http://dl-learner.org/heart#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:hasBloodSugarOver120mg="http://dl-learner.org/heart#hasBloodSugarOver120mg/"> + <owl:Ontology rdf:about="http://dl-learner.org/heart"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Object Properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/heart#hasChestPain --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/heart#hasChestPain"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://dl-learner.org/heart#Thing"/> + </owl:ObjectProperty> + + + + <!-- http://dl-learner.org/heart#hasElectrocardiographicResults --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/heart#hasElectrocardiographicResults"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://dl-learner.org/heart#Thing"/> + </owl:ObjectProperty> + + + + <!-- http://dl-learner.org/heart#hasGender --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/heart#hasGender"> + <rdfs:range rdf:resource="http://dl-learner.org/heart#Gender"/> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + </owl:ObjectProperty> + + + + <!-- http://dl-learner.org/heart#hasThalValue --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/heart#hasThalValue"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://dl-learner.org/heart#Thals"/> + </owl:ObjectProperty> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Data properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/heart#hasAge --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasAge"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasAngina --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasAngina"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasBloodPressure --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasBloodPressure"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasBloodSugarOver120mg/dl --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasBloodSugarOver120mg/dl"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasCholestoral --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasCholestoral"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasMajorVessels --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasMajorVessels"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasMaximumHeartRate --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasMaximumHeartRate"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasOldPeak --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasOldPeak"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/heart#hasStSegment --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/heart#hasStSegment"> + <rdfs:domain rdf:resource="http://dl-learner.org/heart#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Classes + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/heart#Gender --> + + <owl:Class rdf:about="http://dl-learner.org/heart#Gender"/> + + + + <!-- http://dl-learner.org/heart#Patient --> + + <owl:Class rdf:about="http://dl-learner.org/heart#Patient"/> + + + + <!-- http://dl-learner.org/heart#Thals --> + + <owl:Class rdf:about="http://dl-learner.org/heart#Thals"/> + + + + <!-- http://dl-learner.org/heart#Thing --> + + <owl:Class rdf:about="http://dl-learner.org/heart#Thing"/> + + + + <!-- http://dl-learner.org/heart#fixed-defect --> + + <owl:Class rdf:about="http://dl-learner.org/heart#fixed-defect"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/heart#Thals"/> + </owl:Class> + + + + <!-- http://dl-learner.org/heart#normal --> + + <owl:Class rdf:about="http://dl-learner.org/heart#normal"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/heart#Thals"/> + </owl:Class> + + + + <!-- http://dl-learner.org/heart#reversable-defect --> + + <owl:Class rdf:about="http://dl-learner.org/heart#reversable-defect"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/heart#Thals"/> + </owl:Class> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Individuals + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/heart#0.0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#0.0"/> + + + + <!-- http://dl-learner.org/heart#1.0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#1.0"/> + + + + <!-- http://dl-learner.org/heart#2.0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#2.0"/> + + + + <!-- http://dl-learner.org/heart#3.0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#3.0"/> + + + + <!-- http://dl-learner.org/heart#4.0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#4.0"/> + + + + <!-- http://dl-learner.org/heart#Patient0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient0"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">109.0</hasMaximumHeartRate> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">130.0</hasBloodPressure> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.4</hasOldPeak> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.0</hasMajorVessels> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">322.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">70.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient1"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.6</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">115.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">160.0</hasMaximumHeartRate> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">564.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">67.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#3.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient10 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient10"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.5</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">135.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">161.0</hasMaximumHeartRate> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">234.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">59.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient100 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient100"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.6</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">108.0</hasBloodPressure> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">141.0</hasCholestoral> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">175.0</hasMaximumHeartRate> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">44.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#3.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient101 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient101"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">120.0</hasBloodPressure> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">237.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">67.0</hasAge> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">71.0</hasMaximumHeartRate> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient102 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient102"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">130.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">163.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">269.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">49.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient103 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient103"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasOldPeak> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">124.0</hasMaximumHeartRate> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">165.0</hasBloodPressure> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">289.0</hasCholestoral> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.0</hasMajorVessels> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">57.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient104 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient104"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.4</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">130.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">147.0</hasMaximumHeartRate> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">254.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">63.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient105 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient105"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.5</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">124.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">166.0</hasMaximumHeartRate> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">274.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">48.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient106 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient106"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.2</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">100.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">143.0</hasMaximumHeartRate> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">222.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">51.0</hasAge> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasAngina> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#3.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient107 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient107"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">150.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">157.0</hasMaximumHeartRate> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasMajorVessels> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.6</hasOldPeak> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">258.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">60.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient108 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient108"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasMajorVessels> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">140.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">162.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">177.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">59.0</hasAge> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasAngina> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient109 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient109"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">112.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">138.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">160.0</hasCholestoral> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">45.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient11 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient11"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">111.0</hasMaximumHeartRate> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">142.0</hasBloodPressure> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">226.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">53.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient110 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient110"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">117.0</hasMaximumHeartRate> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">180.0</hasBloodPressure> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.4</hasOldPeak> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">327.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">55.0</hasAge> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasAngina> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#1.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient111 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient111"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">110.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">153.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">235.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">41.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient112 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient112"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">158.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">161.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">305.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">60.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient113 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient113"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">135.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">170.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">304.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">54.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#3.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient114 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient114"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">120.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">162.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">295.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">42.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient115 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient115"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasOldPeak> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">134.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">162.0</hasMaximumHeartRate> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasStSegment> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">271.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">49.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient116 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient116"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.8</hasOldPeak> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</hasStSegment> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">120.0</hasBloodPressure> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">144.0</hasMaximumHeartRate> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">249.0</hasCholestoral> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">46.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#female"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient117 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient117"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">133.0</hasMaximumHeartRate> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</hasMajorVessels> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">200.0</hasBloodPressure> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">288.0</hasCholestoral> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.0</hasStSegment> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasOldPeak> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">56.0</hasAge> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasAngina> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#reversable-defect"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient118 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient118"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">114.0</hasMaximumHeartRate> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">150.0</hasBloodPressure> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.6</hasOldPeak> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">226.0</hasCholestoral> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.0</hasStSegment> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">66.0</hasAge> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasAngina> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#0.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#1.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart#male"/> + <hasThalValue rdf:resource="http://dl-learner.org/heart#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/heart#Patient119 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/heart#Patient119"> + <rdf:type rdf:resource="http://dl-learner.org/heart#Patient"/> + <hasMajorVessels rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.0</hasMajorVessels> + <hasOldPeak rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.6</hasOldPeak> + <hasMaximumHeartRate rdf:datatype="http://www.w3.org/2001/XMLSchema#double">103.0</hasMaximumHeartRate> + <hasBloodPressure rdf:datatype="http://www.w3.org/2001/XMLSchema#double">130.0</hasBloodPressure> + <hasCholestoral rdf:datatype="http://www.w3.org/2001/XMLSchema#double">283.0</hasCholestoral> + <hasStSegment rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.0</hasStSegment> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">56.0</hasAge> + <hasBloodSugarOver120mg:dl rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasBloodSugarOver120mg:dl> + <hasAngina rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</hasAngina> + <hasElectrocardiographicResults rdf:resource="http://dl-learner.org/heart#2.0"/> + <hasChestPain rdf:resource="http://dl-learner.org/heart#4.0"/> + <hasGender rdf:resource="http://dl-learner.org/heart... [truncated message content] |
From: <lor...@us...> - 2014-05-22 02:22:20
|
Revision: 4269 http://sourceforge.net/p/dl-learner/code/4269 Author: lorenz_b Date: 2014-05-22 02:22:16 +0000 (Thu, 22 May 2014) Log Message: ----------- Updated Maven libs. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLDataRangeConverter.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java trunk/examples/mutagenesis/train1.conf trunk/pom.xml trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java trunk/test/qtl/alzheimer/train1.conf Added Paths: ----------- trunk/dllearner-parent.iml Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/pom.xml 2014-05-22 02:22:16 UTC (rev 4269) @@ -115,12 +115,15 @@ <artifactId>log4j</artifactId> </dependency> - <!-- Latest JENA ARQ - we have to exclude XercesImpl and use an older version here because use version bei JENA leads to some errors --> <dependency> <groupId>org.apache.jena</groupId> <artifactId>jena-arq</artifactId> - </dependency> + + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>jena-core</artifactId> + </dependency> <!--JSON is in Central --> <dependency> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -118,7 +118,6 @@ public ELLearningAlgorithm(AbstractLearningProblem problem, AbstractReasonerComponent reasoner) { super(problem, reasoner); // configurator = new ELLearningAlgorithmConfigurator(this); - timeMonitor = MonitorFactory.getTimeMonitor("time"); } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.PriorityQueue; @@ -17,11 +16,12 @@ import java.util.SortedSet; import java.util.TreeSet; -import org.apache.commons.collections.ListUtils; import org.apache.log4j.Logger; import org.dllearner.algorithms.qtl.cache.QueryTreeCache; import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.LiteralNodeConversionStrategy; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.LiteralNodeSubsumptionStrategy; import org.dllearner.algorithms.qtl.operations.lgg.EvaluatedQueryTree; import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; @@ -31,9 +31,7 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; -import org.dllearner.core.Score; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -43,7 +41,6 @@ import org.dllearner.learningproblems.Heuristics; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.QueryTreeScore; -import org.dllearner.learningproblems.ScoreTwoValued; import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; import org.dllearner.utilities.owl.OWLAPIConverter; import org.semanticweb.owlapi.io.ToStringRenderer; @@ -141,6 +138,11 @@ super(qtl.getLearningProblem(), qtl.getReasoner()); this.model = ModelFactory.createDefaultModel(); this.model.add(qtl.model); + this.beta = qtl.beta; + this.maxExecutionTimeInSeconds = qtl.maxExecutionTimeInSeconds; + this.maxTreeComputationTimeInSeconds = qtl.maxTreeComputationTimeInSeconds; + this.tryFullCoverage = qtl.tryFullCoverage; + this.stopOnFirstDefinition = qtl.stopOnFirstDefinition; } public EvaluatedQueryTree<String> getBestSolution(){ @@ -160,10 +162,10 @@ lggGenerator = new LGGGeneratorImpl<String>(); -// if(heuristic == null){ + if(heuristic == null){ heuristic = new QueryTreeHeuristic(); heuristic.setPosExamplesWeight(beta); -// } + } logger.info("Initializing..."); treeCache = new QueryTreeCache(model); @@ -218,12 +220,7 @@ */ @Override public void start() { - String setup = "Setup:"; - setup += "\n#Pos. examples:" + currentPosExamples.size(); - setup += "\n#Neg. examples:" + currentNegExamples.size(); - setup += "Heuristic:" + heuristic.getHeuristicType().name(); - setup += "\nbeta=" + beta; - logger.info(setup); + showSetup(); logger.info("Running..."); startTime = System.currentTimeMillis(); @@ -235,12 +232,9 @@ logger.info("#Remaining pos. examples:" + currentPosExampleTrees.size()); logger.info("#Remaining neg. examples:" + currentNegExampleTrees.size()); - //compute a (partial) solution - computeBestPartialSolution(); + //compute best (partial) solution computed so far + EvaluatedQueryTree<String> bestPartialSolution = computeBestPartialSolution(); - //pick best (partial) solution computed so far - EvaluatedQueryTree<String> bestPartialSolution = currentPartialSolutions.first(); - //add if some criteria are satisfied if(bestPartialSolution.getScore() >= minimumTreeScore){ @@ -284,12 +278,13 @@ } - private void computeBestPartialSolution(){ + private EvaluatedQueryTree<String> computeBestPartialSolution(){ logger.info("Computing best partial solution..."); bestCurrentScore = Double.NEGATIVE_INFINITY; partialSolutionStartTime = System.currentTimeMillis(); initTodoList(currentPosExampleTrees, currentNegExampleTrees); + EvaluatedQueryTree<String> bestPartialSolutionTree = null; EvaluatedQueryTree<String> currentElement; QueryTree<String> currentTree; while(!partialSolutionTerminationCriteriaSatisfied()){ @@ -307,30 +302,34 @@ lggMon.stop(); //evaluate the LGG - EvaluatedQueryTree<String> solution = evaluate(lgg, true); - double score = solution.getScore(); - double mas = heuristic.getMaximumAchievableScore(solution); - - if(score >= bestCurrentScore){ - //add to todo list, if not already contained in todo list or solution list - todo(solution); - if(score > bestCurrentScore){ - logger.info("\tGot better solution:" + solution.getTreeScore()); + Set<EvaluatedQueryTree<String>> solutions = evaluate(lgg, true); + for (EvaluatedQueryTree<String> solution : solutions) { + double score = solution.getScore(); + double mas = heuristic.getMaximumAchievableScore(solution); + + if(score >= bestCurrentScore){ + //add to todo list, if not already contained in todo list or solution list + todo(solution); + if(score > bestCurrentScore){ + logger.info("\tGot better solution:" + solution.getTreeScore()); + bestCurrentScore = score; + bestPartialSolutionTree = solution; + } + + } else if(mas >= bestCurrentScore){ + todo(solution); + } else { +// System.out.println("Too general"); +// System.out.println("MAS=" + mas + "\nBest=" + bestCurrentScore); } - bestCurrentScore = solution.getScore(); - } else if(mas < bestCurrentScore){ - todo(solution); - } else { - System.out.println("Too general"); + currentPartialSolutions.add(currentElement); } - currentPartialSolutions.add(currentElement); - } currentPartialSolutions.add(currentElement); } long endTime = System.currentTimeMillis(); logger.info("...finished in " + (endTime-partialSolutionStartTime) + "ms."); - EvaluatedDescription bestPartialSolution = currentPartialSolutions.first().asEvaluatedDescription(); + EvaluatedDescription bestPartialSolution = bestPartialSolutionTree.asEvaluatedDescription(LiteralNodeConversionStrategy.SOME_VALUES_FROM); logger.info("Best partial solution: " + OWLAPIConverter.getOWLAPIDescription(bestPartialSolution.getDescription()).toString().replace("\n", "") + "\n(" + bestPartialSolution.getScore() + ")"); @@ -340,9 +339,11 @@ logger.trace("Subsumption test time: " + subMon.getTotal() + "ms"); logger.trace("Avg. subsumption test time: " + subMon.getAvg() + "ms"); logger.trace("#Subsumption tests: " + subMon.getHits()); + + return bestPartialSolutionTree; } - private EvaluatedQueryTree<String> evaluate(QueryTree<String> tree, boolean useSpecifity){ + private EvaluatedQueryTree<String> evaluateSimple(QueryTree<String> tree, boolean useSpecifity){ //1. get a score for the coverage = recall oriented //compute positive examples which are not covered by LGG List<QueryTree<String>> uncoveredPositiveExampleTrees = getUncoveredTrees(tree, currentPosExampleTrees); @@ -399,45 +400,191 @@ return evaluatedTree; } - private EvaluatedDescription buildCombinedSolution(){ - if(partialSolutions.size() == 1){ - EvaluatedDescription combinedSolution = partialSolutions.get(0).asEvaluatedDescription(); - return combinedSolution; + /** + * Returns a set of evaluated query trees. A set is returned because there are several ways how to convert literal nodes. + * @param tree + * @param useSpecifity + * @return + */ + private Set<EvaluatedQueryTree<String>> evaluate(QueryTree<String> tree, boolean useSpecifity){ + Set<EvaluatedQueryTree<String>> evaluatedTrees = new TreeSet<EvaluatedQueryTree<String>>(); + + LiteralNodeSubsumptionStrategy[] strategies = LiteralNodeSubsumptionStrategy.values(); + strategies = new LiteralNodeSubsumptionStrategy[]{LiteralNodeSubsumptionStrategy.DATATYPE, LiteralNodeSubsumptionStrategy.INTERVAL}; + for (LiteralNodeSubsumptionStrategy strategy : strategies) { + //1. get a score for the coverage = recall oriented + List<QueryTree<String>> uncoveredPositiveExampleTrees = new ArrayList<QueryTree<String>>(); + List<QueryTree<String>> coveredNegativeExampleTrees = new ArrayList<QueryTree<String>>(); + + //compute positive examples which are not covered by LGG + for (QueryTree<String> posTree : currentPosExampleTrees) { + if(!posTree.isSubsumedBy(tree, strategy)){ + uncoveredPositiveExampleTrees.add(posTree); + } + } + //compute negative examples which are covered by LGG + for (QueryTree<String> negTree : currentNegExampleTrees) { + if(negTree.isSubsumedBy(tree, strategy)){ + coveredNegativeExampleTrees.add(negTree); + } + } + //convert to individuals + Set<Individual> uncoveredPosExamples = asIndividuals(uncoveredPositiveExampleTrees); + Set<Individual> coveredNegExamples = asIndividuals(coveredNegativeExampleTrees); + + //compute score + int coveredPositiveExamples = currentPosExampleTrees.size() - uncoveredPositiveExampleTrees.size(); + double recall = coveredPositiveExamples / (double)currentPosExampleTrees.size(); + double precision = (coveredNegativeExampleTrees.size() + coveredPositiveExamples == 0) + ? 0 + : coveredPositiveExamples / (double)(coveredPositiveExamples + coveredNegativeExampleTrees.size()); + + double coverageScore = Heuristics.getFScore(recall, precision, beta); + + //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented + int nrOfSpecificNodes = 0; + for (QueryTree<String> childNode : tree.getChildrenClosure()) { + if(!childNode.getUserObject().equals("?")){ + nrOfSpecificNodes++; + } + } + double specifityScore = 0d; + if(useSpecifity){ + specifityScore = Math.log(nrOfSpecificNodes); + } + + //3.compute the total score + double score = coverageWeight * coverageScore + specifityWeight * specifityScore; + + QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, + new TreeSet<Individual>(Sets.difference(currentPosExamples, uncoveredPosExamples)), uncoveredPosExamples, + coveredNegExamples, new TreeSet<Individual>(Sets.difference(currentNegExamples, coveredNegExamples)), + specifityScore, nrOfSpecificNodes); + + EvaluatedQueryTree<String> evaluatedTree = new EvaluatedQueryTree<String>(tree, uncoveredPositiveExampleTrees, coveredNegativeExampleTrees, queryTreeScore); + + //TODO use only the heuristic to compute the score + score = heuristic.getScore(evaluatedTree); + queryTreeScore.setScore(score); + queryTreeScore.setAccuracy(score); + + evaluatedTrees.add(evaluatedTree); } - List<Description> disjuncts = new ArrayList<Description>(); - Set<Individual> posCovered = new HashSet<Individual>(); - Set<Individual> negCovered = new HashSet<Individual>(); + return evaluatedTrees; + } + + /** + * Returns a set of evaluated query trees. A set is returned because there are several ways how to convert literal nodes. + * @param tree + * @param useSpecifity + * @return + */ + private Set<EvaluatedDescription> evaluate2(QueryTree<String> tree, boolean useSpecifity){ + Set<EvaluatedDescription> evaluatedDescriptions = new TreeSet<EvaluatedDescription>(); - //build the union of all class expressions - Description partialDescription; - for (EvaluatedQueryTree<String> partialSolution : partialSolutions) { - partialDescription = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( - partialSolution.getTree().asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION)); - disjuncts.add(partialDescription); - posCovered.addAll(partialSolution.getTreeScore().getCoveredPositives()); - negCovered.addAll(partialSolution.getTreeScore().getCoveredNegatives()); + LiteralNodeConversionStrategy[] strategies = LiteralNodeConversionStrategy.values(); + strategies = new LiteralNodeConversionStrategy[]{LiteralNodeConversionStrategy.SOME_VALUES_FROM, LiteralNodeConversionStrategy.FACET_RESTRICTION}; + for (LiteralNodeConversionStrategy strategy : strategies) { + Description d = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(tree.asOWLClassExpression(strategy)); + //convert to individuals + SortedSet<Individual> coveredExamples = reasoner.getIndividuals(d); + Set<Individual> coveredPosExamples = new TreeSet<Individual>(Sets.intersection(currentPosExamples, coveredExamples)); + Set<Individual> uncoveredPosExamples = new TreeSet<Individual>(Sets.difference(currentPosExamples, coveredExamples)); + Set<Individual> coveredNegExamples = new TreeSet<Individual>(Sets.intersection(currentNegExamples, coveredExamples)); + + //compute score + double recall = coveredPosExamples.size() / (double)currentPosExamples.size(); + double precision = (coveredNegExamples.size() + coveredPosExamples.size() == 0) + ? 0 + : coveredPosExamples.size() / (double)(coveredPosExamples.size() + coveredNegExamples.size()); + + double coverageScore = Heuristics.getFScore(recall, precision, beta); + + //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented + int nrOfSpecificNodes = 0; + for (QueryTree<String> childNode : tree.getChildrenClosure()) { + if(!childNode.getUserObject().equals("?")){ + nrOfSpecificNodes++; + } + } + double specifityScore = 0d; + if(useSpecifity){ + specifityScore = Math.log(nrOfSpecificNodes); + } + + //3.compute the total score + double score = coverageWeight * coverageScore + specifityWeight * specifityScore; + + QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, + new TreeSet<Individual>(Sets.difference(currentPosExamples, uncoveredPosExamples)), uncoveredPosExamples, + coveredNegExamples, new TreeSet<Individual>(Sets.difference(currentNegExamples, coveredNegExamples)), + specifityScore, nrOfSpecificNodes); + + //TODO use only the heuristic to compute the score +// score = heuristic.getScore(evaluatedTree); +// queryTreeScore.setScore(score); +// queryTreeScore.setAccuracy(score); +// +// EvaluatedDescription evaluatedDescription = new EvaluatedDescription(d, queryTreeScore); +// +// evaluatedDescriptions.add(evaluatedDescription); } - Description unionDescription = new Union(disjuncts); - Set<Individual> posNotCovered = Sets.difference(lp.getPositiveExamples(), posCovered); - Set<Individual> negNotCovered = Sets.difference(lp.getNegativeExamples(), negCovered); - - //compute the coverage - double recall = posCovered.size() / (double)lp.getPositiveExamples().size(); - double precision = (posCovered.size() + negCovered.size() == 0) - ? 0 - : posCovered.size() / (double)(posCovered.size() + negCovered.size()); - - double coverageScore = Heuristics.getFScore(recall, precision, beta); - -// ScoreTwoValued score = new ScoreTwoValued(posCovered, posNotCovered, negCovered, negNotCovered); -// score.setAccuracy(coverageScore); - QueryTreeScore score = new QueryTreeScore(coverageScore, coverageScore, posCovered, posNotCovered, negCovered, negNotCovered, -1, -1); - - return new EvaluatedDescription(unionDescription, score); + return evaluatedDescriptions; } + private EvaluatedDescription buildCombinedSolution(){ + EvaluatedDescription bestCombinedSolution = null; + double bestScore = Double.NEGATIVE_INFINITY; + LiteralNodeConversionStrategy[] strategies = LiteralNodeConversionStrategy.values(); + strategies = new LiteralNodeConversionStrategy[]{LiteralNodeConversionStrategy.SOME_VALUES_FROM}; + for (LiteralNodeConversionStrategy strategy : strategies) { + EvaluatedDescription combinedSolution; + if(partialSolutions.size() == 1){ + combinedSolution = partialSolutions.get(0).asEvaluatedDescription(strategy); + } else { + List<Description> disjuncts = new ArrayList<Description>(); + + Set<Individual> posCovered = new HashSet<Individual>(); + Set<Individual> negCovered = new HashSet<Individual>(); + + //build the union of all class expressions + Description partialDescription; + for (EvaluatedQueryTree<String> partialSolution : partialSolutions) { + partialDescription = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( + partialSolution.getTree().asOWLClassExpression(strategy)); + disjuncts.add(partialDescription); + posCovered.addAll(partialSolution.getTreeScore().getCoveredPositives()); + negCovered.addAll(partialSolution.getTreeScore().getCoveredNegatives()); + } + Description unionDescription = new Union(disjuncts); + + Set<Individual> posNotCovered = Sets.difference(lp.getPositiveExamples(), posCovered); + Set<Individual> negNotCovered = Sets.difference(lp.getNegativeExamples(), negCovered); + + //compute the coverage + double recall = posCovered.size() / (double)lp.getPositiveExamples().size(); + double precision = (posCovered.size() + negCovered.size() == 0) + ? 0 + : posCovered.size() / (double)(posCovered.size() + negCovered.size()); + + double coverageScore = Heuristics.getFScore(recall, precision, beta); + +// ScoreTwoValued score = new ScoreTwoValued(posCovered, posNotCovered, negCovered, negNotCovered); +// score.setAccuracy(coverageScore); + QueryTreeScore score = new QueryTreeScore(coverageScore, coverageScore, posCovered, posNotCovered, negCovered, negNotCovered, -1, -1); + + combinedSolution = new EvaluatedDescription(unionDescription, score); + } + if(combinedSolution.getAccuracy() > bestScore){ + bestCombinedSolution = combinedSolution; + bestCurrentScore = combinedSolution.getAccuracy(); + } + } + return bestCombinedSolution; + } + private void reset(){ currentBestSolution = null; partialSolutions = new ArrayList<EvaluatedQueryTree<String>>(); @@ -524,7 +671,20 @@ return treeCache; } + private Set<Individual> asIndividuals(Collection<QueryTree<String>> trees){ + Set<Individual> individuals = new HashSet<Individual>(trees.size()); + for (QueryTree<String> queryTree : trees) { + individuals.add(tree2Individual.get(queryTree)); + } + return individuals; + } + private void asTree(Description d){ + QueryTree<String> tree = new QueryTreeImpl<String>(""); + for (Description child : d.getChildren()) { + + } + } /** * Return all trees from the given list {@code allTrees} which are not already subsumed by {@code tree}. @@ -587,7 +747,7 @@ } } for (QueryTree<String> queryTree : distinctTrees) {//System.out.println(queryTree.getStringRepresentation()); - EvaluatedQueryTree<String> evaluatedQueryTree = evaluate(queryTree, false); + EvaluatedQueryTree<String> evaluatedQueryTree = evaluateSimple(queryTree, false); todoList.add(evaluatedQueryTree); } } @@ -656,6 +816,18 @@ } /** + * Shows the current setup of the algorithm. + */ + private void showSetup(){ + String setup = "Setup:"; + setup += "\n#Pos. examples:" + currentPosExamples.size(); + setup += "\n#Neg. examples:" + currentNegExamples.size(); + setup += "\nHeuristic:" + heuristic.getHeuristicType().name(); + setup += "\nbeta=" + beta; + logger.info(setup); + } + + /** * @param noisePercentage the noisePercentage to set */ public void setNoisePercentage(double noisePercentage) { @@ -684,6 +856,20 @@ this.maxTreeComputationTimeInSeconds = maxTreeComputationTimeInSeconds; } + /** + * @return the heuristic + */ + public QueryTreeHeuristic getHeuristic() { + return heuristic; + } + + /** + * @param heuristic the heuristic to set + */ + public void setHeuristic(QueryTreeHeuristic heuristic) { + this.heuristic = heuristic; + } + /* (non-Javadoc) * @see java.lang.Object#clone() */ Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -106,15 +106,19 @@ double mas = 0d; switch (heuristicType) { case FMEASURE: + mas = Double.POSITIVE_INFINITY; break; case PRED_ACC: mas = (posExamplesWeight * tp + tn - fp) / (posExamplesWeight * (tp + fn) + tn + fp); break; case ENTROPY: + mas = Double.POSITIVE_INFINITY; break; case MATTHEWS_CORRELATION: + mas = Double.POSITIVE_INFINITY; break; case YOUDEN_INDEX: + mas = Double.POSITIVE_INFINITY; break; default: break; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/QueryTree.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -87,6 +87,8 @@ void addChild(QueryTreeImpl<N> child, Object edge); + void addChild(QueryTree<N> child, Object edge); + void addChild(QueryTreeImpl<N> child, Object edge, int position); int removeChild(QueryTreeImpl<N> child); @@ -150,6 +152,8 @@ RDFDatatype getDatatype(); Set<Literal> getLiterals(); + + void setParent(QueryTree<N> parent); /** * @param edge Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -53,6 +53,9 @@ import org.jgrapht.ext.GraphMLExporter; import org.jgrapht.ext.VertexNameProvider; import org.jgrapht.graph.DefaultDirectedGraph; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLClassExpression; import org.semanticweb.owlapi.model.OWLDataFactory; @@ -101,6 +104,8 @@ public enum LiteralNodeSubsumptionStrategy { DATATYPE, INTERVAL, + MIN, + MAX, ENUMERATION, OFF } @@ -117,7 +122,11 @@ /** * Literals as datatype, e.g. xsd:integer */ - SOME_VALUES_FROM + SOME_VALUES_FROM, + + MIN, + + MAX, } private N userObject; @@ -169,7 +178,12 @@ } public QueryTreeImpl(N userObject, NodeType nodeType) { + this(userObject, nodeType, 0); + } + + public QueryTreeImpl(N userObject, NodeType nodeType, int id) { this.userObject = userObject; + this.id = id; children = new ArrayList<QueryTreeImpl<N>>(); child2EdgeMap = new HashMap<QueryTree<N>, Object>(); edge2ChildrenMap = new HashMap<String, List<QueryTree<N>>>(); @@ -305,13 +319,33 @@ this.parent = parent; this.parent.children.add(this); } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.qtl.datastructures.QueryTree#setParent(org.dllearner.algorithms.qtl.datastructures.QueryTree) + */ + @Override + public void setParent(QueryTree<N> parent) { + setParent((QueryTreeImpl<N>)parent); + } - public void addChild(QueryTreeImpl<N> child) { children.add(child); child.parent = this; } + public void addChild(QueryTree<N> child) { + children.add((QueryTreeImpl<N>) child); + child.setParent(this); + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.qtl.datastructures.QueryTree#addChild(org.dllearner.algorithms.qtl.datastructures.QueryTree, java.lang.Object) + */ + @Override + public void addChild(QueryTree<N> child, Object edge) { + addChild((QueryTreeImpl<N>)child, edge); + } + @Override public void addChild(QueryTreeImpl<N> child, int position) { children.add(position, child); @@ -516,10 +550,13 @@ private boolean subsumes(Set<Literal> subsumer, Set<Literal> subsumee, LiteralNodeSubsumptionStrategy strategy){ if(strategy == LiteralNodeSubsumptionStrategy.DATATYPE){ - + //check if both datatypes are the same + RDFDatatype subsumerDatatype = getDatatype(subsumer); + RDFDatatype subsumeeDatatype = getDatatype(subsumee); + return subsumerDatatype.equals(subsumeeDatatype); } else if(strategy == LiteralNodeSubsumptionStrategy.ENUMERATION){ return subsumer.containsAll(subsumee); - } else if(strategy == LiteralNodeSubsumptionStrategy.INTERVAL){ + } else { //check if both datatypes are the same RDFDatatype subsumerDatatype = getDatatype(subsumer); RDFDatatype subsumeeDatatype = getDatatype(subsumee); @@ -532,19 +569,35 @@ return true; } - //check if subsumee interval is contained in subsumer interval - Literal subsumerMin = getMin(subsumer); - Literal subsumerMax = getMax(subsumer); + if(strategy == LiteralNodeSubsumptionStrategy.INTERVAL){ + //check if subsumee interval is contained in subsumer interval + Literal subsumerMin = getMin(subsumer); + Literal subsumerMax = getMax(subsumer); + + Literal subsumeeMin = getMin(subsumee); + Literal subsumeeMax = getMax(subsumee); + + boolean leftMoreGeneral = isLessOrEqual(subsumerMin, subsumeeMin); + boolean rightMoreGeneral = isGreaterOrEqual(subsumerMax, subsumeeMax); + + if(!(leftMoreGeneral && rightMoreGeneral)){ + // System.out.println("[" + subsumeeMin + "," + subsumeeMax + "] not in interval " + "[" + subsumerMin + "," + subsumerMax + "]"); + return false; + } + } else if(strategy == LiteralNodeSubsumptionStrategy.MIN){ - Literal subsumeeMin = getMin(subsumee); - Literal subsumeeMax = getMax(subsumee); + //check if subsumee min is greater than subsumer min + Literal subsumerMin = getMin(subsumer); + Literal subsumeeMin = getMin(subsumee); + + return isGreaterOrEqual(subsumeeMin, subsumerMin); + } else if(strategy == LiteralNodeSubsumptionStrategy.MAX){ - boolean leftMoreGeneral = isLessOrEqual(subsumerMin, subsumeeMin); - boolean rightMoreGeneral = isGreaterOrEqual(subsumerMax, subsumeeMax); - - if(!(leftMoreGeneral && rightMoreGeneral)){ -// System.out.println("[" + subsumeeMin + "," + subsumeeMax + "] not in interval " + "[" + subsumerMin + "," + subsumerMax + "]"); - return false; + //check if subsumee min is greater than subsumer min + Literal subsumerMax = getMax(subsumer); + Literal subsumeeMax = getMax(subsumee); + + return isGreaterOrEqual(subsumerMax, subsumeeMax); } } return true; @@ -1417,6 +1470,10 @@ dataRange = asDataOneOf(df, literals); } else if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.FACET_RESTRICTION){ dataRange = asFacet(df, literals); + } else if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.MIN){ + dataRange = asMinFacet(df, literals); + } else if(literalNodeConversionStrategy == LiteralNodeConversionStrategy.MAX){ + dataRange = asMaxFacet(df, literals); } } classExpressions.add(df.getOWLDataSomeValuesFrom(p, dataRange)); @@ -1462,6 +1519,30 @@ return df.getOWLDatatypeRestriction(getOWLDatatype(df, literals), minRestriction, maxRestriction); } + private OWLDataRange asMinFacet(OWLDataFactory df, Set<Literal> literals){ + //return Boolean datatype because it doesn't make sense to return a facet of Boolean values + if(getOWLDatatype(df, literals).equals(df.getBooleanOWLDatatype())){ + return df.getBooleanOWLDatatype(); + } + Literal min = getMin(literals); + + OWLFacetRestriction minRestriction = df.getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, asOWLLiteral(df, min)); + + return df.getOWLDatatypeRestriction(getOWLDatatype(df, literals), minRestriction); + } + + private OWLDataRange asMaxFacet(OWLDataFactory df, Set<Literal> literals){ + //return Boolean datatype because it doesn't make sense to return a facet of Boolean values + if(getOWLDatatype(df, literals).equals(df.getBooleanOWLDatatype())){ + return df.getBooleanOWLDatatype(); + } + Literal max = getMax(literals); + + OWLFacetRestriction maxRestriction = df.getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, asOWLLiteral(df, max)); + + return df.getOWLDatatypeRestriction(getOWLDatatype(df, literals), maxRestriction); + } + private OWLDataRange asDataOneOf(OWLDataFactory df, Set<Literal> literals){ //return Boolean datatype because it doesn't make sense to return a enumeration of Boolean values if(getOWLDatatype(df, literals).equals(df.getBooleanOWLDatatype())){ @@ -1506,6 +1587,45 @@ } } + public String asJSON(){ + + PrefixCCMap prefixes = PrefixCCMap.getInstance(); + JSONObject json = null; + try { + json = buildJSON(this, prefixes); + JSONArray array = new JSONArray(); + buildJSON2(array, this, prefixes); + System.out.println(array); + } catch (JSONException e) { + e.printStackTrace(); + } + + + return json.toString(); + } + + private JSONObject buildJSON(QueryTree<N> tree, PrefixCCMap prefixes) throws JSONException{ + JSONObject json = new JSONObject(); + json.put("name", prefixed(prefixes, tree.getUserObject().toString())); + JSONArray children = new JSONArray(); + for (QueryTree<N> child : tree.getChildren()) { + children.put(buildJSON(child, prefixes)); + } + json.put("children", children); + return json; + } + + private void buildJSON2(JSONArray array, QueryTree<N> tree, PrefixCCMap prefixes) throws JSONException{ + for (QueryTree<N> child : tree.getChildren()) { + JSONObject json = new JSONObject(); + json.put("source", tree.getId()); + json.put("target", child.getId()); + json.put("type", prefixed(prefixes, tree.getEdge(child).toString())); + array.put(json); + buildJSON2(array, child, prefixes); + } + } + private String prefixed(Map<String, String> prefixes, String uri){ if(uri.startsWith("http://")){ for (Entry<String, String> entry : prefixes.entrySet()) { @@ -1561,5 +1681,9 @@ e.printStackTrace(); } } + + + + } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/EvaluatedQueryTree.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -8,6 +8,9 @@ import org.dllearner.learningproblems.QueryTreeScore; import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.Ordering; + public class EvaluatedQueryTree<N> implements Comparable<EvaluatedQueryTree<N>>{ private QueryTree<N> tree; @@ -57,14 +60,17 @@ @Override public int compareTo(EvaluatedQueryTree<N> other) { - double diff = getScore() - other.getScore(); - if(diff == 0){ - return -1; - } else if(diff > 0){ - return -1; - } else { - return 1; - } + return ComparisonChain.start() + .compare(this.getScore(), other.getScore()) + .result(); +// double diff = getScore() - other.getScore(); +// if(diff == 0){ +// return -1; +// } else if(diff > 0){ +// return -1; +// } else { +// return 1; +// } } public EvaluatedDescription asEvaluatedDescription(){ @@ -72,6 +78,11 @@ getTree().asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION)), score); } + public EvaluatedDescription asEvaluatedDescription(LiteralNodeConversionStrategy strategy){ + return new EvaluatedDescription(DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( + getTree().asOWLClassExpression(strategy)), score); + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -4,16 +4,65 @@ package org.dllearner.algorithms.qtl.util; import java.util.Collection; +import java.util.Stack; import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.NodeType; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLClassExpressionVisitor; +import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; +import org.semanticweb.owlapi.model.OWLDataComplementOf; +import org.semanticweb.owlapi.model.OWLDataExactCardinality; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDataHasValue; +import org.semanticweb.owlapi.model.OWLDataIntersectionOf; +import org.semanticweb.owlapi.model.OWLDataMaxCardinality; +import org.semanticweb.owlapi.model.OWLDataMinCardinality; +import org.semanticweb.owlapi.model.OWLDataOneOf; +import org.semanticweb.owlapi.model.OWLDataRangeVisitor; +import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLDataUnionOf; +import org.semanticweb.owlapi.model.OWLDatatype; +import org.semanticweb.owlapi.model.OWLDatatypeRestriction; +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectComplementOf; +import org.semanticweb.owlapi.model.OWLObjectExactCardinality; +import org.semanticweb.owlapi.model.OWLObjectHasSelf; +import org.semanticweb.owlapi.model.OWLObjectHasValue; +import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; +import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; +import org.semanticweb.owlapi.model.OWLObjectMinCardinality; +import org.semanticweb.owlapi.model.OWLObjectOneOf; +import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; +import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.PrefixManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.util.DefaultPrefixManager; +import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntaxObjectRenderer; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import com.hp.hpl.jena.vocabulary.RDF; + /** * Converts query trees into OWL class expressions and vice versa. * @author Lorenz Buehmann * */ -public class QueryTreeConverter { +public class QueryTreeConverter implements OWLClassExpressionVisitor, OWLDataRangeVisitor{ + Stack<QueryTree<String>> stack = new Stack<QueryTree<String>>(); + int id = 0; + /** * Returns a OWL class expression of the union of the given query trees. * @param queryTrees @@ -23,5 +72,246 @@ //check for common paths } + + public QueryTree<String> asQueryTree(OWLClassExpression expression){ +// stack.push(new QueryTreeImpl<String>("?")); + reset(); + expression.accept(this); + return stack.pop(); + } + + private void reset(){ + id = 0; + stack.clear(); + } + private void fireUnsupportedFeatureException(OWLClassExpression expression) { + throw new IllegalArgumentException("Conversion of " + expression.getClass().getSimpleName() + " is not supported."); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLClass) + */ + @Override + public void visit(OWLClass cls) { + stack.peek().addChild(new QueryTreeImpl<String>(cls.toStringID(), NodeType.RESOURCE, id++), RDF.type.getURI()); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectIntersectionOf) + */ + @Override + public void visit(OWLObjectIntersectionOf expr) { + boolean root = stack.isEmpty(); + stack.push(new QueryTreeImpl<String>("?", NodeType.VARIABLE, id++)); + for (OWLClassExpression op : expr.getOperandsAsList()) { + op.accept(this); + } +// if(!root) +// stack.pop(); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectUnionOf) + */ + @Override + public void visit(OWLObjectUnionOf expr) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectComplementOf) + */ + @Override + public void visit(OWLObjectComplementOf expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom) + */ + @Override + public void visit(OWLObjectSomeValuesFrom expr) { + QueryTree<String> parent = stack.peek(); + QueryTree<String> child; + OWLClassExpression filler = expr.getFiller(); + if(filler.isAnonymous()){ + if(!(filler instanceof OWLObjectIntersectionOf)){ + stack.push(new QueryTreeImpl<String>("?", NodeType.VARIABLE, id++)); + } + expr.getFiller().accept(this); + child = stack.pop(); + } else { + child = new QueryTreeImpl<String>(filler.asOWLClass().toStringID(), NodeType.RESOURCE, id++); + } + parent.addChild(child, expr.getProperty().asOWLObjectProperty().toStringID()); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectAllValuesFrom) + */ + @Override + public void visit(OWLObjectAllValuesFrom expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectHasValue) + */ + @Override + public void visit(OWLObjectHasValue expr) { + QueryTree<String> tree = stack.peek(); + tree.addChild(new QueryTreeImpl<String>(expr.getValue().asOWLNamedIndividual().toStringID(), NodeType.RESOURCE, id++), expr.getProperty().asOWLObjectProperty().toStringID()); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectMinCardinality) + */ + @Override + public void visit(OWLObjectMinCardinality expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectExactCardinality) + */ + @Override + public void visit(OWLObjectExactCardinality expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectMaxCardinality) + */ + @Override + public void visit(OWLObjectMaxCardinality expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectHasSelf) + */ + @Override + public void visit(OWLObjectHasSelf expr) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectOneOf) + */ + @Override + public void visit(OWLObjectOneOf expr) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataSomeValuesFrom) + */ + @Override + public void visit(OWLDataSomeValuesFrom expr) { + QueryTree<String> tree = stack.peek(); + expr.getFiller().accept(this); + QueryTree<String> child = stack.pop(); + tree.addChild(child, expr.getProperty().asOWLDataProperty().toStringID()); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataAllValuesFrom) + */ + @Override + public void visit(OWLDataAllValuesFrom expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataHasValue) + */ + @Override + public void visit(OWLDataHasValue expr) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataMinCardinality) + */ + @Override + public void visit(OWLDataMinCardinality expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataExactCardinality) + */ + @Override + public void visit(OWLDataExactCardinality expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLDataMaxCardinality) + */ + @Override + public void visit(OWLDataMaxCardinality expr) { + fireUnsupportedFeatureException(expr); + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitor#visit(org.semanticweb.owlapi.model.OWLDatatype) + */ + @Override + public void visit(OWLDatatype arg0) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitor#visit(org.semanticweb.owlapi.model.OWLDataOneOf) + */ + @Override + public void visit(OWLDataOneOf arg0) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitor#visit(org.semanticweb.owlapi.model.OWLDataComplementOf) + */ + @Override + public void visit(OWLDataComplementOf arg0) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitor#visit(org.semanticweb.owlapi.model.OWLDataIntersectionOf) + */ + @Override + public void visit(OWLDataIntersectionOf arg0) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitor#visit(org.semanticweb.owlapi.model.OWLDataUnionOf) + */ + @Override + public void visit(OWLDataUnionOf arg0) { + } + + /* (non-Javadoc) + * @see org.semanticweb.owlapi.model.OWLDataRangeVisitor#visit(org.semanticweb.owlapi.model.OWLDatatypeRestriction) + */ + @Override + public void visit(OWLDatatypeRestriction arg0) { + } + + public static void main(String[] args) throws Exception { + ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory df = man.getOWLDataFactory(); + PrefixManager pm = new DefaultPrefixManager("http://example.org/"); + OWLClassExpression ce = df.getOWLObjectIntersectionOf( + df.getOWLClass("A", pm), + df.getOWLObjectSomeValuesFrom( + df.getOWLObjectProperty("p", pm), + df.getOWLObjectSomeValuesFrom( + df.getOWLObjectProperty("r", pm), + df.getOWLObjectIntersectionOf( + df.getOWLClass("A", pm), + df.getOWLClass("B", pm)))) + ); + System.out.println(ce); + QueryTreeConverter converter = new QueryTreeConverter(); + QueryTree<String> tree = converter.asQueryTree(ce); + tree.dump(); + } + } Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMaxValue.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -58,11 +58,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " <= " + value; + return " double[<= " + value + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " <= " + value; + return " double[<= " + value + "]"; } public void accept(KBElementVisitor visitor) { @@ -74,7 +74,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " <= " + value; + return " double[<= " + value + "]"; } /* (non-Javadoc) Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinValue.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -58,11 +58,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " >= " + value; + return " double[>= " + value + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " >= " + value; + return " double[>= " + value + "]"; } public void accept(KBElementVisitor visitor) { @@ -74,7 +74,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " >= " + value; + return " double[>= " + value + "]"; } /* (non-Javadoc) Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLDataRangeConverter.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLDataRangeConverter.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLDataRangeConverter.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -97,13 +97,16 @@ max = OWLAPIConverter.convertConstant(value); } } - double minValue = Double.parseDouble(min.getLiteral()); - double maxValue = Double.parseDouble(max.getLiteral()); + if(min != null && max != null){ + double minValue = Double.parseDouble(min.getLiteral()); + double maxValue = Double.parseDouble(max.getLiteral()); dataRange = new DoubleMinMaxRange(minValue, maxValue); } else if(min != null && max == null){ + double minValue = Double.parseDouble(min.getLiteral()); dataRange = new DoubleMinValue(minValue); } else if(max != null && min == null){ + double maxValue = Double.parseDouble(max.getLiteral()); dataRange = new DoubleMaxValue(maxValue); } else { Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -67,7 +67,7 @@ tree.dump(); System.out.println("-----------------------------"); cnt++; - System.out.println(((QueryTreeImpl<String>)tree).toQuery()); +// System.out.println(((QueryTreeImpl<String>)tree).toQuery()); } @@ -76,6 +76,7 @@ System.out.println("LGG"); lgg.dump(); + System.out.println(((QueryTreeImpl<String>)lgg).asJSON()); QueryTreeImpl<String> tree = factory.getQueryTree("?"); QueryTreeImpl<String> subTree1 = new QueryTreeImpl<String>("?"); Added: trunk/dllearner-parent.iml =================================================================== --- trunk/dllearner-parent.iml (rev 0) +++ trunk/dllearner-parent.iml 2014-05-22 02:22:16 UTC (rev 4269) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <content url="file://$MODULE_DIR$"> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> + Modified: trunk/examples/mutagenesis/train1.conf =================================================================== --- trunk/examples/mutagenesis/train1.conf 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/examples/mutagenesis/train1.conf 2014-05-22 02:22:16 UTC (rev 4269) @@ -246,10 +246,11 @@ "kb:f6" } -alg.type = "ocel" +alg.type = "celoe" alg.noisePercentage = 30 alg.writeSearchTree = false alg.startClass = "kb:Compound" +alg.maxExecutionTimeInSeconds = 60 alg.searchTreeFile = "log/mutagenesis/searchTree.log" Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/pom.xml 2014-05-22 02:22:16 UTC (rev 4269) @@ -195,7 +195,7 @@ <dependency> <groupId>org.apache.jena</groupId> <artifactId>jena-core</artifactId> - <version>2.7.2</version> + <version>2.11.1</version> </dependency> <!--SwingX is in central --> <dependency> Modified: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -63,12 +63,12 @@ private static final Logger logger = Logger.getLogger(EProcurementUseCase.class.getName()); - static final int maxNrOfPositiveExamples = 100; - static final int maxNrOfNegativeExamples = 200; + static final int maxNrOfPositiveExamples = 10000; + static final int maxNrOfNegativeExamples = 10000; static boolean posOnly = false; - static int maxCBDDepth = 2; + static int maxCBDDepth = 3; static int maxNrOfResults = 100; - static int maxExecutionTimeInSeconds = 200; + static int maxExecutionTimeInSeconds = 500; static double noiseInPercentage = 50; static boolean useNegation = false; static boolean useAllConstructor = false; @@ -117,10 +117,10 @@ // schema.read(new URL("http://opendata.cz/pco/public-contracts.ttl").openStream(), null, "TURTLE"); model.add(schema); // get positive examples - SortedSet<Individual> positiveExamples = getExamples(model, posClass); + SortedSet<Individual> positiveExamples = getExamples(model, posClass, maxNrOfPositiveExamples); // get negative examples // SortedSet<Individual> negativeExamples = getNegativeExamples(model, cls, positiveExamples); - SortedSet<Individual> negativeExamples = getExamples(model, negClass); + SortedSet<Individual> negativeExamples = getExamples(model, negClass, maxNrOfNegativeExamples); //get the lgg of the pos. examples // showLGG(model, positiveExamples); // build a sample of the kb @@ -205,14 +205,14 @@ ((QueryTreeImpl<String>) lgg).asGraph(); } - private static SortedSet<Individual> getExamples(Model model, NamedClass cls){ + private static SortedSet<Individual> getExamples(Model model, NamedClass cls, int limit){ logger.info("Generating examples..."); - SortedSet<Individual> individuals = new SPARQLReasoner(new LocalModelBasedSparqlEndpointKS(model)).getIndividuals(cls, 1000); + SortedSet<Individual> individuals = new SPARQLReasoner(new LocalModelBasedSparqlEndpointKS(model)).getIndividuals(cls, limit); List<Individual> individualsList = new ArrayList<>(individuals); // Collections.shuffle(individualsList, new Random(1234)); individuals.clear(); individuals.addAll(individualsList.subList(0, Math.min(maxNrOfPositiveExamples, individualsList.size()))); - logger.info("Done. Got " + individuals.size() + ": " + individuals); + logger.info("Done. Got " + individuals.size()); return individuals; } Modified: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-12 09:53:57 UTC (rev 4268) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-22 02:22:16 UTC (rev 4269) @@ -8,37 +8,30 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Layout; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; import org.dllearner.algorithms.qtl.QTL2Disjunctive; import org.dllearner.algorithms.qtl.QueryTreeFactory; -import org.dllearner.algorithms.qtl.datastructures.QueryTree; -import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.QueryTreeHeuristic; import org.dllearner.algorithms.qtl.impl.QueryTreeFactoryImpl; import org.dllearner.cli.CLI; import org.dllearner.cli.CrossValidation; -import org.dllearner.core.AbstractLearningProblem; +import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.ComponentInitException; import org.dllearner.core.LearningProblemUnsupportedException; -import org.dllearner.core.owl.Individual; -import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.learningproblems.Heuristics.HeuristicType; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosNegLPStandard; -import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.scripts.NestedCrossValidation; import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.model.OWLOntology; import org.semanticweb.owlapi.model.OWLOntologyCreationException; import org.semanticweb.owlapi.model.OWLOntologyManager; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; @@ -48,11 +41,17 @@ */ public class QTLEvaluation { - int nrOfFolds = 3; + int nrOfFolds = 10; private int nrOfPosExamples = 300; private int nrOfNegExamples = 300; - CLI cli = new CLI(new File("../test/qtl/carcinogenesis/train.conf")); + CLI carcinogenesis = new CLI(new File("../test/qtl/carcinogenesis/train.conf")); + CLI mammographic = new CLI(new File("../test/qtl/mammographic/train.conf")); + CLI suramin = new CLI(new File("../test/qtl/suramin/train.conf")); + CLI heart = new CLI(new File("../test/qtl/heart/train.conf")); + CLI breasttissue = new CLI(new File("../test/qtl/breasttissue/train1.conf")); + CLI parkinsons = new CLI(new File("../test/qtl/parkinsons/train.conf")); + CLI mutagenesis = new CLI(new File("../test/qtl/mutagenesis/train1.conf")); private Model model; private OWLOntology ontology; @@ -65,7 +64,7 @@ queryTreeFactory = new QueryTreeFactoryImpl(); queryTreeFactory.setMaxDepth(3); - loadDataset(); +// loadDataset(); loadExamples(); } @@ -89,46 +88,100 @@ private void loadExamples() throws ComponentInitException, IOException{ - cli.init(); - lp = (PosNegLP) cli.getLearningProblem(); +// cli.init(); +// lp = (PosNegLP) cli.getLearningProblem(); // get examples and shuffle them - List<Individual> posExamples = new LinkedList<Individual>(((PosNegLP)lp).getPositiveExamples()); - Collections.shuffle(posExamples, new Random(1)); - List<Individual> negExamples = new LinkedList<Individual>(((PosNegLP)lp).getNegativeExamples()); - Collections.shuffle(negExamples, new Random(2)); - posExamples = posExamples.subList(0, Math.min(posExamples.size(), nrOfPosExamples)); - neg... [truncated message content] |
From: <lor...@us...> - 2014-05-12 09:54:01
|
Revision: 4268 http://sourceforge.net/p/dl-learner/code/4268 Author: lorenz_b Date: 2014-05-12 09:53:57 +0000 (Mon, 12 May 2014) Log Message: ----------- Added QTL example. Added Paths: ----------- trunk/test/qtl/mammographic/ trunk/test/qtl/mammographic/files/ trunk/test/qtl/mammographic/files/mammographic_masses.data trunk/test/qtl/mammographic/mammographic.owl trunk/test/qtl/mammographic/train.conf Added: trunk/test/qtl/mammographic/files/mammographic_masses.data =================================================================== --- trunk/test/qtl/mammographic/files/mammographic_masses.data (rev 0) +++ trunk/test/qtl/mammographic/files/mammographic_masses.data 2014-05-12 09:53:57 UTC (rev 4268) @@ -0,0 +1,961 @@ +5,67,3,5,3,1 +4,43,1,1,0,1 +5,58,4,5,3,1 +4,28,1,1,3,0 +5,74,1,5,0,1 +4,65,1,0,3,0 +4,70,0,0,3,0 +5,42,1,0,3,0 +5,57,1,5,3,1 +5,60,0,5,1,1 +5,76,1,4,3,1 +3,42,2,1,3,1 +4,64,1,0,3,0 +4,36,3,1,2,0 +4,60,2,1,2,0 +4,54,1,1,3,0 +3,52,3,4,3,0 +4,59,2,1,3,1 +4,54,1,1,3,1 +4,40,1,0,0,0 +0,66,0,0,1,1 +5,56,4,3,1,1 +4,43,1,0,0,0 +5,42,4,4,3,1 +4,59,2,4,3,1 +5,75,4,5,3,1 +2,66,1,1,0,0 +5,63,3,0,3,0 +5,45,4,5,3,1 +5,55,4,4,3,0 +4,46,1,5,2,0 +5,54,4,4,3,1 +5,57,4,4,3,1 +4,39,1,1,2,0 +4,81,1,1,3,0 +4,77,3,0,0,0 +4,60,2,1,3,0 +5,67,3,4,2,1 +4,48,4,5,0,1 +4,55,3,4,2,0 +4,59,2,1,0,0 +4,78,1,1,1,0 +4,50,1,1,3,0 +4,61,2,1,0,0 +5,62,3,5,2,1 +5,44,2,4,0,1 +5,64,4,5,3,1 +4,23,1,1,0,0 +2,42,0,0,4,0 +5,67,4,5,3,1 +4,74,2,1,2,0 +5,80,3,5,3,1 +4,23,1,1,0,0 +4,63,2,1,0,0 +4,53,0,5,3,1 +4,43,3,4,0,0 +4,49,2,1,1,0 +5,51,2,4,0,0 +4,45,2,1,0,0 +5,59,2,0,0,1 +5,52,4,3,3,1 +5,60,4,3,3,1 +4,57,2,5,3,0 +3,57,2,1,0,0 +5,74,4,4,3,1 +4,25,2,1,0,0 +4,49,1,1,3,0 +5,72,4,3,0,1 +4,45,2,1,3,0 +4,64,2,1,3,0 +4,73,2,1,2,0 +5,68,4,3,3,1 +5,52,4,5,3,0 +5,66,4,4,3,1 +5,70,0,4,0,1 +4,25,1,1,3,0 +5,74,1,1,2,1 +4,64,1,1,3,0 +5,60,4,3,2,1 +5,67,2,4,1,0 +4,67,4,5,3,0 +5,44,4,4,2,1 +3,68,1,1,3,1 +4,57,0,4,1,0 +5,51,4,0,0,1 +4,33,1,0,0,0 +5,58,4,4,3,1 +5,36,1,0,0,0 +4,63,1,1,0,0 +5,62,1,5,3,1 +4,73,3,4,3,1 +4,80,4,4,3,1 +4,67,1,1,0,0 +5,59,2,1,3,1 +5,60,1,0,3,0 +5,54,4,4,3,1 +4,40,1,1,0,0 +4,47,2,1,0,0 +5,62,4,4,3,0 +4,33,2,1,3,0 +5,59,2,0,0,0 +4,65,2,0,0,0 +4,58,4,4,0,0 +4,29,2,0,0,0 +4,58,1,1,0,0 +4,54,1,1,0,0 +4,44,1,1,0,1 +3,34,2,1,0,0 +4,57,1,1,3,0 +5,33,4,4,0,1 +4,45,4,4,3,0 +5,71,4,4,3,1 +5,59,4,4,2,0 +4,56,2,1,0,0 +4,40,3,4,0,0 +4,56,1,1,3,0 +4,45,2,1,0,0 +4,57,2,1,2,0 +5,55,3,4,3,1 +5,84,4,5,3,0 +5,51,4,4,3,1 +4,43,1,1,0,0 +4,24,2,1,2,0 +4,66,1,1,3,0 +5,33,4,4,3,0 +4,59,4,3,2,0 +4,76,2,3,0,0 +4,40,1,1,0,0 +4,52,0,4,0,0 +5,40,4,5,3,1 +5,67,4,4,3,1 +5,75,4,3,3,1 +5,86,4,4,3,0 +4,60,2,0,0,0 +5,66,4,4,3,1 +5,46,4,5,3,1 +4,59,4,4,3,1 +5,65,4,4,3,1 +4,53,1,1,3,0 +5,67,3,5,3,1 +5,80,4,5,3,1 +4,55,2,1,3,0 +4,48,1,1,0,0 +4,47,1,1,2,0 +4,50,2,1,0,0 +5,62,4,5,3,1 +5,63,4,4,3,1 +4,63,4,0,3,1 +4,71,4,4,3,1 +4,41,1,1,3,0 +5,57,4,4,4,1 +5,71,4,4,4,1 +4,66,1,1,3,0 +4,47,2,4,2,0 +3,34,4,4,3,0 +4,59,3,4,3,0 +5,55,2,0,0,1 +4,51,0,0,3,0 +4,62,2,1,0,0 +4,58,4,0,3,1 +5,67,4,4,3,1 +4,41,2,1,3,0 +4,23,3,1,3,0 +4,53,0,4,3,0 +4,42,2,1,3,0 +5,87,4,5,3,1 +4,68,1,1,3,1 +4,64,1,1,3,0 +5,54,3,5,3,1 +5,86,4,5,3,1 +4,21,2,1,3,0 +4,39,1,1,0,0 +4,53,4,4,3,0 +4,44,4,4,3,0 +4,54,1,1,3,0 +5,63,4,5,3,1 +4,62,2,1,0,0 +4,45,2,1,2,0 +5,71,4,5,3,0 +5,49,4,4,3,1 +4,49,4,4,3,0 +5,66,4,4,4,0 +4,19,1,1,3,0 +4,35,1,1,2,0 +4,71,3,3,0,1 +5,74,4,5,3,1 +5,37,4,4,3,1 +4,67,1,0,3,0 +5,81,3,4,3,1 +5,59,4,4,3,1 +4,34,1,1,3,0 +5,79,4,3,3,1 +5,60,3,1,3,0 +4,41,1,1,3,1 +4,50,1,1,3,0 +5,85,4,4,3,1 +4,46,1,1,3,0 +5,66,4,4,3,1 +4,73,3,1,2,0 +4,55,1,1,3,0 +4,49,2,1,3,0 +3,49,4,4,3,0 +4,51,4,5,3,1 +2,48,4,4,3,0 +4,58,4,5,3,0 +5,72,4,5,3,1 +4,46,2,3,3,0 +4,43,4,3,3,1 +0,52,4,4,3,0 +4,66,2,1,0,0 +4,46,1,1,1,0 +4,69,3,1,3,0 +2,59,1,1,0,1 +5,43,2,1,3,1 +5,76,4,5,3,1 +4,46,1,1,3,0 +4,59,2,4,3,0 +4,57,1,1,3,0 +5,43,4,5,0,0 +3,45,2,1,3,0 +3,43,2,1,3,0 +4,45,2,1,3,0 +5,57,4,5,3,1 +5,79,4,4,3,1 +5,54,2,1,3,1 +4,40,3,4,3,0 +5,63,4,4,3,1 +2,55,1,0,1,0 +4,52,2,1,3,0 +4,38,1,1,3,0 +3,72,4,3,3,0 +5,80,4,3,3,1 +5,76,4,3,3,1 +4,62,3,1,3,0 +5,64,4,5,3,1 +5,42,4,5,3,0 +3,60,0,3,1,0 +4,64,4,5,3,0 +4,63,4,4,3,1 +4,24,2,1,2,0 +5,72,4,4,3,1 +4,63,2,1,3,0 +4,46,1,1,3,0 +3,33,1,1,3,0 +5,76,4,4,3,1 +4,36,2,3,3,0 +4,40,2,1,3,0 +5,58,1,5,3,1 +4,43,2,1,3,0 +3,42,1,1,3,0 +4,32,1,1,3,0 +5,57,4,4,2,1 +4,37,1,1,3,0 +4,70,4,4,3,1 +5,56,4,2,3,1 +3,76,0,3,2,0 +5,73,4,4,3,1 +5,77,4,5,3,1 +5,67,4,4,1,1 +5,71,4,3,3,1 +5,65,4,4,3,1 +4,43,1,1,3,0 +4,40,2,1,0,0 +4,49,2,1,3,0 +5,76,4,2,3,1 +4,55,4,4,3,0 +5,72,4,5,3,1 +3,53,4,3,3,0 +5,75,4,4,3,1 +5,61,4,5,3,1 +5,67,4,4,3,1 +5,55,4,2,3,1 +5,66,4,4,3,1 +2,76,1,1,2,0 +4,57,4,4,3,1 +5,71,3,1,3,0 +5,70,4,5,3,1 +4,35,4,2,0,0 +5,79,1,0,3,1 +4,63,2,1,3,0 +5,40,1,4,3,1 +4,41,1,1,3,0 +4,47,2,1,2,0 +4,68,1,1,3,1 +4,64,4,3,3,1 +4,65,4,4,0,1 +4,73,4,3,3,0 +4,39,4,3,3,0 +5,55,4,5,4,1 +5,53,3,4,4,0 +5,66,4,4,3,1 +4,43,3,1,2,0 +5,44,4,5,3,1 +4,77,4,4,3,1 +4,62,2,4,3,0 +5,80,4,4,3,1 +4,33,4,4,3,0 +4,50,4,5,3,1 +4,71,1,0,3,0 +5,46,4,4,3,1 +5,49,4,5,3,1 +4,53,1,1,3,0 +3,46,2,1,2,0 +4,57,1,1,3,0 +4,54,3,1,3,0 +4,54,1,0,0,0 +2,49,2,1,2,0 +4,47,3,1,3,0 +4,40,1,1,3,0 +4,45,1,1,3,0 +4,50,4,5,3,1 +5,54,4,4,3,1 +4,67,4,1,3,1 +4,77,4,4,3,1 +4,66,4,3,3,0 +4,71,2,0,3,1 +4,36,2,3,3,0 +4,69,4,4,3,0 +4,48,1,1,3,0 +4,64,4,4,3,1 +4,71,4,2,3,1 +5,60,4,3,3,1 +4,24,1,1,3,0 +5,34,4,5,2,1 +4,79,1,1,2,0 +4,45,1,1,3,0 +4,37,2,1,2,0 +4,42,1,1,2,0 +4,72,4,4,3,1 +5,60,4,5,3,1 +5,85,3,5,3,1 +4,51,1,1,3,0 +5,54,4,5,3,1 +5,55,4,3,3,1 +4,64,4,4,3,0 +5,67,4,5,3,1 +5,75,4,3,3,1 +5,87,4,4,3,1 +4,46,4,4,3,1 +4,59,2,1,0,0 +55,46,4,3,3,1 +5,61,1,1,3,1 +4,44,1,4,3,0 +4,32,1,1,3,0 +4,62,1,1,3,0 +5,59,4,5,3,1 +4,61,4,1,3,0 +5,78,4,4,3,1 +5,42,4,5,3,0 +4,45,1,2,3,0 +5,34,2,1,3,1 +5,39,4,3,0,1 +4,27,3,1,3,0 +4,43,1,1,3,0 +5,83,4,4,3,1 +4,36,2,1,3,0 +4,37,2,1,3,0 +4,56,3,1,3,1 +5,55,4,4,3,1 +5,46,3,0,3,0 +4,88,4,4,3,1 +5,71,4,4,3,1 +4,41,2,1,3,0 +5,49,4,4,3,1 +3,51,1,1,4,0 +4,39,1,3,3,0 +4,46,2,1,3,0 +5,52,4,4,3,1 +5,58,4,4,3,1 +4,67,4,5,3,1 +5,80,4,4,3,1 +3,46,1,0,0,0 +3,43,1,0,0,0 +4,45,1,1,3,0 +5,68,4,4,3,1 +4,54,4,4,0,1 +4,44,2,3,3,0 +5,74,4,3,3,1 +5,55,4,5,3,0 +4,49,4,4,3,1 +4,49,1,1,3,0 +5,50,4,3,3,1 +5,52,3,5,3,1 +4,45,1,1,3,0 +4,66,1,1,3,0 +4,68,4,4,3,1 +4,72,2,1,3,0 +5,64,0,0,3,0 +2,49,0,3,3,0 +3,44,0,4,3,0 +5,74,4,4,3,1 +5,58,4,4,3,1 +4,77,2,3,3,0 +4,49,3,1,3,0 +4,34,0,0,4,0 +5,60,4,3,3,1 +5,69,4,3,3,1 +4,53,2,1,3,0 +3,46,3,4,3,0 +5,74,4,4,3,1 +4,58,1,1,3,0 +5,68,4,4,3,1 +5,46,4,3,3,0 +5,61,2,4,3,1 +5,70,4,3,3,1 +5,37,4,4,3,1 +3,65,4,5,3,1 +4,67,4,4,3,0 +5,69,3,4,3,0 +5,76,4,4,3,1 +4,65,4,3,3,0 +5,72,4,2,3,1 +4,62,4,2,3,0 +5,42,4,4,3,1 +5,66,4,3,3,1 +5,48,4,4,3,1 +4,35,1,1,3,0 +5,60,4,4,3,1 +5,67,4,2,3,1 +5,78,4,4,3,1 +4,66,1,1,3,1 +4,26,1,1,0,0 +4,48,1,1,3,0 +4,31,1,1,3,0 +5,43,4,3,3,1 +5,72,2,4,3,0 +5,66,1,1,3,1 +4,56,4,4,3,0 +5,58,4,5,3,1 +5,33,2,4,3,1 +4,37,1,1,3,0 +5,36,4,3,3,1 +4,39,2,3,3,0 +4,39,4,4,3,1 +5,83,4,4,3,1 +4,68,4,5,3,1 +5,63,3,4,3,1 +5,78,4,4,3,1 +4,38,2,3,3,0 +5,46,4,3,3,1 +5,60,4,4,3,1 +5,56,2,3,3,1 +4,33,1,1,3,0 +4,0,4,5,3,1 +4,69,1,5,3,1 +5,66,1,4,3,1 +4,72,1,3,3,0 +4,29,1,1,3,0 +5,54,4,5,3,1 +5,80,4,4,3,1 +5,68,4,3,3,1 +4,35,2,1,3,0 +4,57,3,0,3,0 +5,0,4,4,3,1 +4,50,1,1,3,0 +4,32,4,3,3,0 +0,69,4,5,3,1 +4,71,4,5,3,1 +5,87,4,5,3,1 +3,40,2,0,3,0 +4,31,1,1,0,0 +4,64,1,1,3,0 +5,55,4,5,3,1 +4,18,1,1,3,0 +3,50,2,1,0,0 +4,53,1,1,3,0 +5,84,4,5,3,1 +5,80,4,3,3,1 +4,32,1,1,3,0 +5,77,3,4,3,1 +4,38,1,1,3,0 +5,54,4,5,3,1 +4,63,1,1,3,0 +4,61,1,1,3,0 +4,52,1,1,3,0 +4,36,1,1,3,0 +4,41,0,0,3,0 +4,59,1,1,3,0 +5,51,4,4,2,1 +4,36,1,1,3,0 +5,40,4,3,3,1 +4,49,1,1,3,0 +4,37,2,3,3,0 +4,46,1,1,3,0 +4,63,1,1,3,0 +4,28,2,1,3,0 +4,47,2,1,3,0 +4,42,2,1,3,1 +5,44,4,5,3,1 +4,49,4,4,3,0 +5,47,4,5,3,1 +5,52,4,5,3,1 +4,53,1,1,3,1 +5,83,3,3,3,1 +4,50,4,4,0,1 +5,63,4,4,3,1 +4,82,0,5,3,1 +4,54,1,1,3,0 +4,50,4,4,3,0 +5,80,4,5,3,1 +5,45,2,4,3,0 +5,59,4,4,0,1 +4,28,2,1,3,0 +4,31,1,1,3,0 +4,41,2,1,3,0 +4,21,3,1,3,0 +5,44,3,4,3,1 +5,49,4,4,3,1 +5,71,4,5,3,1 +5,75,4,5,3,1 +4,38,2,1,3,0 +4,60,1,3,3,0 +5,87,4,5,3,1 +4,70,4,4,3,1 +5,55,4,5,3,1 +3,21,1,1,3,0 +4,50,1,1,3,0 +5,76,4,5,3,1 +4,23,1,1,3,0 +3,68,0,0,3,0 +4,62,4,0,3,1 +5,65,1,0,3,1 +5,73,4,5,3,1 +4,38,2,3,3,0 +2,57,1,1,3,0 +5,65,4,5,3,1 +5,67,2,4,3,1 +5,61,2,4,3,1 +5,56,4,4,3,0 +5,71,2,4,3,1 +4,49,2,2,3,0 +4,55,0,0,3,0 +4,44,2,1,3,0 +0,58,4,4,3,0 +4,27,2,1,3,0 +5,73,4,5,3,1 +4,34,2,1,3,0 +5,63,0,4,3,1 +4,50,2,1,3,1 +4,62,2,1,3,0 +3,21,3,1,3,0 +4,49,2,0,3,0 +4,36,3,1,3,0 +4,45,2,1,3,1 +5,67,4,5,3,1 +4,21,1,1,3,0 +4,57,2,1,3,0 +5,66,4,5,3,1 +4,71,4,4,3,1 +5,69,3,4,3,1 +6,80,4,5,3,1 +3,27,2,1,3,0 +4,38,2,1,3,0 +4,23,2,1,3,0 +5,70,0,5,3,1 +4,46,4,3,3,0 +4,61,2,3,3,0 +5,65,4,5,3,1 +4,60,4,3,3,0 +5,83,4,5,3,1 +5,40,4,4,3,1 +2,59,0,4,3,0 +4,53,3,4,3,0 +4,76,4,4,3,0 +5,79,1,4,3,1 +5,38,2,4,3,1 +4,61,3,4,3,0 +4,56,2,1,3,0 +4,44,2,1,3,0 +4,64,3,4,0,1 +4,66,3,3,3,0 +4,50,3,3,3,0 +4,46,1,1,3,0 +4,39,1,1,3,0 +4,60,3,0,0,0 +5,55,4,5,3,1 +4,40,2,1,3,0 +4,26,1,1,3,0 +5,84,3,2,3,1 +4,41,2,2,3,0 +4,63,1,1,3,0 +2,65,0,1,2,0 +4,49,1,1,3,0 +4,56,2,2,3,1 +5,65,4,4,3,0 +4,54,1,1,3,0 +4,36,1,1,3,0 +5,49,4,4,3,0 +4,59,4,4,3,1 +5,75,4,4,3,1 +5,59,4,2,3,0 +5,59,4,4,3,1 +4,28,4,4,3,1 +5,53,4,5,3,0 +5,57,4,4,3,0 +5,77,4,3,4,0 +5,85,4,3,3,1 +4,59,4,4,3,0 +5,59,1,5,3,1 +4,65,3,3,3,1 +4,54,2,1,3,0 +5,46,4,5,3,1 +4,63,4,4,3,1 +4,53,1,1,3,1 +4,56,1,1,3,0 +5,66,4,4,3,1 +5,66,4,5,3,1 +4,55,1,1,3,0 +4,44,1,1,3,0 +5,86,3,4,3,1 +5,47,4,5,3,1 +5,59,4,5,3,1 +5,66,4,5,3,0 +5,61,4,3,3,1 +3,46,0,5,0,1 +4,69,1,1,3,0 +5,93,1,5,3,1 +4,39,1,3,3,0 +5,44,4,5,3,1 +4,45,2,2,3,0 +4,51,3,4,3,0 +4,56,2,4,3,0 +4,66,4,4,3,0 +5,61,4,5,3,1 +4,64,3,3,3,1 +5,57,2,4,3,0 +5,79,4,4,3,1 +4,57,2,1,0,0 +4,44,4,1,1,0 +4,31,2,1,3,0 +4,63,4,4,3,0 +4,64,1,1,3,0 +5,47,4,5,3,0 +5,68,4,5,3,1 +4,30,1,1,3,0 +5,43,4,5,3,1 +4,56,1,1,3,0 +4,46,2,1,3,0 +4,67,2,1,3,0 +5,52,4,5,3,1 +4,67,4,4,3,1 +4,47,2,1,3,0 +5,58,4,5,3,1 +4,28,2,1,3,0 +4,43,1,1,3,0 +4,57,2,4,3,0 +5,68,4,5,3,1 +4,64,2,4,3,0 +4,64,2,4,3,0 +5,62,4,4,3,1 +4,38,4,1,3,0 +5,68,4,4,3,1 +4,41,2,1,3,0 +4,35,2,1,3,1 +4,68,2,1,3,0 +5,55,4,4,3,1 +5,67,4,4,3,1 +4,51,4,3,3,0 +2,40,1,1,3,0 +5,73,4,4,3,1 +4,58,0,4,3,1 +4,51,0,4,3,0 +3,50,0,0,3,1 +5,59,4,3,3,1 +6,60,3,5,3,1 +4,27,2,1,0,0 +5,54,4,3,3,0 +4,56,1,1,3,0 +5,53,4,5,3,1 +4,54,2,4,3,0 +5,79,1,4,3,1 +5,67,4,3,3,1 +5,64,3,3,3,1 +4,70,1,2,3,1 +5,55,4,3,3,1 +5,65,3,3,3,1 +5,45,4,2,3,1 +4,57,4,4,0,1 +5,49,1,1,3,1 +4,24,2,1,3,0 +4,52,1,1,3,0 +4,50,2,1,3,0 +4,35,1,1,3,0 +5,0,3,3,3,1 +5,64,4,3,3,1 +5,40,4,1,1,1 +5,66,4,4,3,1 +4,64,4,4,3,1 +5,52,4,3,3,1 +5,43,1,4,3,1 +4,56,4,4,3,0 +4,72,3,0,3,0 +6,51,4,4,3,1 +4,79,4,4,3,1 +4,22,2,1,3,0 +4,73,2,1,3,0 +4,53,3,4,3,0 +4,59,2,1,3,1 +4,46,4,4,2,0 +5,66,4,4,3,1 +4,50,4,3,3,1 +4,58,1,1,3,1 +4,55,1,1,3,0 +4,62,2,4,3,1 +4,60,1,1,3,0 +5,57,4,3,3,1 +4,57,1,1,3,0 +6,41,2,1,3,0 +4,71,2,1,3,1 +4,32,2,1,3,0 +4,57,2,1,3,0 +4,19,1,1,3,0 +4,62,2,4,3,1 +5,67,4,5,3,1 +4,50,4,5,3,0 +4,65,2,3,2,0 +4,40,2,4,2,0 +6,71,4,4,3,1 +6,68,4,3,3,1 +4,68,1,1,3,0 +4,29,1,1,3,0 +4,53,2,1,3,0 +5,66,4,4,3,1 +4,60,3,0,4,0 +5,76,4,4,3,1 +4,58,2,1,2,0 +5,96,3,4,3,1 +5,70,4,4,3,1 +4,34,2,1,3,0 +4,59,2,1,3,0 +4,45,3,1,3,1 +5,65,4,4,3,1 +4,59,1,1,3,0 +4,21,2,1,3,0 +3,43,2,1,3,0 +4,53,1,1,3,0 +4,65,2,1,3,0 +4,64,2,4,3,1 +4,53,4,4,3,0 +4,51,1,1,3,0 +4,59,2,4,3,0 +4,56,2,1,3,0 +4,60,2,1,3,0 +4,22,1,1,3,0 +4,25,2,1,3,0 +6,76,3,0,3,0 +5,69,4,4,3,1 +4,58,2,1,3,0 +5,62,4,3,3,1 +4,56,4,4,3,0 +4,64,1,1,3,0 +4,32,2,1,3,0 +5,48,0,4,0,1 +5,59,4,4,2,1 +4,52,1,1,3,0 +4,63,4,4,3,0 +5,67,4,4,3,1 +5,61,4,4,3,1 +5,59,4,5,3,1 +5,52,4,3,3,1 +4,35,4,4,3,0 +5,77,3,3,3,1 +5,71,4,3,3,1 +5,63,4,3,3,1 +4,38,2,1,2,0 +5,72,4,3,3,1 +4,76,4,3,3,1 +4,53,3,3,3,0 +4,67,4,5,3,0 +5,69,2,4,3,1 +4,54,1,1,3,0 +2,35,2,1,2,0 +5,68,4,3,3,1 +4,68,4,4,3,0 +4,67,2,4,3,1 +3,39,1,1,3,0 +4,44,2,1,3,0 +4,33,1,1,3,0 +4,60,0,4,3,0 +4,58,1,1,3,0 +4,31,1,1,3,0 +3,23,1,1,3,0 +5,56,4,5,3,1 +4,69,2,1,3,1 +6,63,1,1,3,0 +4,65,1,1,3,1 +4,44,2,1,2,0 +4,62,3,3,3,1 +4,67,4,4,3,1 +4,56,2,1,3,0 +4,52,3,4,3,0 +4,43,1,1,3,1 +4,41,4,3,2,1 +4,42,3,4,2,0 +3,46,1,1,3,0 +5,55,4,4,3,1 +5,58,4,4,2,1 +5,87,4,4,3,1 +4,66,2,1,3,0 +0,72,4,3,3,1 +5,60,4,3,3,1 +5,83,4,4,2,1 +4,31,2,1,3,0 +4,53,2,1,3,0 +4,64,2,3,3,0 +5,31,4,4,2,1 +5,62,4,4,2,1 +4,56,2,1,3,0 +5,58,4,4,3,1 +4,67,1,4,3,0 +5,75,4,5,3,1 +5,65,3,4,3,1 +5,74,3,2,3,1 +4,59,2,1,3,0 +4,57,4,4,4,1 +4,76,3,2,3,0 +4,63,1,4,3,0 +4,44,1,1,3,0 +4,42,3,1,2,0 +4,35,3,0,2,0 +5,65,4,3,3,1 +4,70,2,1,3,0 +4,48,1,1,3,0 +4,74,1,1,1,1 +6,40,0,3,4,1 +4,63,1,1,3,0 +5,60,4,4,3,1 +5,86,4,3,3,1 +4,27,1,1,3,0 +4,71,4,5,2,1 +5,85,4,4,3,1 +4,51,3,3,3,0 +6,72,4,3,3,1 +5,52,4,4,3,1 +4,66,2,1,3,0 +5,71,4,5,3,1 +4,42,2,1,3,0 +4,64,4,4,2,1 +4,41,2,2,3,0 +4,50,2,1,3,0 +4,30,1,1,3,0 +4,67,1,1,3,0 +5,62,4,4,3,1 +4,46,2,1,2,0 +4,35,1,1,3,0 +4,53,1,1,2,0 +4,59,2,1,3,0 +4,19,3,1,3,0 +5,86,2,1,3,1 +4,72,2,1,3,0 +4,37,2,1,2,0 +4,46,3,1,3,1 +4,45,1,1,3,0 +4,48,4,5,3,0 +4,58,4,4,3,1 +4,42,1,1,3,0 +4,56,2,4,3,1 +4,47,2,1,3,0 +4,49,4,4,3,1 +5,76,2,5,3,1 +5,62,4,5,3,1 +5,64,4,4,3,1 +5,53,4,3,3,1 +4,70,4,2,2,1 +5,55,4,4,3,1 +4,34,4,4,3,0 +5,76,4,4,3,1 +4,39,1,1,3,0 +2,23,1,1,3,0 +4,19,1,1,3,0 +5,65,4,5,3,1 +4,57,2,1,3,0 +5,41,4,4,3,1 +4,36,4,5,3,1 +4,62,3,3,3,0 +4,69,2,1,3,0 +4,41,3,1,3,0 +3,51,2,4,3,0 +5,50,3,2,3,1 +4,47,4,4,3,0 +4,54,4,5,3,1 +5,52,4,4,3,1 +4,30,1,1,3,0 +3,48,4,4,3,1 +5,0,4,4,3,1 +4,65,2,4,3,1 +4,50,1,1,3,0 +5,65,4,5,3,1 +5,66,4,3,3,1 +6,41,3,3,2,1 +5,72,3,2,3,1 +4,42,1,1,1,1 +4,80,4,4,3,1 +0,45,2,4,3,0 +4,41,1,1,3,0 +4,72,3,3,3,1 +4,60,4,5,3,0 +5,67,4,3,3,1 +4,55,2,1,3,0 +4,61,3,4,3,1 +4,55,3,4,3,1 +4,52,4,4,3,1 +4,42,1,1,3,0 +5,63,4,4,3,1 +4,62,4,5,3,1 +4,46,1,1,3,0 +4,65,2,1,3,0 +4,57,3,3,3,1 +4,66,4,5,3,1 +4,45,1,1,3,0 +4,77,4,5,3,1 +4,35,1,1,3,0 +4,50,4,5,3,1 +4,57,4,4,3,0 +4,74,3,1,3,1 +4,59,4,5,3,0 +4,51,1,1,3,0 +4,42,3,4,3,1 +4,35,2,4,3,0 +4,42,1,1,3,0 +4,43,2,1,3,0 +4,62,4,4,3,1 +4,27,2,1,3,0 +5,0,4,3,3,1 +4,57,4,4,3,1 +4,59,2,1,3,0 +5,40,3,2,3,1 +4,20,1,1,3,0 +5,74,4,3,3,1 +4,22,1,1,3,0 +4,57,4,3,3,0 +4,57,4,3,3,1 +4,55,2,1,2,0 +4,62,2,1,3,0 +4,54,1,1,3,0 +4,71,1,1,3,1 +4,65,3,3,3,0 +4,68,4,4,3,0 +4,64,1,1,3,0 +4,54,2,4,3,0 +4,48,4,4,3,1 +4,58,4,3,3,0 +5,58,3,4,3,1 +4,70,1,1,1,0 +5,70,1,4,3,1 +4,59,2,1,3,0 +4,57,2,4,3,0 +4,53,4,5,3,0 +4,54,4,4,3,1 +4,53,2,1,3,0 +0,71,4,4,3,1 +5,67,4,5,3,1 +4,68,4,4,3,1 +4,56,2,4,3,0 +4,35,2,1,3,0 +4,52,4,4,3,1 +4,47,2,1,3,0 +4,56,4,5,3,1 +4,64,4,5,3,0 +5,66,4,5,3,1 +4,62,3,3,3,0 \ No newline at end of file Added: trunk/test/qtl/mammographic/mammographic.owl =================================================================== --- trunk/test/qtl/mammographic/mammographic.owl (rev 0) +++ trunk/test/qtl/mammographic/mammographic.owl 2014-05-12 09:53:57 UTC (rev 4268) @@ -0,0 +1,12873 @@ +<?xml version="1.0"?> +<rdf:RDF xmlns="http://dl-learner.org/mammographic#" + xml:base="http://dl-learner.org/mammographic" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:mammographic="http://dl-learner.org/mammographic#"> + <owl:Ontology rdf:about="http://dl-learner.org/mammographic"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Object Properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/mammographic#hasDensity --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/mammographic#hasDensity"> + <rdfs:range rdf:resource="http://dl-learner.org/mammographic#Density"/> + <rdfs:domain rdf:resource="http://dl-learner.org/mammographic#Patient"/> + </owl:ObjectProperty> + + + + <!-- http://dl-learner.org/mammographic#hasMargin --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/mammographic#hasMargin"> + <rdfs:range rdf:resource="http://dl-learner.org/mammographic#Margin"/> + <rdfs:domain rdf:resource="http://dl-learner.org/mammographic#Patient"/> + </owl:ObjectProperty> + + + + <!-- http://dl-learner.org/mammographic#hasShape --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/mammographic#hasShape"> + <rdfs:domain rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <rdfs:range rdf:resource="http://dl-learner.org/mammographic#Shape"/> + </owl:ObjectProperty> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Data properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/mammographic#hasAge --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/mammographic#hasAge"> + <rdfs:domain rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- http://dl-learner.org/mammographic#hasBiRads --> + + <owl:DatatypeProperty rdf:about="http://dl-learner.org/mammographic#hasBiRads"> + <rdfs:domain rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/> + </owl:DatatypeProperty> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Classes + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/mammographic#Density --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#Density"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Measure"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#Margin --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#Margin"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Measure"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#Measure --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#Measure"/> + + + + <!-- http://dl-learner.org/mammographic#Patient --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#Patient"/> + + + + <!-- http://dl-learner.org/mammographic#Shape --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#Shape"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Measure"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#circumscribed --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#circumscribed"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Margin"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#fat-containing --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#fat-containing"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Density"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#high --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#high"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Density"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#ill-defined --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#ill-defined"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Margin"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#irregular --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#irregular"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Shape"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#iso --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#iso"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Density"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#lobular --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#lobular"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Shape"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#low --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#low"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Density"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#microlobulated --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#microlobulated"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Margin"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#obscured --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#obscured"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Margin"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#oval --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#oval"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Shape"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#round --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#round"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Shape"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#spiculated --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#spiculated"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Margin"/> + </owl:Class> + + + + <!-- http://dl-learner.org/mammographic#unknown --> + + <owl:Class rdf:about="http://dl-learner.org/mammographic#unknown"> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Density"/> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Margin"/> + <rdfs:subClassOf rdf:resource="http://dl-learner.org/mammographic#Shape"/> + </owl:Class> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Individuals + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/mammographic#Patient0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient0"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">67.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#lobular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#spiculated"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient1"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">43.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient10 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient10"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">76.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient100 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient100"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">59.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#unknown"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient101 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient101"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">65.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#unknown"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient102 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient102"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">58.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient103 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient103"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">29.0</hasAge> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient104 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient104"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">58.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient105 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient105"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">54.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient106 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient106"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">44.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient107 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient107"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">34.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient108 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient108"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">57.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient109 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient109"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">33.0</hasAge> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient11 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient11"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">42.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient110 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient110"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">45.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient111 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient111"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">71.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient112 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient112"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">59.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#iso"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient113 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient113"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">56.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient114 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient114"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">40.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#lobular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient115 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient115"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">56.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient116 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient116"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">45.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient117 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient117"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">57.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#iso"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient118 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient118"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">55.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#lobular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient119 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient119"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">84.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#spiculated"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient12 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient12"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">64.0</hasAge> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient120 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient120"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">51.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient121 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient121"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">43.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient122 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient122"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">24.0</hasAge> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#iso"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient123 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient123"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">66.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient124 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient124"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">33.0</hasAge> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient125 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient125"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">59.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#iso"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#obscured"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient126 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient126"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">76.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#obscured"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient127 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient127"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">40.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient128 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient128"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">52.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#unknown"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient129 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient129"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">40.0</hasAge> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#spiculated"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient13 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient13"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">36.0</hasAge> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#iso"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#lobular"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient130 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient130"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">67.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient131 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient131"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">75.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#obscured"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient132 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient132"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">86.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient133 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient133"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">60.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#unknown"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient134 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient134"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">66.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient135 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient135"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">46.0</hasAge> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#spiculated"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient136 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient136"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">59.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient137 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient137"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">65.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient138 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient138"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">53.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient139 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient139"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">67.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#lobular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#spiculated"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient14 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient14"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">60.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#iso"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient140 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient140"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">80.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#spiculated"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient141 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient141"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">55.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient142 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient142"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">48.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient143 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient143"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">47.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#iso"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#round"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient144 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient144"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">50.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#circumscribed"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#oval"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient145 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient145"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">62.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#spiculated"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient146 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient146"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">63.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient147 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient147"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">63.0</hasAge> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#unknown"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient148 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/mammographic#Patient148"> + <rdf:type rdf:resource="http://dl-learner.org/mammographic#Patient"/> + <hasBiRads rdf:datatype="http://www.w3.org/2001/XMLSchema#double">4.0</hasBiRads> + <hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#double">71.0</hasAge> + <hasMargin rdf:resource="http://dl-learner.org/mammographic#ill-defined"/> + <hasShape rdf:resource="http://dl-learner.org/mammographic#irregular"/> + <hasDensity rdf:resource="http://dl-learner.org/mammographic#low"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/mammographic#Patient149 --> + + <owl:NamedIndividual rdf:about="http://dl-learne... [truncated message content] |
From: <lor...@us...> - 2014-05-09 18:13:07
|
Revision: 4267 http://sourceforge.net/p/dl-learner/code/4267 Author: lorenz_b Date: 2014-05-09 18:13:04 +0000 (Fri, 09 May 2014) Log Message: ----------- Modified CV script. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java trunk/test/qtl/breasttissue/train1.conf trunk/test/qtl/carcinogenesis/train.conf trunk/test/qtl/mutagenesis/train1.conf trunk/test/qtl/parkinsons/train.conf trunk/test/qtl/suramin/train.conf Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-09 18:13:04 UTC (rev 4267) @@ -102,19 +102,18 @@ @ConfigOption(name = "noisePercentage", defaultValue="0.0", description="the (approximated) percentage of noise within the examples") private double noisePercentage = 0.0; @ConfigOption(defaultValue = "10", name = "maxExecutionTimeInSeconds", description = "maximum execution of the algorithm in seconds") - private int maxExecutionTimeInSeconds = -1; + private int maxExecutionTimeInSeconds = 60; private double coverageWeight = 0.8; private double specifityWeight = 0.1; - private double coverageBeta = 0.5; private double minCoveredPosExamplesFraction = 0.2; // maximum execution time to compute a part of the solution private double maxTreeComputationTimeInSeconds = 10; // how important not to cover negatives - private double posWeight = 2; + private double beta = 1; // minimum score a query tree must have to be part of the solution - private double minimumTreeScore = 0.2; + private double minimumTreeScore = 0.3; //If yes, then the algorithm tries to cover all positive examples. Note that while this improves accuracy on the testing set, //it may lead to overfitting private boolean tryFullCoverage; @@ -161,10 +160,10 @@ lggGenerator = new LGGGeneratorImpl<String>(); - if(heuristic == null){ +// if(heuristic == null){ heuristic = new QueryTreeHeuristic(); - heuristic.setPosExamplesWeight(posWeight); - } + heuristic.setPosExamplesWeight(beta); +// } logger.info("Initializing..."); treeCache = new QueryTreeCache(model); @@ -222,7 +221,8 @@ String setup = "Setup:"; setup += "\n#Pos. examples:" + currentPosExamples.size(); setup += "\n#Neg. examples:" + currentNegExamples.size(); - setup += "\nPos. weight(beta):" + posWeight; + setup += "Heuristic:" + heuristic.getHeuristicType().name(); + setup += "\nbeta=" + beta; logger.info(setup); logger.info("Running..."); startTime = System.currentTimeMillis(); @@ -236,7 +236,7 @@ logger.info("#Remaining neg. examples:" + currentNegExampleTrees.size()); //compute a (partial) solution - computeNextPartialSolution(); + computeBestPartialSolution(); //pick best (partial) solution computed so far EvaluatedQueryTree<String> bestPartialSolution = currentPartialSolutions.first(); @@ -279,29 +279,31 @@ long endTime = System.currentTimeMillis(); logger.info("Finished in " + (endTime-startTime) + "ms."); - logger.info("Combined solution:\n" + OWLAPIConverter.getOWLAPIDescription(currentBestSolution.getDescription())); + logger.info("Combined solution:" + OWLAPIConverter.getOWLAPIDescription(currentBestSolution.getDescription()).toString().replace("\n", "")); logger.info(currentBestSolution.getScore()); } - private void computeNextPartialSolution(){ + private void computeBestPartialSolution(){ logger.info("Computing best partial solution..."); bestCurrentScore = Double.NEGATIVE_INFINITY; partialSolutionStartTime = System.currentTimeMillis(); initTodoList(currentPosExampleTrees, currentNegExampleTrees); EvaluatedQueryTree<String> currentElement; + QueryTree<String> currentTree; while(!partialSolutionTerminationCriteriaSatisfied()){ logger.trace("TODO list size: " + todoList.size()); //pick best element from todo list currentElement = todoList.poll(); + currentTree = currentElement.getTree(); //generate the LGG between the chosen tree and each uncovered positive example - for (QueryTree<String> example : currentElement.getFalseNegatives()) { - QueryTree<String> tree = currentElement.getTree(); - + Iterator<QueryTree<String>> it = currentElement.getFalseNegatives().iterator(); + while (it.hasNext() && !isPartialSolutionTimeExpired() && !isTimeExpired()) { + QueryTree<String> uncoveredTree = it.next(); //compute the LGG lggMon.start(); - QueryTree<String> lgg = lggGenerator.getLGG(tree, example); + QueryTree<String> lgg = lggGenerator.getLGG(currentTree, uncoveredTree); lggMon.stop(); //evaluate the LGG @@ -312,8 +314,8 @@ if(score >= bestCurrentScore){ //add to todo list, if not already contained in todo list or solution list todo(solution); - if(solution.getScore() > bestCurrentScore){ - logger.info("Got better solution:" + solution.getTreeScore()); + if(score > bestCurrentScore){ + logger.info("\tGot better solution:" + solution.getTreeScore()); } bestCurrentScore = solution.getScore(); } else if(mas < bestCurrentScore){ @@ -330,7 +332,7 @@ logger.info("...finished in " + (endTime-partialSolutionStartTime) + "ms."); EvaluatedDescription bestPartialSolution = currentPartialSolutions.first().asEvaluatedDescription(); - logger.info("Best partial solution:\n" + OWLAPIConverter.getOWLAPIDescription(bestPartialSolution.getDescription()) + "\n(" + bestPartialSolution.getScore() + ")"); + logger.info("Best partial solution: " + OWLAPIConverter.getOWLAPIDescription(bestPartialSolution.getDescription()).toString().replace("\n", "") + "\n(" + bestPartialSolution.getScore() + ")"); logger.trace("LGG time: " + lggMon.getTotal() + "ms"); logger.trace("Avg. LGG time: " + lggMon.getAvg() + "ms"); @@ -361,7 +363,7 @@ ? 0 : coveredPositiveExamples / (double)(coveredPositiveExamples + coveredNegativeExampleTrees.size()); - double coverageScore = Heuristics.getFScore(recall, precision, coverageBeta); + double coverageScore = Heuristics.getFScore(recall, precision, beta); //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented int nrOfSpecificNodes = 0; @@ -400,8 +402,6 @@ private EvaluatedDescription buildCombinedSolution(){ if(partialSolutions.size() == 1){ EvaluatedDescription combinedSolution = partialSolutions.get(0).asEvaluatedDescription(); - double accuracy = lp.getAccuracy(combinedSolution.getDescription()); - System.out.println(accuracy); return combinedSolution; } List<Description> disjuncts = new ArrayList<Description>(); @@ -423,16 +423,13 @@ Set<Individual> posNotCovered = Sets.difference(lp.getPositiveExamples(), posCovered); Set<Individual> negNotCovered = Sets.difference(lp.getNegativeExamples(), negCovered); - double accuracy = lp.getAccuracy(unionDescription); - System.out.println(accuracy); - //compute the coverage double recall = posCovered.size() / (double)lp.getPositiveExamples().size(); double precision = (posCovered.size() + negCovered.size() == 0) ? 0 : posCovered.size() / (double)(posCovered.size() + negCovered.size()); - double coverageScore = Heuristics.getFScore(recall, precision, coverageBeta); + double coverageScore = Heuristics.getFScore(recall, precision, beta); // ScoreTwoValued score = new ScoreTwoValued(posCovered, posNotCovered, negCovered, negNotCovered); // score.setAccuracy(coverageScore); @@ -442,6 +439,7 @@ } private void reset(){ + currentBestSolution = null; partialSolutions = new ArrayList<EvaluatedQueryTree<String>>(); stop = false; @@ -672,17 +670,18 @@ } /** - * @param coverageBeta the coverageBeta to set + * Default value is 1. Lower values force importance of covering positive examples. + * @param beta the beta to set */ - public void setCoverageBeta(double coverageBeta) { - this.coverageBeta = coverageBeta; + public void setBeta(double beta) { + this.beta = beta; } /** - * @param posWeight the posWeight to set + * @param maxTreeComputationTimeInSeconds the maxTreeComputationTimeInSeconds to set */ - public void setPosWeight(double posWeight) { - this.posWeight = posWeight; + public void setMaxTreeComputationTimeInSeconds(double maxTreeComputationTimeInSeconds) { + this.maxTreeComputationTimeInSeconds = maxTreeComputationTimeInSeconds; } /* (non-Javadoc) Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-09 18:13:04 UTC (rev 4267) @@ -26,13 +26,6 @@ private HeuristicType heuristicType = HeuristicType.PRED_ACC; - // F score beta value - private double coverageBeta = 1; - - private double coverageWeight = 0.8; - - private double specifityWeight = 0.1; - private double posExamplesWeight = 1; // syntactic comparison as final comparison criterion @@ -63,7 +56,7 @@ case FMEASURE : score = Heuristics.getFScore(tp/(tp+fn), tp/(tp+fp), posExamplesWeight);break; case PRED_ACC : - score = (tp + posExamplesWeight * tn) / ((tp + fn) + posExamplesWeight * (tn + fp));break; + score = (1/posExamplesWeight * tp + tn) / (1/posExamplesWeight * (tp + fn) + (tn + fp));break; case ENTROPY :{ double total = tp + fn; double pp = tp / total; @@ -154,6 +147,13 @@ } /** + * @return the heuristicType + */ + public HeuristicType getHeuristicType() { + return heuristicType; + } + + /** * @param posExamplesWeight the posExamplesWeight to set */ public void setPosExamplesWeight(double posExamplesWeight) { Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/DoubleMinMaxRange.java 2014-05-09 18:13:04 UTC (rev 4267) @@ -65,11 +65,11 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return " [>= " + minValue + " <= " + maxValue + "]"; + return " double[>= " + minValue + " <= " + maxValue + "]"; } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return " [>= " + minValue + " <= " + maxValue + "]"; + return " double[>= " + minValue + " <= " + maxValue + "]"; } public void accept(KBElementVisitor visitor) { @@ -81,7 +81,7 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return " [>= " + minValue + " <= " + maxValue + "]"; + return " double[>= " + minValue + " <= " + maxValue + "]"; } /* (non-Javadoc) Modified: trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-09 18:13:04 UTC (rev 4267) @@ -22,7 +22,6 @@ import static java.util.Arrays.asList; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.text.DecimalFormat; @@ -43,15 +42,17 @@ import org.apache.commons.beanutils.PropertyUtils; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.FileAppender; +import org.apache.log4j.Layout; import org.apache.log4j.Level; import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.apache.log4j.Priority; import org.apache.log4j.SimpleLayout; import org.dllearner.cli.CLI; import org.dllearner.core.AbstractCELA; import org.dllearner.core.AbstractLearningProblem; import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.ComponentInitException; -import org.dllearner.core.ComponentManager; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.learningproblems.PosNegLP; @@ -101,7 +102,10 @@ */ public class NestedCrossValidation { - private File outputFile = new File("log/nested-cv.log"); + + private static final Logger logger = Logger.getLogger(NestedCrossValidation.class.getName()); + + private static File logFile = new File("log/nested-cv.log"); DecimalFormat df = new DecimalFormat(); // overall statistics @@ -126,7 +130,7 @@ OptionParser parser = new OptionParser(); parser.acceptsAll(asList("h", "?", "help"), "Show help."); - parser.acceptsAll(asList("c", "conf"), "The comma separated list of conffiles to be used.").withRequiredArg().describedAs("file1, file2, ..."); + parser.acceptsAll(asList("c", "conf"), "The comma separated list of config files to be used.").withRequiredArg().describedAs("file1, file2, ..."); parser.acceptsAll(asList( "v", "verbose"), "Be more verbose."); parser.acceptsAll(asList( "o", "outerfolds"), "Number of outer folds.").withRequiredArg().ofType(Integer.class).describedAs("#folds"); parser.acceptsAll(asList( "i", "innerfolds"), "Number of inner folds.").withRequiredArg().ofType(Integer.class).describedAs("#folds"); @@ -167,13 +171,18 @@ // create logger (a simple logger which outputs // its messages to the console) - SimpleLayout layout = new SimpleLayout(); + Layout layout = new PatternLayout("%m%n"); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger logger = Logger.getRootLogger(); logger.removeAllAppenders(); logger.addAppender(consoleAppender); - logger.setLevel(Level.WARN); + logger.setLevel(Level.ERROR); Logger.getLogger("org.dllearner.algorithms").setLevel(Level.INFO); + Logger.getLogger("org.dllearner.scripts").setLevel(Level.INFO); + + FileAppender fileAppender = new FileAppender(layout, logFile.getPath(), false); + logger.addAppender(fileAppender); + fileAppender.setThreshold(Level.INFO); // logger.addAppender(new FileAppender(layout, "nested-cv.log", false)); // disable OWL API info output java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.WARNING); @@ -188,15 +197,6 @@ } } - - private void print(String s){ - try { - Files.append(s + "\n", outputFile , Charsets.UTF_8); - } catch (IOException e) { - e.printStackTrace(); - } - System.out.println(s); - } public NestedCrossValidation(File confFile, int outerFolds, int innerFolds, String parameter, double startValue, double endValue, double stepsize, boolean verbose) throws ComponentInitException, ParseException, org.dllearner.confparser.ParseException, IOException { this(Lists.newArrayList(confFile), outerFolds, innerFolds, parameter, startValue, endValue, stepsize, verbose); @@ -205,37 +205,38 @@ public NestedCrossValidation(List<File> confFiles, int outerFolds, int innerFolds, String parameter, double startValue, double endValue, double stepsize, boolean verbose) throws ComponentInitException, ParseException, org.dllearner.confparser.ParseException, IOException { for (File confFile : confFiles) { - print(confFile.getPath()); + logger.info("++++++++++++++++++++++++++++++++++++++++++++++"); + logger.info(confFile.getPath()); + logger.info("++++++++++++++++++++++++++++++++++++++++++++++"); validate(confFile, outerFolds, innerFolds, parameter, startValue, endValue, stepsize, verbose); } - print("********************************************"); - print("********************************************"); - print("********************************************"); + logger.info("############################################"); + logger.info("############################################"); // decide for the best parameter - print(" Summary over parameter values:"); + logger.info(" Overall summary over parameter values:"); double bestPara = startValue; double bestValue = Double.NEGATIVE_INFINITY; for (Entry<Double, Stat> entry : globalParaStats.entrySet()) { double para = entry.getKey(); Stat stat = entry.getValue(); - print(" value " + para + ": " + stat.prettyPrint("%")); + logger.info(" value " + para + ": " + stat.prettyPrint("%")); if (stat.getMean() > bestValue) { bestPara = para; bestValue = stat.getMean(); } } - print(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); + logger.info(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); // overall statistics - print("*******************"); - print("* Overall Results *"); - print("*******************"); - print("accuracy: " + globalAcc.prettyPrint("%")); - print("F measure: " + globalF.prettyPrint("%")); - print("precision: " + globalPrecision.prettyPrint("%")); - print("recall: " + globalRecall.prettyPrint("%")); + logger.info("*******************"); + logger.info("* Overall Results *"); + logger.info("*******************"); + logger.info("accuracy: " + globalAcc.prettyPrint("%")); + logger.info("F measure: " + globalF.prettyPrint("%")); + logger.info("precision: " + globalPrecision.prettyPrint("%")); + logger.info("recall: " + globalRecall.prettyPrint("%")); } @@ -255,6 +256,7 @@ Collections.shuffle(negExamples, new Random(2)); AbstractReasonerComponent rc = start.getReasonerComponent(); + rc.init(); String baseURI = rc.getBaseURI(); List<TrainTestList> posLists = getFolds(posExamples, outerFolds); @@ -268,7 +270,7 @@ for(int currOuterFold=0; currOuterFold<outerFolds; currOuterFold++) { - print("Outer fold " + currOuterFold); + logger.info("Outer fold " + currOuterFold); TrainTestList posList = posLists.get(currOuterFold); TrainTestList negList = negLists.get(currOuterFold); @@ -277,7 +279,7 @@ for(double currParaValue=startValue; currParaValue<=endValue; currParaValue+=stepsize) { - print(" Parameter value " + currParaValue + ":"); + logger.info(" Parameter value " + currParaValue + ":"); // split train folds again (computation of inner folds for each parameter // value is redundant, but not a big problem) List<Individual> trainPosList = posList.getTrainList(); @@ -291,7 +293,7 @@ for(int currInnerFold=0; currInnerFold<innerFolds; currInnerFold++) { - print(" Inner fold " + currInnerFold + ":"); + logger.info(" Inner fold " + currInnerFold + ":"); // get positive & negative examples for training run Set<Individual> posEx = new TreeSet<Individual>(innerPosLists.get(currInnerFold).getTrainList()); Set<Individual> negEx = new TreeSet<Individual>(innerNegLists.get(currInnerFold).getTrainList()); @@ -320,13 +322,12 @@ TreeSet<Individual> posTest = new TreeSet<Individual>(innerPosLists.get(currInnerFold).getTestList()); TreeSet<Individual> negTest = new TreeSet<Individual>(innerNegLists.get(currInnerFold).getTestList()); - AbstractReasonerComponent rs = start.getReasonerComponent(); // true positive - Set<Individual> posCorrect = rs.hasType(concept, posTest); + Set<Individual> posCorrect = rc.hasType(concept, posTest); // false negative Set<Individual> posError = Helper.difference(posTest, posCorrect); // false positive - Set<Individual> negError = rs.hasType(concept, negTest); + Set<Individual> negError = rc.hasType(concept, negTest); // true negative Set<Individual> negCorrect = Helper.difference(negTest, negError); @@ -340,19 +341,16 @@ paraCriterionStat.addNumber(accuracy); - print(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); - print(" accuracy: " + df.format(accuracy) + "%"); - print(" precision: " + df.format(precision) + "%"); - print(" recall: " + df.format(recall) + "%"); - print(" F measure: " + df.format(fmeasure) + "%"); + logger.info(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); + logger.info(" accuracy: " + df.format(accuracy) + "%"); + logger.info(" precision: " + df.format(precision) + "%"); + logger.info(" recall: " + df.format(recall) + "%"); + logger.info(" F measure: " + df.format(fmeasure) + "%"); if(verbose) { - print(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); - print(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); + logger.info(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); + logger.info(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); } - - // free memory - rs.releaseKB(); } paraStats.put(currParaValue, paraCriterionStat); @@ -365,20 +363,20 @@ } // decide for the best parameter - print(" Summary over parameter values:"); + logger.info(" Summary over parameter values:"); double bestPara = startValue; double bestValue = Double.NEGATIVE_INFINITY; for(Entry<Double,Stat> entry : paraStats.entrySet()) { double para = entry.getKey(); Stat stat = entry.getValue(); - print(" value " + para + ": " + stat.prettyPrint("%")); + logger.info(" value " + para + ": " + stat.prettyPrint("%")); if(stat.getMean() > bestValue) { bestPara = para; bestValue = stat.getMean(); } } - print(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); - print(" Learn on Outer fold:"); + logger.info(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); + logger.info(" Learn on Outer fold:"); // start a learning process with this parameter and evaluate it on the outer fold start = new CLI(confFile); @@ -418,15 +416,15 @@ double recall = 100 * (double) posCorrect.size() / (posCorrect.size() + posError.size()); double fmeasure = 2 * (precision * recall) / (precision + recall); - print(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); - print(" accuracy: " + df.format(accuracy) + "%"); - print(" precision: " + df.format(precision) + "%"); - print(" recall: " + df.format(recall) + "%"); - print(" F measure: " + df.format(fmeasure) + "%"); + logger.info(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); + logger.info(" accuracy: " + df.format(accuracy) + "%"); + logger.info(" precision: " + df.format(precision) + "%"); + logger.info(" recall: " + df.format(recall) + "%"); + logger.info(" F measure: " + df.format(fmeasure) + "%"); if(verbose) { - print(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); - print(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); + logger.info(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); + logger.info(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); } // update overall statistics @@ -445,13 +443,13 @@ globalRecall.add(recallOverall); // overall statistics - print("*******************"); - print("* Overall Results *"); - print("*******************"); - print("accuracy: " + accOverall.prettyPrint("%")); - print("F measure: " + fOverall.prettyPrint("%")); - print("precision: " + precisionOverall.prettyPrint("%")); - print("recall: " + recallOverall.prettyPrint("%")); + logger.info("*******************"); + logger.info("* Overall Results *"); + logger.info("*******************"); + logger.info("accuracy: " + accOverall.prettyPrint("%")); + logger.info("F measure: " + fOverall.prettyPrint("%")); + logger.info("precision: " + precisionOverall.prettyPrint("%")); + logger.info("recall: " + recallOverall.prettyPrint("%")); } // convenience methods, which takes a list of examples and divides them in Modified: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-09 18:13:04 UTC (rev 4267) @@ -6,43 +6,39 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import org.dllearner.algorithms.qtl.QTL2; import org.dllearner.algorithms.qtl.QTL2Disjunctive; import org.dllearner.algorithms.qtl.QueryTreeFactory; import org.dllearner.algorithms.qtl.datastructures.QueryTree; import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; import org.dllearner.algorithms.qtl.impl.QueryTreeFactoryImpl; +import org.dllearner.cli.CLI; import org.dllearner.cli.CrossValidation; -import org.dllearner.cli.SPARQLCrossValidation; +import org.dllearner.core.AbstractLearningProblem; import org.dllearner.core.ComponentInitException; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.owl.Individual; -import org.dllearner.kb.LocalModelBasedSparqlEndpointKS; import org.dllearner.kb.OWLAPIOntology; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.reasoning.SPARQLReasoner; +import org.dllearner.scripts.NestedCrossValidation; import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLDataFactory; import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyChange; import org.semanticweb.owlapi.model.OWLOntologyCreationException; import org.semanticweb.owlapi.model.OWLOntologyManager; -import org.semanticweb.owlapi.reasoner.OWLReasoner; -import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; -import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; @@ -52,363 +48,20 @@ */ public class QTLEvaluation { - int nrOfFolds = 10; + int nrOfFolds = 3; private int nrOfPosExamples = 300; private int nrOfNegExamples = 300; - List<String> posExamples = Lists.newArrayList( - "http://dl-learner.org/carcinogenesis#d1", - "http://dl-learner.org/carcinogenesis#d10", - "http://dl-learner.org/carcinogenesis#d101", - "http://dl-learner.org/carcinogenesis#d102", - "http://dl-learner.org/carcinogenesis#d103", - "http://dl-learner.org/carcinogenesis#d106", - "http://dl-learner.org/carcinogenesis#d107", - "http://dl-learner.org/carcinogenesis#d108", - "http://dl-learner.org/carcinogenesis#d11", - "http://dl-learner.org/carcinogenesis#d12", - "http://dl-learner.org/carcinogenesis#d13", - "http://dl-learner.org/carcinogenesis#d134", - "http://dl-learner.org/carcinogenesis#d135", - "http://dl-learner.org/carcinogenesis#d136", - "http://dl-learner.org/carcinogenesis#d138", - "http://dl-learner.org/carcinogenesis#d140", - "http://dl-learner.org/carcinogenesis#d141", - "http://dl-learner.org/carcinogenesis#d144", - "http://dl-learner.org/carcinogenesis#d145", - "http://dl-learner.org/carcinogenesis#d146", - "http://dl-learner.org/carcinogenesis#d147", - "http://dl-learner.org/carcinogenesis#d15", - "http://dl-learner.org/carcinogenesis#d17", - "http://dl-learner.org/carcinogenesis#d19", - "http://dl-learner.org/carcinogenesis#d192", - "http://dl-learner.org/carcinogenesis#d193", - "http://dl-learner.org/carcinogenesis#d195", - "http://dl-learner.org/carcinogenesis#d196", - "http://dl-learner.org/carcinogenesis#d197", - "http://dl-learner.org/carcinogenesis#d198", - "http://dl-learner.org/carcinogenesis#d199", - "http://dl-learner.org/carcinogenesis#d2", - "http://dl-learner.org/carcinogenesis#d20", - "http://dl-learner.org/carcinogenesis#d200", - "http://dl-learner.org/carcinogenesis#d201", - "http://dl-learner.org/carcinogenesis#d202", - "http://dl-learner.org/carcinogenesis#d203", - "http://dl-learner.org/carcinogenesis#d204", - "http://dl-learner.org/carcinogenesis#d205", - "http://dl-learner.org/carcinogenesis#d21", - "http://dl-learner.org/carcinogenesis#d22", - "http://dl-learner.org/carcinogenesis#d226", - "http://dl-learner.org/carcinogenesis#d227", - "http://dl-learner.org/carcinogenesis#d228", - "http://dl-learner.org/carcinogenesis#d229", - "http://dl-learner.org/carcinogenesis#d231", - "http://dl-learner.org/carcinogenesis#d232", - "http://dl-learner.org/carcinogenesis#d234", - "http://dl-learner.org/carcinogenesis#d236", - "http://dl-learner.org/carcinogenesis#d239", - "http://dl-learner.org/carcinogenesis#d23_2", - "http://dl-learner.org/carcinogenesis#d242", - "http://dl-learner.org/carcinogenesis#d245", - "http://dl-learner.org/carcinogenesis#d247", - "http://dl-learner.org/carcinogenesis#d249", - "http://dl-learner.org/carcinogenesis#d25", - "http://dl-learner.org/carcinogenesis#d252", - "http://dl-learner.org/carcinogenesis#d253", - "http://dl-learner.org/carcinogenesis#d254", - "http://dl-learner.org/carcinogenesis#d255", - "http://dl-learner.org/carcinogenesis#d26", - "http://dl-learner.org/carcinogenesis#d272", - "http://dl-learner.org/carcinogenesis#d275", - "http://dl-learner.org/carcinogenesis#d277", - "http://dl-learner.org/carcinogenesis#d279", - "http://dl-learner.org/carcinogenesis#d28", - "http://dl-learner.org/carcinogenesis#d281", - "http://dl-learner.org/carcinogenesis#d283", - "http://dl-learner.org/carcinogenesis#d284", - "http://dl-learner.org/carcinogenesis#d288", - "http://dl-learner.org/carcinogenesis#d29", - "http://dl-learner.org/carcinogenesis#d290", - "http://dl-learner.org/carcinogenesis#d291", - "http://dl-learner.org/carcinogenesis#d292", - "http://dl-learner.org/carcinogenesis#d30", - "http://dl-learner.org/carcinogenesis#d31", - "http://dl-learner.org/carcinogenesis#d32", - "http://dl-learner.org/carcinogenesis#d33", - "http://dl-learner.org/carcinogenesis#d34", - "http://dl-learner.org/carcinogenesis#d35", - "http://dl-learner.org/carcinogenesis#d36", - "http://dl-learner.org/carcinogenesis#d37", - "http://dl-learner.org/carcinogenesis#d38", - "http://dl-learner.org/carcinogenesis#d42", - "http://dl-learner.org/carcinogenesis#d43", - "http://dl-learner.org/carcinogenesis#d44", - "http://dl-learner.org/carcinogenesis#d45", - "http://dl-learner.org/carcinogenesis#d46", - "http://dl-learner.org/carcinogenesis#d47", - "http://dl-learner.org/carcinogenesis#d48", - "http://dl-learner.org/carcinogenesis#d49", - "http://dl-learner.org/carcinogenesis#d5", - "http://dl-learner.org/carcinogenesis#d51", - "http://dl-learner.org/carcinogenesis#d52", - "http://dl-learner.org/carcinogenesis#d53", - "http://dl-learner.org/carcinogenesis#d55", - "http://dl-learner.org/carcinogenesis#d58", - "http://dl-learner.org/carcinogenesis#d6", - "http://dl-learner.org/carcinogenesis#d7", - "http://dl-learner.org/carcinogenesis#d84", - "http://dl-learner.org/carcinogenesis#d85_2", - "http://dl-learner.org/carcinogenesis#d86", - "http://dl-learner.org/carcinogenesis#d87", - "http://dl-learner.org/carcinogenesis#d88", - "http://dl-learner.org/carcinogenesis#d89", - "http://dl-learner.org/carcinogenesis#d9", - "http://dl-learner.org/carcinogenesis#d91", - "http://dl-learner.org/carcinogenesis#d92", - "http://dl-learner.org/carcinogenesis#d93", - "http://dl-learner.org/carcinogenesis#d95", - "http://dl-learner.org/carcinogenesis#d96", - "http://dl-learner.org/carcinogenesis#d98", - "http://dl-learner.org/carcinogenesis#d99", - "http://dl-learner.org/carcinogenesis#d100", - "http://dl-learner.org/carcinogenesis#d104", - "http://dl-learner.org/carcinogenesis#d105", - "http://dl-learner.org/carcinogenesis#d109", - "http://dl-learner.org/carcinogenesis#d137", - "http://dl-learner.org/carcinogenesis#d139", - "http://dl-learner.org/carcinogenesis#d14", - "http://dl-learner.org/carcinogenesis#d142", - "http://dl-learner.org/carcinogenesis#d143", - "http://dl-learner.org/carcinogenesis#d148", - "http://dl-learner.org/carcinogenesis#d16", - "http://dl-learner.org/carcinogenesis#d18", - "http://dl-learner.org/carcinogenesis#d191", - "http://dl-learner.org/carcinogenesis#d206", - "http://dl-learner.org/carcinogenesis#d230", - "http://dl-learner.org/carcinogenesis#d233", - "http://dl-learner.org/carcinogenesis#d235", - "http://dl-learner.org/carcinogenesis#d237", - "http://dl-learner.org/carcinogenesis#d238", - "http://dl-learner.org/carcinogenesis#d23_1", - "http://dl-learner.org/carcinogenesis#d24", - "http://dl-learner.org/carcinogenesis#d240", - "http://dl-learner.org/carcinogenesis#d241", - "http://dl-learner.org/carcinogenesis#d243", - "http://dl-learner.org/carcinogenesis#d244", - "http://dl-learner.org/carcinogenesis#d246", - "http://dl-learner.org/carcinogenesis#d248", - "http://dl-learner.org/carcinogenesis#d250", - "http://dl-learner.org/carcinogenesis#d251", - "http://dl-learner.org/carcinogenesis#d27", - "http://dl-learner.org/carcinogenesis#d273", - "http://dl-learner.org/carcinogenesis#d274", - "http://dl-learner.org/carcinogenesis#d278", - "http://dl-learner.org/carcinogenesis#d286", - "http://dl-learner.org/carcinogenesis#d289", - "http://dl-learner.org/carcinogenesis#d3", - "http://dl-learner.org/carcinogenesis#d39", - "http://dl-learner.org/carcinogenesis#d4", - "http://dl-learner.org/carcinogenesis#d40", - "http://dl-learner.org/carcinogenesis#d41", - "http://dl-learner.org/carcinogenesis#d50", - "http://dl-learner.org/carcinogenesis#d54", - "http://dl-learner.org/carcinogenesis#d56", - "http://dl-learner.org/carcinogenesis#d57", - "http://dl-learner.org/carcinogenesis#d8", - "http://dl-learner.org/carcinogenesis#d85_1", - "http://dl-learner.org/carcinogenesis#d90", - "http://dl-learner.org/carcinogenesis#d94", - "http://dl-learner.org/carcinogenesis#d97", - "http://dl-learner.org/carcinogenesis#d296", - "http://dl-learner.org/carcinogenesis#d305", - "http://dl-learner.org/carcinogenesis#d306", - "http://dl-learner.org/carcinogenesis#d307", - "http://dl-learner.org/carcinogenesis#d308", - "http://dl-learner.org/carcinogenesis#d311", - "http://dl-learner.org/carcinogenesis#d314", - "http://dl-learner.org/carcinogenesis#d315", - "http://dl-learner.org/carcinogenesis#d316", - "http://dl-learner.org/carcinogenesis#d320", - "http://dl-learner.org/carcinogenesis#d322", - "http://dl-learner.org/carcinogenesis#d323", - "http://dl-learner.org/carcinogenesis#d325", - "http://dl-learner.org/carcinogenesis#d329", - "http://dl-learner.org/carcinogenesis#d330", - "http://dl-learner.org/carcinogenesis#d331", - "http://dl-learner.org/carcinogenesis#d332", - "http://dl-learner.org/carcinogenesis#d333", - "http://dl-learner.org/carcinogenesis#d336", - "http://dl-learner.org/carcinogenesis#d337" - ); + CLI cli = new CLI(new File("../test/qtl/carcinogenesis/train.conf")); - List<String> negExamples = Lists.newArrayList( - "http://dl-learner.org/carcinogenesis#d110", - "http://dl-learner.org/carcinogenesis#d111", - "http://dl-learner.org/carcinogenesis#d114", - "http://dl-learner.org/carcinogenesis#d116", - "http://dl-learner.org/carcinogenesis#d117", - "http://dl-learner.org/carcinogenesis#d119", - "http://dl-learner.org/carcinogenesis#d121", - "http://dl-learner.org/carcinogenesis#d123", - "http://dl-learner.org/carcinogenesis#d124", - "http://dl-learner.org/carcinogenesis#d125", - "http://dl-learner.org/carcinogenesis#d127", - "http://dl-learner.org/carcinogenesis#d128", - "http://dl-learner.org/carcinogenesis#d130", - "http://dl-learner.org/carcinogenesis#d133", - "http://dl-learner.org/carcinogenesis#d150", - "http://dl-learner.org/carcinogenesis#d151", - "http://dl-learner.org/carcinogenesis#d154", - "http://dl-learner.org/carcinogenesis#d155", - "http://dl-learner.org/carcinogenesis#d156", - "http://dl-learner.org/carcinogenesis#d159", - "http://dl-learner.org/carcinogenesis#d160", - "http://dl-learner.org/carcinogenesis#d161", - "http://dl-learner.org/carcinogenesis#d162", - "http://dl-learner.org/carcinogenesis#d163", - "http://dl-learner.org/carcinogenesis#d164", - "http://dl-learner.org/carcinogenesis#d165", - "http://dl-learner.org/carcinogenesis#d166", - "http://dl-learner.org/carcinogenesis#d169", - "http://dl-learner.org/carcinogenesis#d170", - "http://dl-learner.org/carcinogenesis#d171", - "http://dl-learner.org/carcinogenesis#d172", - "http://dl-learner.org/carcinogenesis#d173", - "http://dl-learner.org/carcinogenesis#d174", - "http://dl-learner.org/carcinogenesis#d178", - "http://dl-learner.org/carcinogenesis#d179", - "http://dl-learner.org/carcinogenesis#d180", - "http://dl-learner.org/carcinogenesis#d181", - "http://dl-learner.org/carcinogenesis#d183", - "http://dl-learner.org/carcinogenesis#d184", - "http://dl-learner.org/carcinogenesis#d185", - "http://dl-learner.org/carcinogenesis#d186", - "http://dl-learner.org/carcinogenesis#d188", - "http://dl-learner.org/carcinogenesis#d190", - "http://dl-learner.org/carcinogenesis#d194", - "http://dl-learner.org/carcinogenesis#d207", - "http://dl-learner.org/carcinogenesis#d208_1", - "http://dl-learner.org/carcinogenesis#d209", - "http://dl-learner.org/carcinogenesis#d210", - "http://dl-learner.org/carcinogenesis#d211", - "http://dl-learner.org/carcinogenesis#d212", - "http://dl-learner.org/carcinogenesis#d213", - "http://dl-learner.org/carcinogenesis#d214", - "http://dl-learner.org/carcinogenesis#d215", - "http://dl-learner.org/carcinogenesis#d217", - "http://dl-learner.org/carcinogenesis#d218", - "http://dl-learner.org/carcinogenesis#d219", - "http://dl-learner.org/carcinogenesis#d220", - "http://dl-learner.org/carcinogenesis#d224", - "http://dl-learner.org/carcinogenesis#d256", - "http://dl-learner.org/carcinogenesis#d257", - "http://dl-learner.org/carcinogenesis#d258", - "http://dl-learner.org/carcinogenesis#d261", - "http://dl-learner.org/carcinogenesis#d262", - "http://dl-learner.org/carcinogenesis#d263", - "http://dl-learner.org/carcinogenesis#d264", - "http://dl-learner.org/carcinogenesis#d265", - "http://dl-learner.org/carcinogenesis#d266", - "http://dl-learner.org/carcinogenesis#d267", - "http://dl-learner.org/carcinogenesis#d269", - "http://dl-learner.org/carcinogenesis#d271", - "http://dl-learner.org/carcinogenesis#d276", - "http://dl-learner.org/carcinogenesis#d280", - "http://dl-learner.org/carcinogenesis#d285", - "http://dl-learner.org/carcinogenesis#d287", - "http://dl-learner.org/carcinogenesis#d293", - "http://dl-learner.org/carcinogenesis#d294", - "http://dl-learner.org/carcinogenesis#d59", - "http://dl-learner.org/carcinogenesis#d60", - "http://dl-learner.org/carcinogenesis#d61", - "http://dl-learner.org/carcinogenesis#d63", - "http://dl-learner.org/carcinogenesis#d64", - "http://dl-learner.org/carcinogenesis#d65", - "http://dl-learner.org/carcinogenesis#d69", - "http://dl-learner.org/carcinogenesis#d70", - "http://dl-learner.org/carcinogenesis#d71", - "http://dl-learner.org/carcinogenesis#d72", - "http://dl-learner.org/carcinogenesis#d73", - "http://dl-learner.org/carcinogenesis#d74", - "http://dl-learner.org/carcinogenesis#d75", - "http://dl-learner.org/carcinogenesis#d76", - "http://dl-learner.org/carcinogenesis#d77", - "http://dl-learner.org/carcinogenesis#d78", - "http://dl-learner.org/carcinogenesis#d79", - "http://dl-learner.org/carcinogenesis#d80", - "http://dl-learner.org/carcinogenesis#d81", - "http://dl-learner.org/carcinogenesis#d82", - "http://dl-learner.org/carcinogenesis#d112", - "http://dl-learner.org/carcinogenesis#d113", - "http://dl-learner.org/carcinogenesis#d115", - "http://dl-learner.org/carcinogenesis#d118", - "http://dl-learner.org/carcinogenesis#d120", - "http://dl-learner.org/carcinogenesis#d122", - "http://dl-learner.org/carcinogenesis#d126", - "http://dl-learner.org/carcinogenesis#d129", - "http://dl-learner.org/carcinogenesis#d131", - "http://dl-learner.org/carcinogenesis#d132", - "http://dl-learner.org/carcinogenesis#d149", - "http://dl-learner.org/carcinogenesis#d152", - "http://dl-learner.org/carcinogenesis#d153", - "http://dl-learner.org/carcinogenesis#d157", - "http://dl-learner.org/carcinogenesis#d158", - "http://dl-learner.org/carcinogenesis#d167", - "http://dl-learner.org/carcinogenesis#d168", - "http://dl-learner.org/carcinogenesis#d175", - "http://dl-learner.org/carcinogenesis#d176", - "http://dl-learner.org/carcinogenesis#d177", - "http://dl-learner.org/carcinogenesis#d182", - "http://dl-learner.org/carcinogenesis#d187", - "http://dl-learner.org/carcinogenesis#d189", - "http://dl-learner.org/carcinogenesis#d208_2", - "http://dl-learner.org/carcinogenesis#d216", - "http://dl-learner.org/carcinogenesis#d221", - "http://dl-learner.org/carcinogenesis#d222", - "http://dl-learner.org/carcinogenesis#d223", - "http://dl-learner.org/carcinogenesis#d225", - "http://dl-learner.org/carcinogenesis#d259", - "http://dl-learner.org/carcinogenesis#d260", - "http://dl-learner.org/carcinogenesis#d268", - "http://dl-learner.org/carcinogenesis#d270", - "http://dl-learner.org/carcinogenesis#d282", - "http://dl-learner.org/carcinogenesis#d295", - "http://dl-learner.org/carcinogenesis#d62", - "http://dl-learner.org/carcinogenesis#d66", - "http://dl-learner.org/carcinogenesis#d67", - "http://dl-learner.org/carcinogenesis#d68", - "http://dl-learner.org/carcinogenesis#d83", - "http://dl-learner.org/carcinogenesis#d297", - "http://dl-learner.org/carcinogenesis#d298", - "http://dl-learner.org/carcinogenesis#d299", - "http://dl-learner.org/carcinogenesis#d300", - "http://dl-learner.org/carcinogenesis#d302", - "http://dl-learner.org/carcinogenesis#d303", - "http://dl-learner.org/carcinogenesis#d304", - "http://dl-learner.org/carcinogenesis#d309", - "http://dl-learner.org/carcinogenesis#d312", - "http://dl-learner.org/carcinogenesis#d313", - "http://dl-learner.org/carcinogenesis#d317", - "http://dl-learner.org/carcinogenesis#d318", - "http://dl-learner.org/carcinogenesis#d319", - "http://dl-learner.org/carcinogenesis#d324", - "http://dl-learner.org/carcinogenesis#d326", - "http://dl-learner.org/carcinogenesis#d327", - "http://dl-learner.org/carcinogenesis#d328", - "http://dl-learner.org/carcinogenesis#d334", - "http://dl-learner.org/carcinogenesis#d335" - ); - private Model model; private OWLOntology ontology; private QueryTreeFactory<String> queryTreeFactory; - private List<QueryTree<String>> posExampleTrees; - private List<QueryTree<String>> negExampleTrees; private PosNegLP lp; - public QTLEvaluation() throws ComponentInitException { + public QTLEvaluation() throws ComponentInitException, IOException { queryTreeFactory = new QueryTreeFactoryImpl(); queryTreeFactory.setMaxDepth(3); @@ -434,59 +87,29 @@ } } - private void loadExamples() throws ComponentInitException{ + private void loadExamples() throws ComponentInitException, IOException{ - Collections.shuffle(posExamples, new Random(1)); - Collections.shuffle(negExamples, new Random(2)); + cli.init(); + lp = (PosNegLP) cli.getLearningProblem(); + + // get examples and shuffle them + List<Individual> posExamples = new LinkedList<Individual>(((PosNegLP)lp).getPositiveExamples()); + Collections.shuffle(posExamples, new Random(1)); + List<Individual> negExamples = new LinkedList<Individual>(((PosNegLP)lp).getNegativeExamples()); + Collections.shuffle(negExamples, new Random(2)); posExamples = posExamples.subList(0, Math.min(posExamples.size(), nrOfPosExamples)); negExamples = negExamples.subList(0, Math.min(negExamples.size(), nrOfNegExamples)); -// posExamples.clear(); -// String string = "http://dl-learner.org/carcinogenesis#d101, http://dl-learner.org/carcinogenesis#d103, http://dl-learner.org/carcinogenesis#d107, http://dl-learner.org/carcinogenesis#d108, http://dl-learner.org/carcinogenesis#d135, http://dl-learner.org/carcinogenesis#d139, http://dl-learner.org/carcinogenesis#d14, http://dl-learner.org/carcinogenesis#d141, http://dl-learner.org/carcinogenesis#d143, http://dl-learner.org/carcinogenesis#d147, http://dl-learner.org/carcinogenesis#d17, http://dl-learner.org/carcinogenesis#d19, http://dl-learner.org/carcinogenesis#d193, http://dl-learner.org/carcinogenesis#d198, http://dl-learner.org/carcinogenesis#d228, http://dl-learner.org/carcinogenesis#d236, http://dl-learner.org/carcinogenesis#d242, http://dl-learner.org/carcinogenesis#d244, http://dl-learner.org/carcinogenesis#d273, http://dl-learner.org/carcinogenesis#d275, http://dl-learner.org/carcinogenesis#d28, http://dl-learner.org/carcinogenesis#d283, http://dl-learner.org/carcinogenesis#d286, http://dl-learner.org/carcinogenesis#d291, http://dl-learner.org/carcinogenesis#d292, http://dl-learner.org/carcinogenesis#d307, http://dl-learner.org/carcinogenesis#d31, http://dl-learner.org/carcinogenesis#d325, http://dl-learner.org/carcinogenesis#d33, http://dl-learner.org/carcinogenesis#d333, http://dl-learner.org/carcinogenesis#d34, http://dl-learner.org/carcinogenesis#d36, http://dl-learner.org/carcinogenesis#d38, http://dl-learner.org/carcinogenesis#d4, http://dl-learner.org/carcinogenesis#d40, http://dl-learner.org/carcinogenesis#d44, http://dl-learner.org/carcinogenesis#d51, http://dl-learner.org/carcinogenesis#d85_2, http://dl-learner.org/carcinogenesis#d98, http://dl-learner.org/carcinogenesis#d99"; -// String[] split = string.split(","); -// for (String s : split) { -// posExamples.add(s.trim()); -// } -// negExamples.clear(); -// string = "http://dl-learner.org/carcinogenesis#d112, http://dl-learner.org/carcinogenesis#d116, http://dl-learner.org/carcinogenesis#d117, http://dl-learner.org/carcinogenesis#d119, http://dl-learner.org/carcinogenesis#d157, http://dl-learner.org/carcinogenesis#d160, http://dl-learner.org/carcinogenesis#d161, http://dl-learner.org/carcinogenesis#d162, http://dl-learner.org/carcinogenesis#d163, http://dl-learner.org/carcinogenesis#d167, http://dl-learner.org/carcinogenesis#d169, http://dl-learner.org/carcinogenesis#d175, http://dl-learner.org/carcinogenesis#d177, http://dl-learner.org/carcinogenesis#d184, http://dl-learner.org/carcinogenesis#d194, http://dl-learner.org/carcinogenesis#d208_2, http://dl-learner.org/carcinogenesis#d209, http://dl-learner.org/carcinogenesis#d217, http://dl-learner.org/carcinogenesis#d256, http://dl-learner.org/carcinogenesis#d257, http://dl-learner.org/carcinogenesis#d260, http://dl-learner.org/carcinogenesis#d271, http://dl-learner.org/carcinogenesis#d276, http://dl-learner.org/carcinogenesis#d282, http://dl-learner.org/carcinogenesis#d287, http://dl-learner.org/carcinogenesis#d294, http://dl-learner.org/carcinogenesis#d298, http://dl-learner.org/carcinogenesis#d300, http://dl-learner.org/carcinogenesis#d309, http://dl-learner.org/carcinogenesis#d319, http://dl-learner.org/carcinogenesis#d326, http://dl-learner.org/carcinogenesis#d328, http://dl-learner.org/carcinogenesis#d334, http://dl-learner.org/carcinogenesis#d60, http://dl-learner.org/carcinogenesis#d61, http://dl-learner.org/carcinogenesis#d66, http://dl-learner.org/carcinogenesis#d75, http://dl-learner.org/carcinogenesis#d79, http://dl-learner.org/carcinogenesis#d80, http://dl-learner.org/carcinogenesis#d83"; -// split = string.split(","); -// for (String s : split) { -// negExamples.add(s.trim()); -// } + Set<Individual> posSet = new TreeSet<Individual>( + NestedCrossValidation.getFolds(NestedCrossValidation.getFolds(posExamples, 3).get(0).getTrainList(), 3).get(0).getTrainList()); + Set<Individual> negSet = new TreeSet<Individual>( + NestedCrossValidation.getFolds(NestedCrossValidation.getFolds(negExamples, 3).get(0).getTrainList(), 3).get(0).getTrainList()); - posExampleTrees = new ArrayList<QueryTree<String>>(); - for (String ex : posExamples) { - QueryTreeImpl<String> tree = queryTreeFactory.getQueryTree(ex, model); - posExampleTrees.add(tree); - } - negExampleTrees = new ArrayList<QueryTree<String>>(); - for (String ex : negExamples) { - QueryTreeImpl<String> tree = queryTreeFactory.getQueryTree(ex, model); - negExampleTrees.add(tree); - } - int cnt = 1; - for(QueryTree<String> tree : posExampleTrees){ -// System.out.println("TREE " + cnt); -// tree.dump(); -// -// System.out.println("-----------------------------"); - cnt++; -// System.out.println(((QueryTreeImpl<String>)tree).toQuery()); - } - - SortedSet<Individual> pos = new TreeSet<Individual>(); - for (String ex : posExamples) { - pos.add(new Individual(ex)); - } - SortedSet<Individual> neg = new TreeSet<Individual>(); - for (String ex : negExamples) { - neg.add(new Individual(ex)); - } - lp = new PosNegLPStandard(); - lp.setPositiveExamples(pos); - lp.setNegativeExamples(neg); + this.lp = new PosNegLPStandard(); + this.lp.setPositiveExamples(posSet); + this.lp.setNegativeExamples(negSet); } public void run(boolean multiThreaded) throws ComponentInitException, LearningProblemUnsupportedException{ @@ -496,13 +119,14 @@ lp.setReasoner(reasoner); lp.init(); QTL2Disjunctive la = new QTL2Disjunctive(lp, reasoner); -// la.init(); -// la.start(); + la.setBeta(0.5); + la.init(); + la.start(); CrossValidation.outputFile = new File("log/qtl-cv.log"); CrossValidation.writeToFile = true; CrossValidation.multiThreaded = multiThreaded; - CrossValidation cv = new CrossValidation(la, lp, reasoner, nrOfFolds, false); +// CrossValidation cv = new CrossValidation(la, lp, reasoner, nrOfFolds, false); long endTime = System.currentTimeMillis(); System.err.println((endTime - startTime) + "ms"); } Modified: trunk/test/qtl/breasttissue/train1.conf =================================================================== --- trunk/test/qtl/breasttissue/train1.conf 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/test/qtl/breasttissue/train1.conf 2014-05-09 18:13:04 UTC (rev 4267) @@ -8,6 +8,8 @@ // QTL configuration alg.type = "qtl2dis" +alg.maxExecutionTimeInSeconds = 60 +alg.maxTreeComputationTimeInSeconds = 10 // learning problem lp.type = "posNegStandard" Modified: trunk/test/qtl/carcinogenesis/train.conf =================================================================== --- trunk/test/qtl/carcinogenesis/train.conf 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/test/qtl/carcinogenesis/train.conf 2014-05-09 18:13:04 UTC (rev 4267) @@ -8,6 +8,11 @@ reasoner.type = "fast instance checker" reasoner.sources = { ks } +// QTL configuration +alg.type = "qtl2dis" +alg.maxExecutionTimeInSeconds = 60 +alg.maxTreeComputationTimeInSeconds = 10 + // learning problem lp.type = "posNegStandard" lp.positiveExamples = { @@ -352,5 +357,3 @@ "kb:d335" } -// QTL configuration -alg.type = "qtl2dis" Modified: trunk/test/qtl/mutagenesis/train1.conf =================================================================== --- trunk/test/qtl/mutagenesis/train1.conf 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/test/qtl/mutagenesis/train1.conf 2014-05-09 18:13:04 UTC (rev 4267) @@ -11,6 +11,8 @@ // QTL configuration alg.type = "qtl2dis" +alg.maxExecutionTimeInSeconds = 60 +alg.maxTreeComputationTimeInSeconds = 10 // learning problem lp.type = "posNegStandard" Modified: trunk/test/qtl/parkinsons/train.conf =================================================================== --- trunk/test/qtl/parkinsons/train.conf 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/test/qtl/parkinsons/train.conf 2014-05-09 18:13:04 UTC (rev 4267) @@ -7,6 +7,8 @@ // QTL configuration alg.type = "qtl2dis" +alg.maxExecutionTimeInSeconds = 60 +alg.maxTreeComputationTimeInSeconds = 10 // learning problem lp.type = "posNegStandard" Modified: trunk/test/qtl/suramin/train.conf =================================================================== --- trunk/test/qtl/suramin/train.conf 2014-05-08 18:19:32 UTC (rev 4266) +++ trunk/test/qtl/suramin/train.conf 2014-05-09 18:13:04 UTC (rev 4267) @@ -30,4 +30,6 @@ } // QTL configuration -alg.type = "qtl2dis" \ No newline at end of file +alg.type = "qtl2dis" +alg.maxExecutionTimeInSeconds = 60 +alg.maxTreeComputationTimeInSeconds = 10 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-08 18:19:35
|
Revision: 4266 http://sourceforge.net/p/dl-learner/code/4266 Author: lorenz_b Date: 2014-05-08 18:19:32 +0000 (Thu, 08 May 2014) Log Message: ----------- Extended CV script. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-08 14:40:15 UTC (rev 4265) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-08 18:19:32 UTC (rev 4266) @@ -110,7 +110,7 @@ private double minCoveredPosExamplesFraction = 0.2; // maximum execution time to compute a part of the solution - private double maxTreeComputationTimeInSeconds = 60; + private double maxTreeComputationTimeInSeconds = 10; // how important not to cover negatives private double posWeight = 2; // minimum score a query tree must have to be part of the solution Modified: trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-08 14:40:15 UTC (rev 4265) +++ trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-08 18:19:32 UTC (rev 4266) @@ -334,9 +334,9 @@ // double negErrorRate = 100*(negError.size()/posTest.size()); double accuracy = 100*((double)(posCorrect.size()+negCorrect.size())/(posTest.size()+negTest.size())); - double precision = 100 * (double) posCorrect.size() / (posCorrect.size() + negError.size()); - double recall = 100 * (double) posCorrect.size() / (posCorrect.size() + posError.size()); - double fmeasure = 2 * (precision * recall) / (precision + recall); + double precision = 100 * (double) posCorrect.size() / (posCorrect.size() + negError.size()) == 0 ? 0 : (posCorrect.size() + negError.size()); + double recall = 100 * (double) posCorrect.size() / (posCorrect.size() + posError.size()) == 0 ? 0 : (posCorrect.size() + posError.size()); + double fmeasure = 2 * (precision * recall) / (precision + recall) == 0 ? 0 : (precision + recall); paraCriterionStat.addNumber(accuracy); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-08 14:40:17
|
Revision: 4265 http://sourceforge.net/p/dl-learner/code/4265 Author: lorenz_b Date: 2014-05-08 14:40:15 +0000 (Thu, 08 May 2014) Log Message: ----------- Extended CV script. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java trunk/components-core/src/main/java/org/dllearner/utilities/statistics/Stat.java trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-08 14:39:43 UTC (rev 4264) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-08 14:40:15 UTC (rev 4265) @@ -17,6 +17,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.commons.collections.ListUtils; import org.apache.log4j.Logger; import org.dllearner.algorithms.qtl.cache.QueryTreeCache; import org.dllearner.algorithms.qtl.datastructures.QueryTree; @@ -69,7 +70,7 @@ private Queue<EvaluatedQueryTree<String>> todoList; private SortedSet<EvaluatedQueryTree<String>> currentPartialSolutions; - private double currentlyBestScore = 0d; + private double bestCurrentScore = 0d; private List<QueryTree<String>> currentPosExampleTrees; private List<QueryTree<String>> currentNegExampleTrees; @@ -114,11 +115,17 @@ private double posWeight = 2; // minimum score a query tree must have to be part of the solution private double minimumTreeScore = 0.2; + //If yes, then the algorithm tries to cover all positive examples. Note that while this improves accuracy on the testing set, + //it may lead to overfitting + private boolean tryFullCoverage; + //algorithm will terminate immediately when a correct definition is found + private boolean stopOnFirstDefinition; private long startTime; - private long partialSolutionStartTime; + private double startPosExamplesSize; + public QTL2Disjunctive() {} public QTL2Disjunctive(PosNegLP learningProblem, AbstractReasonerComponent reasoner) throws LearningProblemUnsupportedException{ @@ -156,7 +163,7 @@ if(heuristic == null){ heuristic = new QueryTreeHeuristic(); - heuristic.setPosExamplesWeight(2); + heuristic.setPosExamplesWeight(posWeight); } logger.info("Initializing..."); @@ -168,6 +175,8 @@ currentPosExamples = new TreeSet<Individual>(lp.getPositiveExamples()); currentNegExamples = new TreeSet<Individual>(lp.getNegativeExamples()); + startPosExamplesSize = currentPosExamples.size(); + //get the query trees generateTrees(); @@ -178,6 +187,15 @@ //console rendering of class expressions ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); ToStringRenderer.getInstance().setShortFormProvider(new SimpleShortFormProvider()); + + //compute the LGG for all examples + //this allows us to prune all other trees because we can omit paths in trees which are contained in all positive + //as well as negative examples +// List<QueryTree<String>> allExamplesTrees = new ArrayList<QueryTree<String>>(); +// allExamplesTrees.addAll(currentPosExampleTrees); +// allExamplesTrees.addAll(currentNegExampleTrees); +// QueryTree<String> lgg = lggGenerator.getLGG(allExamplesTrees); +// lgg.dump(); } private void generateTrees(){ @@ -204,7 +222,7 @@ String setup = "Setup:"; setup += "\n#Pos. examples:" + currentPosExamples.size(); setup += "\n#Neg. examples:" + currentNegExamples.size(); - setup += "\nCoverage beta:" + coverageBeta; + setup += "\nPos. weight(beta):" + posWeight; logger.info(setup); logger.info("Running..."); startTime = System.currentTimeMillis(); @@ -268,7 +286,7 @@ private void computeNextPartialSolution(){ logger.info("Computing best partial solution..."); - currentlyBestScore = 0d; + bestCurrentScore = Double.NEGATIVE_INFINITY; partialSolutionStartTime = System.currentTimeMillis(); initTodoList(currentPosExampleTrees, currentNegExampleTrees); @@ -291,14 +309,14 @@ double score = solution.getScore(); double mas = heuristic.getMaximumAchievableScore(solution); - if(score >= currentlyBestScore){ + if(score >= bestCurrentScore){ //add to todo list, if not already contained in todo list or solution list todo(solution); - if(solution.getScore() > currentlyBestScore){ + if(solution.getScore() > bestCurrentScore){ logger.info("Got better solution:" + solution.getTreeScore()); } - currentlyBestScore = solution.getScore(); - } else if(mas < currentlyBestScore){ + bestCurrentScore = solution.getScore(); + } else if(mas < bestCurrentScore){ todo(solution); } else { System.out.println("Too general"); @@ -431,6 +449,8 @@ subMon.reset(); lggMon.reset(); + + bestCurrentScore = minimumTreeScore; } @@ -578,8 +598,31 @@ return tree1.isSubsumedBy(tree2) && tree2.isSubsumedBy(tree1); } - private boolean terminationCriteriaSatisfied(){ - return stop || isTimeExpired() || currentPosExampleTrees.isEmpty(); + private boolean terminationCriteriaSatisfied() { + //stop was called or time expired + if(stop || isTimeExpired()){ + return true; + } + + // stop if there are no more positive examples to cover + if (stopOnFirstDefinition && currentPosExamples.isEmpty()) { + return true; + } + + // we stop when the score of the last tree added is too low + // (indicating that the algorithm could not find anything appropriate + // in the timeframe set) + if (bestCurrentScore < minimumTreeScore) { + return true; + } + + // stop when almost all positive examples have been covered + if (tryFullCoverage) { + return false; + } else { + int maxPosRemaining = (int) Math.ceil(startPosExamplesSize * 0.05d); + return (currentPosExamples.size() <= maxPosRemaining); + } } private boolean partialSolutionTerminationCriteriaSatisfied(){ @@ -635,6 +678,13 @@ this.coverageBeta = coverageBeta; } + /** + * @param posWeight the posWeight to set + */ + public void setPosWeight(double posWeight) { + this.posWeight = posWeight; + } + /* (non-Javadoc) * @see java.lang.Object#clone() */ Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-08 14:39:43 UTC (rev 4264) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-08 14:40:15 UTC (rev 4265) @@ -63,7 +63,7 @@ case FMEASURE : score = Heuristics.getFScore(tp/(tp+fn), tp/(tp+fp), posExamplesWeight);break; case PRED_ACC : - score = (posExamplesWeight * tp + tn) / (posExamplesWeight * (tp + fn) + tn + fp);break; + score = (tp + posExamplesWeight * tn) / ((tp + fn) + posExamplesWeight * (tn + fp));break; case ENTROPY :{ double total = tp + fn; double pp = tp / total; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-08 14:39:43 UTC (rev 4264) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-08 14:40:15 UTC (rev 4265) @@ -161,7 +161,7 @@ label += "Values: " + object.getLiterals(); } } - label += object.isResourceNode() + "," + object.isLiteralNode(); +// label += object.isResourceNode() + "," + object.isLiteralNode(); return label; } }; @@ -801,13 +801,16 @@ writer.println(ren); for (QueryTree<N> child : getChildren()) { Object edge = getEdge(child); - if (edge != null) { + boolean meaningful = !edge.equals(RDF.type.getURI()) || meaningful(child); + if (edge != null && meaningful) { writer.print(sb.toString()); writer.print("--- "); writer.print(edge); writer.print(" ---\n"); } - child.dump(writer, indent); + if(meaningful){ + child.dump(writer, indent); + } } writer.flush(); // int depth = getPathToRoot().size(); @@ -832,6 +835,23 @@ // writer.flush(); } + private boolean meaningful(QueryTree<N> tree){ + if(tree.isResourceNode() || tree.isLiteralNode()){ + return true; + } else { + for (QueryTree<N> child : tree.getChildren()) { + Object edge = tree.getEdge(child); + if(!edge.equals(RDFS.subClassOf.getURI())){ + return true; + } else if(child.isResourceNode()){ + return true; + } else if(meaningful(child)){ + return true; + } + } + } + return false; + } public List<N> fillDepthFirst() { List<N> results = new ArrayList<N>(); Modified: trunk/components-core/src/main/java/org/dllearner/utilities/statistics/Stat.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/statistics/Stat.java 2014-05-08 14:39:43 UTC (rev 4264) +++ trunk/components-core/src/main/java/org/dllearner/utilities/statistics/Stat.java 2014-05-08 14:40:15 UTC (rev 4265) @@ -75,6 +75,14 @@ } } + public void add(Stat stat){ + count += stat.count; + sum += stat.sum; + squareSum += stat.squareSum; + min = Math.min(min, stat.min); + max = Math.max(max, stat.max); + } + /** * Add a number to this object. * Modified: trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-08 14:39:43 UTC (rev 4264) +++ trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-08 14:40:15 UTC (rev 4265) @@ -26,6 +26,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -60,6 +61,7 @@ import org.dllearner.utilities.statistics.Stat; import com.google.common.base.Charsets; +import com.google.common.collect.Lists; import com.google.common.io.Files; /** @@ -100,6 +102,15 @@ public class NestedCrossValidation { private File outputFile = new File("log/nested-cv.log"); + DecimalFormat df = new DecimalFormat(); + + // overall statistics + Stat globalAcc = new Stat(); + Stat globalF = new Stat(); + Stat globalRecall = new Stat(); + Stat globalPrecision = new Stat(); + + Map<Double,Stat> globalParaStats = new HashMap<Double,Stat>(); /** * Entry method, which uses JOptSimple to parse parameters. @@ -115,8 +126,7 @@ OptionParser parser = new OptionParser(); parser.acceptsAll(asList("h", "?", "help"), "Show help."); - parser.acceptsAll(asList("c", "conf"), "Conf file to use.").withRequiredArg().ofType( - File.class); + parser.acceptsAll(asList("c", "conf"), "The comma separated list of conffiles to be used.").withRequiredArg().describedAs("file1, file2, ..."); parser.acceptsAll(asList( "v", "verbose"), "Be more verbose."); parser.acceptsAll(asList( "o", "outerfolds"), "Number of outer folds.").withRequiredArg().ofType(Integer.class).describedAs("#folds"); parser.acceptsAll(asList( "i", "innerfolds"), "Number of inner folds.").withRequiredArg().ofType(Integer.class).describedAs("#folds"); @@ -139,7 +149,12 @@ // all options present => start nested cross validation } else if(options.has("c") && options.has("o") && options.has("i") && options.has("p") && options.has("r")) { // read all options in variables and parse option values - File confFile = (File) options.valueOf("c"); + String confFilesString = (String) options.valueOf("c"); + List<File> confFiles = new ArrayList<File>(); + for (String fileString : confFilesString.split(",")) { + confFiles.add(new File(fileString.trim())); + } + int outerFolds = (Integer) options.valueOf("o"); int innerFolds = (Integer) options.valueOf("i"); String parameter = (String) options.valueOf("p"); @@ -164,7 +179,7 @@ java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.WARNING); System.out.println("Warning: The script is not well tested yet. (No known bugs, but needs more testing.)"); - new NestedCrossValidation(confFile, outerFolds, innerFolds, parameter, rangeStart, rangeEnd, stepsize, verbose); + new NestedCrossValidation(confFiles, outerFolds, innerFolds, parameter, rangeStart, rangeEnd, stepsize, verbose); // an option is missing => print help screen and message } else { @@ -182,16 +197,52 @@ } System.out.println(s); } + + public NestedCrossValidation(File confFile, int outerFolds, int innerFolds, String parameter, double startValue, double endValue, double stepsize, boolean verbose) throws ComponentInitException, ParseException, org.dllearner.confparser.ParseException, IOException { + this(Lists.newArrayList(confFile), outerFolds, innerFolds, parameter, startValue, endValue, stepsize, verbose); + } - public NestedCrossValidation(File confFile, int outerFolds, int innerFolds, String parameter, double startValue, double endValue, double stepsize, boolean verbose) throws ComponentInitException, ParseException, org.dllearner.confparser.ParseException, IOException { + public NestedCrossValidation(List<File> confFiles, int outerFolds, int innerFolds, String parameter, double startValue, double endValue, double stepsize, boolean verbose) throws ComponentInitException, ParseException, org.dllearner.confparser.ParseException, IOException { - DecimalFormat df = new DecimalFormat(); - ComponentManager cm = ComponentManager.getInstance(); + for (File confFile : confFiles) { + print(confFile.getPath()); + validate(confFile, outerFolds, innerFolds, parameter, startValue, endValue, stepsize, verbose); + } + print("********************************************"); + print("********************************************"); + print("********************************************"); + + // decide for the best parameter + print(" Summary over parameter values:"); + double bestPara = startValue; + double bestValue = Double.NEGATIVE_INFINITY; + for (Entry<Double, Stat> entry : globalParaStats.entrySet()) { + double para = entry.getKey(); + Stat stat = entry.getValue(); + print(" value " + para + ": " + stat.prettyPrint("%")); + if (stat.getMean() > bestValue) { + bestPara = para; + bestValue = stat.getMean(); + } + } + print(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); + + // overall statistics + print("*******************"); + print("* Overall Results *"); + print("*******************"); + print("accuracy: " + globalAcc.prettyPrint("%")); + print("F measure: " + globalF.prettyPrint("%")); + print("precision: " + globalPrecision.prettyPrint("%")); + print("recall: " + globalRecall.prettyPrint("%")); + + } + + private void validate(File confFile, int outerFolds, int innerFolds, String parameter, double startValue, double endValue, double stepsize, boolean verbose) throws IOException, ComponentInitException{ CLI start = new CLI(confFile); start.init(); AbstractLearningProblem lp = start.getLearningProblem(); - System.out.println(lp); if(!(lp instanceof PosNegLP)) { System.out.println("Positive only learning not supported yet."); System.exit(0); @@ -213,7 +264,7 @@ Stat accOverall = new Stat(); Stat fOverall = new Stat(); Stat recallOverall = new Stat(); - Stat precisionOverall = new Stat(); + Stat precisionOverall = new Stat(); for(int currOuterFold=0; currOuterFold<outerFolds; currOuterFold++) { @@ -302,11 +353,15 @@ // free memory rs.releaseKB(); - cm.freeAllComponents(); } paraStats.put(currParaValue, paraCriterionStat); - + Stat globalParaStat = globalParaStats.get(currParaValue); + if(globalParaStat == null){ + globalParaStat = new Stat(); + globalParaStats.put(currParaValue, globalParaStat); + } + globalParaStat.add(paraCriterionStat); } // decide for the best parameter @@ -382,9 +437,13 @@ // free memory rs.releaseKB(); - cm.freeAllComponents(); } + globalAcc.add(accOverall); + globalF.add(fOverall); + globalPrecision.add(precisionOverall); + globalRecall.add(recallOverall); + // overall statistics print("*******************"); print("* Overall Results *"); @@ -393,7 +452,6 @@ print("F measure: " + fOverall.prettyPrint("%")); print("precision: " + precisionOverall.prettyPrint("%")); print("recall: " + recallOverall.prettyPrint("%")); - } // convenience methods, which takes a list of examples and divides them in Modified: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-08 14:39:43 UTC (rev 4264) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-08 14:40:15 UTC (rev 4265) @@ -496,13 +496,13 @@ lp.setReasoner(reasoner); lp.init(); QTL2Disjunctive la = new QTL2Disjunctive(lp, reasoner); - la.init(); - la.start(); +// la.init(); +// la.start(); CrossValidation.outputFile = new File("log/qtl-cv.log"); CrossValidation.writeToFile = true; CrossValidation.multiThreaded = multiThreaded; -// CrossValidation cv = new CrossValidation(la, lp, reasoner, nrOfFolds, false); + CrossValidation cv = new CrossValidation(la, lp, reasoner, nrOfFolds, false); long endTime = System.currentTimeMillis(); System.err.println((endTime - startTime) + "ms"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-08 14:39:47
|
Revision: 4264 http://sourceforge.net/p/dl-learner/code/4264 Author: lorenz_b Date: 2014-05-08 14:39:43 +0000 (Thu, 08 May 2014) Log Message: ----------- Added QTL examples. Modified Paths: -------------- trunk/test/qtl/mutagenesis/train1.conf Added Paths: ----------- trunk/test/qtl/alzheimer/ trunk/test/qtl/alzheimer/alzheimer.owl trunk/test/qtl/alzheimer/prolog/ trunk/test/qtl/alzheimer/prolog/amine_uptake/ trunk/test/qtl/alzheimer/prolog/amine_uptake/d_alz_ne.b trunk/test/qtl/alzheimer/prolog/amine_uptake/ne.f trunk/test/qtl/alzheimer/prolog/amine_uptake/ne.n trunk/test/qtl/alzheimer/prolog/choline/ trunk/test/qtl/alzheimer/prolog/choline/d_alz_inh.b trunk/test/qtl/alzheimer/prolog/choline/inh.f trunk/test/qtl/alzheimer/prolog/choline/inh.n trunk/test/qtl/alzheimer/prolog/d_alz.b trunk/test/qtl/alzheimer/prolog/nd_alz.b trunk/test/qtl/alzheimer/prolog/scopolamine/ trunk/test/qtl/alzheimer/prolog/scopolamine/d_alz_rsd.b trunk/test/qtl/alzheimer/prolog/scopolamine/rsd.f trunk/test/qtl/alzheimer/prolog/scopolamine/rsd.n trunk/test/qtl/alzheimer/prolog/toxic/ trunk/test/qtl/alzheimer/prolog/toxic/d_alz_toxic.b trunk/test/qtl/alzheimer/prolog/toxic/toxic.f trunk/test/qtl/alzheimer/prolog/toxic/toxic.n trunk/test/qtl/alzheimer/train1.conf trunk/test/qtl/alzheimer/train2.conf trunk/test/qtl/alzheimer/train3.conf trunk/test/qtl/alzheimer/train4.conf trunk/test/qtl/breasttissue/ trunk/test/qtl/breasttissue/breasttissue.owl trunk/test/qtl/breasttissue/files/ trunk/test/qtl/breasttissue/files/breasttissue.txt trunk/test/qtl/breasttissue/train1.conf trunk/test/qtl/breasttissue/train2.conf trunk/test/qtl/breasttissue/train3.conf trunk/test/qtl/breasttissue/train4.conf trunk/test/qtl/breasttissue/train5.conf trunk/test/qtl/breasttissue/train6.conf trunk/test/qtl/breasttissue/train7.conf trunk/test/qtl/cardiotocography/ trunk/test/qtl/cardiotocography/cardiotocography.zip trunk/test/qtl/cardiotocography/files/ trunk/test/qtl/cardiotocography/files/cardiotocography.txt trunk/test/qtl/cardiotocography/train1.conf trunk/test/qtl/cardiotocography/train10.conf trunk/test/qtl/cardiotocography/train11.conf trunk/test/qtl/cardiotocography/train12.conf trunk/test/qtl/cardiotocography/train13.conf trunk/test/qtl/cardiotocography/train2.conf trunk/test/qtl/cardiotocography/train3.conf trunk/test/qtl/cardiotocography/train4.conf trunk/test/qtl/cardiotocography/train5.conf trunk/test/qtl/cardiotocography/train6.conf trunk/test/qtl/cardiotocography/train7.conf trunk/test/qtl/cardiotocography/train8.conf trunk/test/qtl/cardiotocography/train9.conf trunk/test/qtl/parkinsons/ trunk/test/qtl/parkinsons/files/ trunk/test/qtl/parkinsons/parkinsons.data trunk/test/qtl/parkinsons/parkinsons.owl trunk/test/qtl/parkinsons/train.conf trunk/test/qtl/suramin/ trunk/test/qtl/suramin/catalog.xml trunk/test/qtl/suramin/prolog/ trunk/test/qtl/suramin/prolog/suramin.pl trunk/test/qtl/suramin/suramin.owl trunk/test/qtl/suramin/train.conf Added: trunk/test/qtl/alzheimer/alzheimer.owl =================================================================== --- trunk/test/qtl/alzheimer/alzheimer.owl (rev 0) +++ trunk/test/qtl/alzheimer/alzheimer.owl 2014-05-08 14:39:43 UTC (rev 4264) @@ -0,0 +1,2285 @@ +<?xml version="1.0"?> +<rdf:RDF xmlns="http://dl-learner.org/alzheimer#" + xml:base="http://dl-learner.org/alzheimer" + xmlns:alzheimer="http://dl-learner.org/alzheimer#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:CH2="http://dl-learner.org/alzheimer#CH2–" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <owl:Ontology rdf:about="http://dl-learner.org/alzheimer"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Object Properties + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/alzheimer#getsNrOfReplacementsInMiddleRing --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsNrOfReplacementsInMiddleRing"/> + + + + <!-- http://dl-learner.org/alzheimer#getsReplacedAtPosition --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsReplacedAtPosition"/> + + + + <!-- http://dl-learner.org/alzheimer#getsReplacedBy --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsReplacedBy"/> + + + + <!-- http://dl-learner.org/alzheimer#getsReplacedByFirst --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsReplacedByFirst"/> + + + + <!-- http://dl-learner.org/alzheimer#getsReplacedBySecond --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsReplacedBySecond"/> + + + + <!-- http://dl-learner.org/alzheimer#getsReplacedByThird --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsReplacedByThird"/> + + + + <!-- http://dl-learner.org/alzheimer#getsReplacedWith --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsReplacedWith"/> + + + + <!-- http://dl-learner.org/alzheimer#getsRingReplacedAtPosition --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsRingReplacedAtPosition"/> + + + + <!-- http://dl-learner.org/alzheimer#getsRingReplacementAt --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#getsRingReplacementAt"/> + + + + <!-- http://dl-learner.org/alzheimer#hasFlex --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#hasFlex"/> + + + + <!-- http://dl-learner.org/alzheimer#hasNrOfAlkylSubstitutions --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#hasNrOfAlkylSubstitutions"/> + + + + <!-- http://dl-learner.org/alzheimer#hasPolatisation --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#hasPolatisation"/> + + + + <!-- http://dl-learner.org/alzheimer#hasRingStructure --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#hasRingStructure"/> + + + + <!-- http://dl-learner.org/alzheimer#hasSigma --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#hasSigma"/> + + + + <!-- http://dl-learner.org/alzheimer#hasSize --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#hasSize"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreater --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreater"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterFlex --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterFlex"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterHAcceptor --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterHAcceptor"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterHDonor --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterHDonor"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterPiAcceptor --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterPiAcceptor"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterPiDonor --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterPiDonor"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterPolar --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterPolar"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterSigma --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterSigma"/> + + + + <!-- http://dl-learner.org/alzheimer#isGreaterSize --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isGreaterSize"/> + + + + <!-- http://dl-learner.org/alzheimer#isHAcceptor --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isHAcceptor"/> + + + + <!-- http://dl-learner.org/alzheimer#isHDoner --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isHDoner"/> + + + + <!-- http://dl-learner.org/alzheimer#isPiAcceptor --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isPiAcceptor"/> + + + + <!-- http://dl-learner.org/alzheimer#isPiDoner --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isPiDoner"/> + + + + <!-- http://dl-learner.org/alzheimer#isPolarisable --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#isPolarisable"/> + + + + <!-- http://dl-learner.org/alzheimer#nrOfSubstitutionsInRing --> + + <owl:ObjectProperty rdf:about="http://dl-learner.org/alzheimer#nrOfSubstitutionsInRing"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Classes + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/alzheimer#Drug --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#Drug"/> + + + + <!-- http://dl-learner.org/alzheimer#Flex --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#Flex"/> + + + + <!-- http://dl-learner.org/alzheimer#HAcceptor --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#HAcceptor"/> + + + + <!-- http://dl-learner.org/alzheimer#HDonor --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#HDonor"/> + + + + <!-- http://dl-learner.org/alzheimer#PiAcceptor --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#PiAcceptor"/> + + + + <!-- http://dl-learner.org/alzheimer#PiDonor --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#PiDonor"/> + + + + <!-- http://dl-learner.org/alzheimer#Polar --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#Polar"/> + + + + <!-- http://dl-learner.org/alzheimer#Sigma --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#Sigma"/> + + + + <!-- http://dl-learner.org/alzheimer#Size --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#Size"/> + + + + <!-- http://dl-learner.org/alzheimer#Substituent --> + + <owl:Class rdf:about="http://dl-learner.org/alzheimer#Substituent"/> + + + + <!-- + /////////////////////////////////////////////////////////////////////////////////////// + // + // Individuals + // + /////////////////////////////////////////////////////////////////////////////////////// + --> + + + + + <!-- http://dl-learner.org/alzheimer#(Aromatic-Ring)2 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#(Aromatic-Ring)2"/> + + + + <!-- http://dl-learner.org/alzheimer#(CH3)2 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#(CH3)2"/> + + + + <!-- http://dl-learner.org/alzheimer#(CH3)3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#(CH3)3"/> + + + + <!-- http://dl-learner.org/alzheimer#0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#0"/> + + + + <!-- http://dl-learner.org/alzheimer#1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#1"> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#0"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#2 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#2"> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#0"/> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#3"> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#0"/> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#1"/> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#2"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#4 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#4"> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#0"/> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#1"/> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#2"/> + <isGreater rdf:resource="http://dl-learner.org/alzheimer#3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#5 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#5"/> + + + + <!-- http://dl-learner.org/alzheimer#6 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#6"/> + + + + <!-- http://dl-learner.org/alzheimer#7 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#7"/> + + + + <!-- http://dl-learner.org/alzheimer#Aromatic-Ring --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + + + + <!-- http://dl-learner.org/alzheimer#CH2–CH3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#CH2–CH3"/> + + + + <!-- http://dl-learner.org/alzheimer#CH3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#CH3"/> + + + + <!-- http://dl-learner.org/alzheimer#N(CH3)2 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#N(CH3)2"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Substituent"/> + <hasFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isHDoner rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isPiAcceptor rdf:resource="http://dl-learner.org/alzheimer#pi_acc0"/> + <isPiDoner rdf:resource="http://dl-learner.org/alzheimer#pi_don2"/> + <hasPolatisation rdf:resource="http://dl-learner.org/alzheimer#polar1"/> + <isPolarisable rdf:resource="http://dl-learner.org/alzheimer#polari1"/> + <hasSigma rdf:resource="http://dl-learner.org/alzheimer#sigma1"/> + <hasSize rdf:resource="http://dl-learner.org/alzheimer#size2"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#a1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#a1"> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#h"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#aa1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#aa1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#3"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#3"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedWith rdf:resource="http://dl-learner.org/alzheimer#ch3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#ch3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#b1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#b1"> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#7"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cl"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#h"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#bb1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#bb1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#ch3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#c1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#c1"> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cl"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#h"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#cc1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#cc1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedWith rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#cf3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#cf3"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Substituent"/> + <hasFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isHDoner rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isPiAcceptor rdf:resource="http://dl-learner.org/alzheimer#pi_acc0"/> + <isPiDoner rdf:resource="http://dl-learner.org/alzheimer#pi_don0"/> + <hasPolatisation rdf:resource="http://dl-learner.org/alzheimer#polar3"/> + <isPolarisable rdf:resource="http://dl-learner.org/alzheimer#polari0"/> + <hasSigma rdf:resource="http://dl-learner.org/alzheimer#sigma3"/> + <hasSize rdf:resource="http://dl-learner.org/alzheimer#size1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#ch3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#ch3"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Substituent"/> + <hasFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isHDoner rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isPiAcceptor rdf:resource="http://dl-learner.org/alzheimer#pi_acc0"/> + <isPiDoner rdf:resource="http://dl-learner.org/alzheimer#pi_don0"/> + <hasPolatisation rdf:resource="http://dl-learner.org/alzheimer#polar0"/> + <isPolarisable rdf:resource="http://dl-learner.org/alzheimer#polari1"/> + <hasSigma rdf:resource="http://dl-learner.org/alzheimer#sigma0"/> + <hasSize rdf:resource="http://dl-learner.org/alzheimer#size1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#cl --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#cl"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Substituent"/> + <hasFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isHDoner rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isPiAcceptor rdf:resource="http://dl-learner.org/alzheimer#pi_acc0"/> + <isPiDoner rdf:resource="http://dl-learner.org/alzheimer#pi_don0"/> + <hasPolatisation rdf:resource="http://dl-learner.org/alzheimer#polar3"/> + <isPolarisable rdf:resource="http://dl-learner.org/alzheimer#polari1"/> + <hasSigma rdf:resource="http://dl-learner.org/alzheimer#sigma3"/> + <hasSize rdf:resource="http://dl-learner.org/alzheimer#size1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#d1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#d1"> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#och3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#dd1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#dd1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#3"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + <getsReplacedWith rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#e1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#e1"> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#h"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#ee1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#ee1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + <getsReplacedWith rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#f --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#f"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Substituent"/> + <hasFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isHDoner rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isPiAcceptor rdf:resource="http://dl-learner.org/alzheimer#pi_acc0"/> + <isPiDoner rdf:resource="http://dl-learner.org/alzheimer#pi_don0"/> + <hasPolatisation rdf:resource="http://dl-learner.org/alzheimer#polar5"/> + <isPolarisable rdf:resource="http://dl-learner.org/alzheimer#polari0"/> + <hasSigma rdf:resource="http://dl-learner.org/alzheimer#sigma5"/> + <hasSize rdf:resource="http://dl-learner.org/alzheimer#size1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#f1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#f1"> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#f"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#h"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#ff1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#ff1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#3"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#3"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#5"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#5"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#5"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#f"/> + <getsReplacedWith rdf:resource="http://dl-learner.org/alzheimer#f"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex0"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex2 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex2"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex3"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex2"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex4 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex4"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex2"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex5 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex5"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex2"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex3"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex4"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex6 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex6"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex2"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex3"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex4"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex5"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex7 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex7"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex2"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex3"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex4"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex5"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex6"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex8 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex8"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex2"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex3"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex4"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex5"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex6"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex7"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#flex9 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#flex9"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Flex"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex0"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex1"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex2"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex3"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex4"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex5"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex6"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex7"/> + <isGreaterFlex rdf:resource="http://dl-learner.org/alzheimer#flex8"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#g1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#g1"> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#h"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#h"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h"/> + + + + <!-- http://dl-learner.org/alzheimer#h1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h1"> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc0"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc2 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc2"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc3"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc2"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc4 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc4"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc2"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc5 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc5"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc2"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc3"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc4"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc6 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc6"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc2"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc3"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc4"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc5"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc7 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc7"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc2"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc3"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc4"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc5"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc6"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc8 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc8"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc2"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc3"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc4"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc5"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc6"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc7"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_acc9 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_acc9"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HAcceptor"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc0"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc1"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc2"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc3"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc4"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc5"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc6"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc7"/> + <isGreaterHAcceptor rdf:resource="http://dl-learner.org/alzheimer#h_acc8"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don0 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don0"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don2 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don2"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don3 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don3"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don2"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don4 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don4"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don2"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don5 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don5"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don2"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don3"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don4"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don6 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don6"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don2"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don3"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don4"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don5"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don7 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don7"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don2"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don3"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don4"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don5"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don6"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don8 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don8"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don2"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don3"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don4"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don5"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don6"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don7"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#h_don9 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#h_don9"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#HDonor"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don0"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don1"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don2"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don3"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don4"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don5"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don6"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don7"/> + <isGreaterHDonor rdf:resource="http://dl-learner.org/alzheimer#h_don8"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#hh1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#hh1"> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cl"/> + <hasRingStructure rdf:resource="http://dl-learner.org/alzheimer#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#i1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#i1"> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#(CH3)3"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#(CH3)3"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#3"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#ii1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#ii1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#4"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cl"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#f"/> + <getsReplacedWith rdf:resource="http://dl-learner.org/alzheimer#f"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#j1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#j1"> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#(CH3)2"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#(CH3)2"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#N(CH3)2"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#N(CH3)2"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#jj1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#jj1"> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#f"/> + <hasRingStructure rdf:resource="http://dl-learner.org/alzheimer#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#k1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#k1"> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#(CH3)2"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#(CH3)2"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <hasRingStructure rdf:resource="http://dl-learner.org/alzheimer#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#kk1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#kk1"> + <rdf:type rdf:resource="http://dl-learner.org/alzheimer#Drug"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacementAt rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsRingReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedWith rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#f"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#l1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#l1"> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#(CH3)3"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#(CH3)3"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#3"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#3"/> + <getsReplacedByThird rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <hasRingStructure rdf:resource="http://dl-learner.org/alzheimer#normal"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#o"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#o"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#ll1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#ll1"> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#0"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsReplacedAtPosition rdf:resource="http://dl-learner.org/alzheimer#6"/> + <getsReplacedBySecond rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#Aromatic-Ring"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#CH3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#cf3"/> + <hasRingStructure rdf:resource="http://dl-learner.org/alzheimer#normal"/> + </owl:NamedIndividual> + + + + <!-- http://dl-learner.org/alzheimer#m1 --> + + <owl:NamedIndividual rdf:about="http://dl-learner.org/alzheimer#m1"> + <getsReplacedByThird rdf:resource="http://dl-learner.org/alzheimer#(Aromatic-Ring)2"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#(Aromatic-Ring)2"/> + <getsReplacedByFirst rdf:resource="http://dl-learner.org/alzheimer#(CH3)3"/> + <getsReplacedBy rdf:resource="http://dl-learner.org/alzheimer#(CH3)3"/> + <nrOfSubstitutionsInRing rdf:resource="http://dl-learner.org/alzheimer#0"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#1"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#2"/> + <getsNrOfReplacementsInMiddleRing rdf:resource="http://dl-learner.org/alzheimer#3"/> + <hasNrOfAlkylSubstitutions rdf:resource="http://dl-learner.org/alzheimer#4"... [truncated message content] |
From: <lor...@us...> - 2014-05-08 11:45:49
|
Revision: 4263 http://sourceforge.net/p/dl-learner/code/4263 Author: lorenz_b Date: 2014-05-08 11:45:45 +0000 (Thu, 08 May 2014) Log Message: ----------- Added more termination criteria for QTL algorithm. Added heuristics for tree score. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java trunk/components-core/src/main/java/org/dllearner/learningproblems/Heuristics.java trunk/components-core/src/main/java/org/dllearner/learningproblems/QueryTreeScore.java trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-07 13:43:54 UTC (rev 4262) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-08 11:45:45 UTC (rev 4263) @@ -2,6 +2,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -61,6 +62,7 @@ private static final Logger logger = Logger.getLogger(QTL2Disjunctive.class.getName()); + private final DecimalFormat df = new DecimalFormat("0.00"); private LGGGenerator<String> lggGenerator; @@ -92,21 +94,31 @@ private EvaluatedDescription currentBestSolution; + private QueryTreeHeuristic heuristic; //Parameters @ConfigOption(name = "noisePercentage", defaultValue="0.0", description="the (approximated) percentage of noise within the examples") private double noisePercentage = 0.0; @ConfigOption(defaultValue = "10", name = "maxExecutionTimeInSeconds", description = "maximum execution of the algorithm in seconds") - private int maxExecutionTimeInSeconds = 10; - private double minimumTreeScore = 0.2; + private int maxExecutionTimeInSeconds = -1; + private double coverageWeight = 0.8; private double specifityWeight = 0.1; - private double noise = 0.3; - private double coverageBeta = 0.7; + private double coverageBeta = 0.5; - private double posExampleWeight = 1; + private double minCoveredPosExamplesFraction = 0.2; + // maximum execution time to compute a part of the solution + private double maxTreeComputationTimeInSeconds = 60; + // how important not to cover negatives + private double posWeight = 2; + // minimum score a query tree must have to be part of the solution + private double minimumTreeScore = 0.2; + private long startTime; + + private long partialSolutionStartTime; + public QTL2Disjunctive() {} public QTL2Disjunctive(PosNegLP learningProblem, AbstractReasonerComponent reasoner) throws LearningProblemUnsupportedException{ @@ -142,6 +154,11 @@ lggGenerator = new LGGGeneratorImpl<String>(); + if(heuristic == null){ + heuristic = new QueryTreeHeuristic(); + heuristic.setPosExamplesWeight(2); + } + logger.info("Initializing..."); treeCache = new QueryTreeCache(model); tree2Individual = new HashMap<QueryTree<String>, Individual>(lp.getPositiveExamples().size()+lp.getNegativeExamples().size()); @@ -164,6 +181,7 @@ } private void generateTrees(){ + logger.info("Generating trees..."); QueryTree<String> queryTree; for (Individual ind : lp.getPositiveExamples()) { queryTree = treeCache.getQueryTree(ind.getName()); @@ -175,6 +193,7 @@ tree2Individual.put(queryTree, ind); currentNegExampleTrees.add(queryTree); } + logger.info("...done."); } /* (non-Javadoc) @@ -183,46 +202,59 @@ @Override public void start() { String setup = "Setup:"; - setup += "#Pos. examples:" + currentPosExamples.size(); - setup += "#Neg. examples:" + currentNegExamples.size(); - setup += "Coverage beta:" + coverageBeta; + setup += "\n#Pos. examples:" + currentPosExamples.size(); + setup += "\n#Neg. examples:" + currentNegExamples.size(); + setup += "\nCoverage beta:" + coverageBeta; logger.info(setup); logger.info("Running..."); - long startTime = System.currentTimeMillis(); + startTime = System.currentTimeMillis(); reset(); int i = 1; - do { + while(!terminationCriteriaSatisfied()){ logger.info(i++ + ". iteration..."); logger.info("#Remaining pos. examples:" + currentPosExampleTrees.size()); logger.info("#Remaining neg. examples:" + currentNegExampleTrees.size()); - //compute LGG - computeLGG(); + //compute a (partial) solution + computeNextPartialSolution(); //pick best (partial) solution computed so far EvaluatedQueryTree<String> bestPartialSolution = currentPartialSolutions.first(); - partialSolutions.add(bestPartialSolution); - //remove all covered examples - QueryTree<String> tree; - for (Iterator<QueryTree<String>> iterator = currentPosExampleTrees.iterator(); iterator.hasNext();) { - tree = iterator.next(); - if(tree.isSubsumedBy(bestPartialSolution.getTree())){ - iterator.remove(); - currentPosExamples.remove(tree2Individual.get(tree)); + //add if some criteria are satisfied + if(bestPartialSolution.getScore() >= minimumTreeScore){ + + partialSolutions.add(bestPartialSolution); + + //remove all covered examples + QueryTree<String> tree; + for (Iterator<QueryTree<String>> iterator = currentPosExampleTrees.iterator(); iterator.hasNext();) { + tree = iterator.next(); + if(tree.isSubsumedBy(bestPartialSolution.getTree())){ + iterator.remove(); + currentPosExamples.remove(tree2Individual.get(tree)); + } } - } - for (Iterator<QueryTree<String>> iterator = currentNegExampleTrees.iterator(); iterator.hasNext();) { - tree = iterator.next(); - if(tree.isSubsumedBy(bestPartialSolution.getTree())){ - iterator.remove(); - currentNegExamples.remove(tree2Individual.get(tree)); + for (Iterator<QueryTree<String>> iterator = currentNegExampleTrees.iterator(); iterator.hasNext();) { + tree = iterator.next(); + if(tree.isSubsumedBy(bestPartialSolution.getTree())){ + iterator.remove(); + currentNegExamples.remove(tree2Individual.get(tree)); + } } + //build the current combined solution + currentBestSolution = buildCombinedSolution(); + + logger.info("combined accuracy: " + df.format(currentBestSolution.getAccuracy())); + } else { + logger.info("no tree found, which satisfies the minimum criteria - the best was: " + + currentBestSolution.getDescription().toManchesterSyntaxString(baseURI, prefixes) + + " with score " + currentBestSolution.getScore()); } - currentBestSolution = buildCombinedSolution(); - } while (!(stop || currentPosExampleTrees.isEmpty())); + + }; isRunning = false; @@ -234,6 +266,119 @@ } + private void computeNextPartialSolution(){ + logger.info("Computing best partial solution..."); + currentlyBestScore = 0d; + partialSolutionStartTime = System.currentTimeMillis(); + initTodoList(currentPosExampleTrees, currentNegExampleTrees); + + EvaluatedQueryTree<String> currentElement; + while(!partialSolutionTerminationCriteriaSatisfied()){ + logger.trace("TODO list size: " + todoList.size()); + //pick best element from todo list + currentElement = todoList.poll(); + //generate the LGG between the chosen tree and each uncovered positive example + for (QueryTree<String> example : currentElement.getFalseNegatives()) { + QueryTree<String> tree = currentElement.getTree(); + + //compute the LGG + lggMon.start(); + QueryTree<String> lgg = lggGenerator.getLGG(tree, example); + lggMon.stop(); + + //evaluate the LGG + EvaluatedQueryTree<String> solution = evaluate(lgg, true); + double score = solution.getScore(); + double mas = heuristic.getMaximumAchievableScore(solution); + + if(score >= currentlyBestScore){ + //add to todo list, if not already contained in todo list or solution list + todo(solution); + if(solution.getScore() > currentlyBestScore){ + logger.info("Got better solution:" + solution.getTreeScore()); + } + currentlyBestScore = solution.getScore(); + } else if(mas < currentlyBestScore){ + todo(solution); + } else { + System.out.println("Too general"); + } + currentPartialSolutions.add(currentElement); + + } + currentPartialSolutions.add(currentElement); + } + long endTime = System.currentTimeMillis(); + logger.info("...finished in " + (endTime-partialSolutionStartTime) + "ms."); + EvaluatedDescription bestPartialSolution = currentPartialSolutions.first().asEvaluatedDescription(); + + logger.info("Best partial solution:\n" + OWLAPIConverter.getOWLAPIDescription(bestPartialSolution.getDescription()) + "\n(" + bestPartialSolution.getScore() + ")"); + + logger.trace("LGG time: " + lggMon.getTotal() + "ms"); + logger.trace("Avg. LGG time: " + lggMon.getAvg() + "ms"); + logger.info("#LGG computations: " + lggMon.getHits()); + logger.trace("Subsumption test time: " + subMon.getTotal() + "ms"); + logger.trace("Avg. subsumption test time: " + subMon.getAvg() + "ms"); + logger.trace("#Subsumption tests: " + subMon.getHits()); + } + + private EvaluatedQueryTree<String> evaluate(QueryTree<String> tree, boolean useSpecifity){ + //1. get a score for the coverage = recall oriented + //compute positive examples which are not covered by LGG + List<QueryTree<String>> uncoveredPositiveExampleTrees = getUncoveredTrees(tree, currentPosExampleTrees); + Set<Individual> uncoveredPosExamples = new TreeSet<Individual>(); + for (QueryTree<String> queryTree : uncoveredPositiveExampleTrees) { + uncoveredPosExamples.add(tree2Individual.get(queryTree)); + } + //compute negative examples which are covered by LGG + Collection<QueryTree<String>> coveredNegativeExampleTrees = getCoveredTrees(tree, currentNegExampleTrees); + Set<Individual> coveredNegExamples = new TreeSet<Individual>(); + for (QueryTree<String> queryTree : coveredNegativeExampleTrees) { + coveredNegExamples.add(tree2Individual.get(queryTree)); + } + //compute score + int coveredPositiveExamples = currentPosExampleTrees.size() - uncoveredPositiveExampleTrees.size(); + double recall = coveredPositiveExamples / (double)currentPosExampleTrees.size(); + double precision = (coveredNegativeExampleTrees.size() + coveredPositiveExamples == 0) + ? 0 + : coveredPositiveExamples / (double)(coveredPositiveExamples + coveredNegativeExampleTrees.size()); + + double coverageScore = Heuristics.getFScore(recall, precision, coverageBeta); + + //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented + int nrOfSpecificNodes = 0; + for (QueryTree<String> childNode : tree.getChildrenClosure()) { + if(!childNode.getUserObject().equals("?")){ + nrOfSpecificNodes++; + } + } + double specifityScore = 0d; + if(useSpecifity){ + specifityScore = Math.log(nrOfSpecificNodes); + } + + //3.compute the total score + double score = coverageWeight * coverageScore + specifityWeight * specifityScore; + + QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, + new TreeSet<Individual>(Sets.difference(currentPosExamples, uncoveredPosExamples)), uncoveredPosExamples, + coveredNegExamples, new TreeSet<Individual>(Sets.difference(currentNegExamples, coveredNegExamples)), + specifityScore, nrOfSpecificNodes); + +// QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, +// null,null,null,null, +// specifityScore, nrOfSpecificNodes); + + EvaluatedQueryTree<String> evaluatedTree = new EvaluatedQueryTree<String>(tree, uncoveredPositiveExampleTrees, coveredNegativeExampleTrees, queryTreeScore); + + //TODO use only the heuristic to compute the score + score = heuristic.getScore(evaluatedTree); + queryTreeScore.setScore(score); + queryTreeScore.setAccuracy(score); + + return evaluatedTree; + } + private EvaluatedDescription buildCombinedSolution(){ if(partialSolutions.size() == 1){ EvaluatedDescription combinedSolution = partialSolutions.get(0).asEvaluatedDescription(); @@ -288,58 +433,8 @@ lggMon.reset(); } - private void computeLGG(){ - logger.info("Computing best partial solution..."); - currentlyBestScore = 0d; - - initTodoList(currentPosExampleTrees, currentNegExampleTrees); - - long startTime = System.currentTimeMillis(); - EvaluatedQueryTree<String> currentElement; - do{ - logger.trace("TODO list size: " + todoList.size()); - //pick best element from todo list - currentElement = todoList.poll(); - //generate the LGG between the chosen tree and each uncovered positive example - for (QueryTree<String> example : currentElement.getFalseNegatives()) { - QueryTree<String> tree = currentElement.getTree(); - - //compute the LGG - lggMon.start(); - QueryTree<String> lgg = lggGenerator.getLGG(tree, example); - lggMon.stop(); - - //evaluate the LGG - EvaluatedQueryTree<String> solution = evaluate(lgg, true); - - if(solution.getScore() >= currentlyBestScore){ - //add to todo list, if not already contained in todo list or solution list - todo(solution); - if(solution.getScore() > currentlyBestScore){ - logger.info("Got better solution:" + solution.getTreeScore()); - } - currentlyBestScore = solution.getScore(); - } - currentPartialSolutions.add(currentElement); - - } - currentPartialSolutions.add(currentElement); -// todoList.remove(currentElement); - } while(!terminationCriteriaSatisfied()); - long endTime = System.currentTimeMillis(); - logger.info("...finished in " + (endTime-startTime) + "ms."); - EvaluatedDescription bestPartialSolution = currentPartialSolutions.first().asEvaluatedDescription(); - - logger.info("Best partial solution:\n" + OWLAPIConverter.getOWLAPIDescription(bestPartialSolution.getDescription()) + "\n(" + bestPartialSolution.getScore() + ")"); - - logger.trace("LGG time: " + lggMon.getTotal() + "ms"); - logger.trace("Avg. LGG time: " + lggMon.getAvg() + "ms"); - logger.trace("#LGG computations: " + lggMon.getHits()); - logger.trace("Subsumption test time: " + subMon.getTotal() + "ms"); - logger.trace("Avg. subsumption test time: " + subMon.getAvg() + "ms"); - logger.trace("#Subsumption tests: " + subMon.getHits()); - } + /* (non-Javadoc) * @see org.dllearner.core.StoppableLearningAlgorithm#stop() */ @@ -411,58 +506,7 @@ return treeCache; } - private EvaluatedQueryTree<String> evaluate(QueryTree<String> tree, boolean useSpecifity){ - //1. get a score for the coverage = recall oriented - //compute positive examples which are not covered by LGG - List<QueryTree<String>> uncoveredPositiveExampleTrees = getUncoveredTrees(tree, currentPosExampleTrees); - Set<Individual> uncoveredPosExamples = new TreeSet<Individual>(); - for (QueryTree<String> queryTree : uncoveredPositiveExampleTrees) { - uncoveredPosExamples.add(tree2Individual.get(queryTree)); - } - //compute negative examples which are covered by LGG - Collection<QueryTree<String>> coveredNegativeExampleTrees = getCoveredTrees(tree, currentNegExampleTrees); - Set<Individual> coveredNegExamples = new TreeSet<Individual>(); - for (QueryTree<String> queryTree : coveredNegativeExampleTrees) { - coveredNegExamples.add(tree2Individual.get(queryTree)); - } - //compute score - int coveredPositiveExamples = currentPosExampleTrees.size() - uncoveredPositiveExampleTrees.size(); - double recall = coveredPositiveExamples / (double)currentPosExampleTrees.size(); - double precision = (coveredNegativeExampleTrees.size() + coveredPositiveExamples == 0) - ? 0 - : coveredPositiveExamples / (double)(coveredPositiveExamples + coveredNegativeExampleTrees.size()); - - double beta = 0.5; - double coverageScore = Heuristics.getFScore(recall, precision, beta); - - //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented - int nrOfSpecificNodes = 0; - for (QueryTree<String> childNode : tree.getChildrenClosure()) { - if(!childNode.getUserObject().equals("?")){ - nrOfSpecificNodes++; - } - } - double specifityScore = 0d; - if(useSpecifity){ - specifityScore = Math.log(nrOfSpecificNodes); - } - - //3.compute the total score - double score = coverageWeight * coverageScore + specifityWeight * specifityScore; - - QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, - new TreeSet<Individual>(Sets.difference(currentPosExamples, uncoveredPosExamples)), uncoveredPosExamples, - coveredNegExamples, new TreeSet<Individual>(Sets.difference(currentNegExamples, coveredNegExamples)), - specifityScore, nrOfSpecificNodes); - -// QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, -// null,null,null,null, -// specifityScore, nrOfSpecificNodes); - - EvaluatedQueryTree<String> evaluatedTree = new EvaluatedQueryTree<String>(tree, uncoveredPositiveExampleTrees, coveredNegativeExampleTrees, queryTreeScore); - - return evaluatedTree; - } + /** * Return all trees from the given list {@code allTrees} which are not already subsumed by {@code tree}. @@ -535,9 +579,21 @@ } private boolean terminationCriteriaSatisfied(){ - return stop || todoList.isEmpty() || currentPosExampleTrees.isEmpty(); + return stop || isTimeExpired() || currentPosExampleTrees.isEmpty(); } + private boolean partialSolutionTerminationCriteriaSatisfied(){ + return stop || todoList.isEmpty() || currentPosExampleTrees.isEmpty() || isPartialSolutionTimeExpired() || isTimeExpired(); + } + + private boolean isTimeExpired(){ + return maxExecutionTimeInSeconds <= 0 ? false : (System.currentTimeMillis() - startTime)/1000d >= maxExecutionTimeInSeconds; + } + + private boolean isPartialSolutionTimeExpired(){ + return maxTreeComputationTimeInSeconds <= 0 ? false : (System.currentTimeMillis() - partialSolutionStartTime)/1000d >= maxTreeComputationTimeInSeconds; + } + /** * Add tree to todo list if not already contained in that list or the solutions. * @param solution Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-07 13:43:54 UTC (rev 4262) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-08 11:45:45 UTC (rev 4263) @@ -13,6 +13,7 @@ import org.dllearner.core.Heuristic; import org.dllearner.core.owl.Individual; import org.dllearner.learningproblems.Heuristics; +import org.dllearner.learningproblems.Heuristics.HeuristicType; import org.dllearner.learningproblems.QueryTreeScore; import org.dllearner.utilities.owl.ConceptComparator; @@ -23,6 +24,8 @@ @ComponentAnn(name = "QueryTreeHeuristic", shortName = "qtree_heuristic", version = 0.1) public class QueryTreeHeuristic extends AbstractComponent implements Heuristic, Comparator<EvaluatedQueryTree<String>>{ + private HeuristicType heuristicType = HeuristicType.PRED_ACC; + // F score beta value private double coverageBeta = 1; @@ -30,6 +33,8 @@ private double specifityWeight = 0.1; + private double posExamplesWeight = 1; + // syntactic comparison as final comparison criterion private ConceptComparator conceptComparator = new ConceptComparator(); @@ -43,23 +48,88 @@ public double getScore(EvaluatedQueryTree<String> tree){ QueryTreeScore treeScore = tree.getTreeScore(); - //TODO - double score = treeScore.getScore(); + Set<Individual> truePositives = treeScore.getCoveredPositives(); + Set<Individual> trueNegatives = treeScore.getNotCoveredNegatives(); + Set<Individual> falsePositives = treeScore.getNotCoveredPositives(); + Set<Individual> falseNegatives = treeScore.getCoveredNegatives(); + double tp = truePositives.size(); + double tn = trueNegatives.size(); + double fp = falsePositives.size(); + double fn = falseNegatives.size(); + + double score = 0; + switch(heuristicType){ + case FMEASURE : + score = Heuristics.getFScore(tp/(tp+fn), tp/(tp+fp), posExamplesWeight);break; + case PRED_ACC : + score = (posExamplesWeight * tp + tn) / (posExamplesWeight * (tp + fn) + tn + fp);break; + case ENTROPY :{ + double total = tp + fn; + double pp = tp / total; + double pn = fn / total; + score = pp * Math.log(pp) + pn * Math.log(pn); + break;} + case MATTHEWS_CORRELATION : + score = (tp * tn - fp * fn) / Math.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn));break; + case YOUDEN_INDEX : score = tp / (tp + fn) + tn / (fp + tn) - 1;break; + default: + break; + + } + return score; } - private double getPredictedAccuracy(EvaluatedQueryTree<String> tree){ + /** + * Returns the maximum achievable score according to the used score function. + * @return + */ + public double getMaximumAchievableScore(EvaluatedQueryTree<String> tree) { QueryTreeScore treeScore = tree.getTreeScore(); Set<Individual> truePositives = treeScore.getCoveredPositives(); Set<Individual> trueNegatives = treeScore.getNotCoveredNegatives(); Set<Individual> falsePositives = treeScore.getNotCoveredPositives(); Set<Individual> falseNegatives = treeScore.getCoveredNegatives(); - return 0; + double tp = truePositives.size(); + double tn = trueNegatives.size(); + double fp = falsePositives.size(); + double fn = falseNegatives.size(); + + return getMaximumAchievableScore(tp, tn, fp, fn); } + + /** + * Returns the maximum achievable score according to the used score function. + * @param tp + * @param tn + * @param fp + * @param fn + * @return + */ + private double getMaximumAchievableScore(double tp, double tn, double fp, double fn) { + double mas = 0d; + switch (heuristicType) { + case FMEASURE: + break; + case PRED_ACC: + mas = (posExamplesWeight * tp + tn - fp) / (posExamplesWeight * (tp + fn) + tn + fp); + break; + case ENTROPY: + break; + case MATTHEWS_CORRELATION: + break; + case YOUDEN_INDEX: + break; + default: + break; + } + return mas; + } + /* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @@ -75,5 +145,19 @@ return conceptComparator.compare(tree1.asEvaluatedDescription().getDescription(), tree2.asEvaluatedDescription().getDescription()); } } + + /** + * @param heuristicType the heuristicType to set + */ + public void setHeuristicType(HeuristicType heuristicType) { + this.heuristicType = heuristicType; + } + + /** + * @param posExamplesWeight the posExamplesWeight to set + */ + public void setPosExamplesWeight(double posExamplesWeight) { + this.posExamplesWeight = posExamplesWeight; + } } Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/Heuristics.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/Heuristics.java 2014-05-07 13:43:54 UTC (rev 4262) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/Heuristics.java 2014-05-08 11:45:45 UTC (rev 4263) @@ -29,7 +29,7 @@ */ public class Heuristics { - public static enum HeuristicType { PRED_ACC, AMEASURE, JACCARD, FMEASURE, GEN_FMEASURE }; + public static enum HeuristicType { PRED_ACC, AMEASURE, JACCARD, FMEASURE, GEN_FMEASURE, ENTROPY, MATTHEWS_CORRELATION, YOUDEN_INDEX }; /** * Computes F1-Score. Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/QueryTreeScore.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/QueryTreeScore.java 2014-05-07 13:43:54 UTC (rev 4262) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/QueryTreeScore.java 2014-05-08 11:45:45 UTC (rev 4263) @@ -16,7 +16,7 @@ private double score; - private double coverageScore; + private double accuracy; private double specifityScore; private int nrOfSpecificNodes; @@ -26,12 +26,12 @@ private Set<Individual> negAsPos; private Set<Individual> negAsNeg; - public QueryTreeScore(double score, double coverageScore, + public QueryTreeScore(double score, double accuracy, Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg, double specifityScore, int nrOfSpecificNodes) { super(); this.score = score; - this.coverageScore = coverageScore; + this.accuracy = accuracy; this.posAsPos = posAsPos; this.posAsNeg = posAsNeg; this.negAsPos = negAsPos; @@ -46,15 +46,29 @@ public double getScore() { return score; } + + /** + * @param score the score to set + */ + public void setScore(double score) { + this.score = score; + } /* (non-Javadoc) * @see org.dllearner.core.Score#getAccuracy() */ @Override public double getAccuracy() { - return score; + return accuracy; } + /** + * @param accuracy the accuracy to set + */ + public void setAccuracy(double accuracy) { + this.accuracy = accuracy; + } + public Set<Individual> getCoveredNegatives() { return negAsPos; } @@ -77,7 +91,7 @@ @Override public String toString() { return score - + "(coverage=" + coverageScore + + "(accuracy=" + accuracy + "(+" + posAsPos.size() + "/" + (posAsPos.size() + posAsNeg.size()) + "|-" + negAsPos.size() + "/" + (negAsPos.size() + negAsNeg.size()) + ")|" + "specifity=" + specifityScore + "(" + nrOfSpecificNodes + "))"; Modified: trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-07 13:43:54 UTC (rev 4262) +++ trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java 2014-05-08 11:45:45 UTC (rev 4263) @@ -19,44 +19,49 @@ */ package org.dllearner.scripts; +import static java.util.Arrays.asList; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.text.DecimalFormat; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Random; import java.util.Set; import java.util.TreeSet; -import java.util.Map.Entry; +import joptsimple.OptionParser; +import joptsimple.OptionSet; + +import org.apache.commons.beanutils.PropertyUtils; import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.FileAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; -import org.dllearner.cli.Start; -import org.dllearner.core.ComponentInitException; -import org.dllearner.core.ComponentManager; +import org.dllearner.cli.CLI; import org.dllearner.core.AbstractCELA; import org.dllearner.core.AbstractLearningProblem; import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.parser.ParseException; import org.dllearner.utilities.Helper; -import org.dllearner.utilities.datastructures.Datastructures; import org.dllearner.utilities.datastructures.TrainTestList; import org.dllearner.utilities.statistics.Stat; -import joptsimple.OptionParser; -import joptsimple.OptionSet; +import com.google.common.base.Charsets; +import com.google.common.io.Files; -import static java.util.Arrays.*; - /** * Performs nested cross validation for the given problem. A k fold outer and l * fold inner cross validation is used. Parameters: @@ -93,6 +98,8 @@ * */ public class NestedCrossValidation { + + private File outputFile = new File("log/nested-cv.log"); /** * Entry method, which uses JOptSimple to parse parameters. @@ -115,6 +122,7 @@ parser.acceptsAll(asList( "i", "innerfolds"), "Number of inner folds.").withRequiredArg().ofType(Integer.class).describedAs("#folds"); parser.acceptsAll(asList( "p", "parameter"), "Parameter to vary.").withRequiredArg(); parser.acceptsAll(asList( "r", "pvalues", "range"), "Values of parameter. $x-$y can be used for integer ranges.").withRequiredArg(); + parser.acceptsAll(asList( "s", "stepsize", "steps"), "Step size of range.").withOptionalArg().ofType(Double.class).defaultsTo(1d); // parse options and display a message for the user in case of problems OptionSet options = null; @@ -137,8 +145,9 @@ String parameter = (String) options.valueOf("p"); String range = (String) options.valueOf("r"); String[] rangeSplit = range.split("-"); - int rangeStart = new Integer(rangeSplit[0]); - int rangeEnd = new Integer(rangeSplit[1]); + double rangeStart = Double.valueOf(rangeSplit[0]); + double rangeEnd = Double.valueOf(rangeSplit[1]); + double stepsize = (Double) options.valueOf("s"); boolean verbose = options.has("v"); // create logger (a simple logger which outputs @@ -149,11 +158,13 @@ logger.removeAllAppenders(); logger.addAppender(consoleAppender); logger.setLevel(Level.WARN); + Logger.getLogger("org.dllearner.algorithms").setLevel(Level.INFO); +// logger.addAppender(new FileAppender(layout, "nested-cv.log", false)); // disable OWL API info output java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.WARNING); System.out.println("Warning: The script is not well tested yet. (No known bugs, but needs more testing.)"); - new NestedCrossValidation(confFile, outerFolds, innerFolds, parameter, rangeStart, rangeEnd, verbose); + new NestedCrossValidation(confFile, outerFolds, innerFolds, parameter, rangeStart, rangeEnd, stepsize, verbose); // an option is missing => print help screen and message } else { @@ -163,14 +174,24 @@ } - public NestedCrossValidation(File confFile, int outerFolds, int innerFolds, String parameter, int startValue, int endValue, boolean verbose) throws FileNotFoundException, ComponentInitException, ParseException, org.dllearner.confparser.ParseException { + private void print(String s){ + try { + Files.append(s + "\n", outputFile , Charsets.UTF_8); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println(s); + } + + public NestedCrossValidation(File confFile, int outerFolds, int innerFolds, String parameter, double startValue, double endValue, double stepsize, boolean verbose) throws ComponentInitException, ParseException, org.dllearner.confparser.ParseException, IOException { DecimalFormat df = new DecimalFormat(); ComponentManager cm = ComponentManager.getInstance(); - Start start = new Start(confFile); + CLI start = new CLI(confFile); + start.init(); AbstractLearningProblem lp = start.getLearningProblem(); - + System.out.println(lp); if(!(lp instanceof PosNegLP)) { System.out.println("Positive only learning not supported yet."); System.exit(0); @@ -196,16 +217,16 @@ for(int currOuterFold=0; currOuterFold<outerFolds; currOuterFold++) { - System.out.println("Outer fold " + currOuterFold); + print("Outer fold " + currOuterFold); TrainTestList posList = posLists.get(currOuterFold); TrainTestList negList = negLists.get(currOuterFold); // measure relevant criterion (accuracy, F-measure) over different parameter values - Map<Integer,Stat> paraStats = new HashMap<Integer,Stat>(); + Map<Double,Stat> paraStats = new HashMap<Double,Stat>(); - for(int currParaValue=startValue; currParaValue<=endValue; currParaValue++) { + for(double currParaValue=startValue; currParaValue<=endValue; currParaValue+=stepsize) { - System.out.println(" Parameter value " + currParaValue + ":"); + print(" Parameter value " + currParaValue + ":"); // split train folds again (computation of inner folds for each parameter // value is redundant, but not a big problem) List<Individual> trainPosList = posList.getTrainList(); @@ -219,19 +240,24 @@ for(int currInnerFold=0; currInnerFold<innerFolds; currInnerFold++) { - System.out.println(" Inner fold " + currInnerFold + ":"); + print(" Inner fold " + currInnerFold + ":"); // get positive & negative examples for training run Set<Individual> posEx = new TreeSet<Individual>(innerPosLists.get(currInnerFold).getTrainList()); Set<Individual> negEx = new TreeSet<Individual>(innerNegLists.get(currInnerFold).getTrainList()); // read conf file and exchange options for pos/neg examples // and parameter to optimise - start = new Start(confFile); + start = new CLI(confFile); + start.init(); AbstractLearningProblem lpIn = start.getLearningProblem(); - cm.applyConfigEntry(lpIn, "positiveExamples", Datastructures.individualSetToStringSet(posEx)); - cm.applyConfigEntry(lpIn, "negativeExamples", Datastructures.individualSetToStringSet(negEx)); + ((PosNegLP)lpIn).setPositiveExamples(posEx); + ((PosNegLP)lpIn).setNegativeExamples(negEx); AbstractCELA laIn = start.getLearningAlgorithm(); - cm.applyConfigEntry(laIn, parameter, (double)currParaValue); + try { + PropertyUtils.setSimpleProperty(laIn, parameter, currParaValue); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + } lpIn.init(); laIn.init(); @@ -263,15 +289,15 @@ paraCriterionStat.addNumber(accuracy); - System.out.println(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); - System.out.println(" accuracy: " + df.format(accuracy) + "%"); - System.out.println(" precision: " + df.format(precision) + "%"); - System.out.println(" recall: " + df.format(recall) + "%"); - System.out.println(" F measure: " + df.format(fmeasure) + "%"); + print(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); + print(" accuracy: " + df.format(accuracy) + "%"); + print(" precision: " + df.format(precision) + "%"); + print(" recall: " + df.format(recall) + "%"); + print(" F measure: " + df.format(fmeasure) + "%"); if(verbose) { - System.out.println(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); - System.out.println(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); + print(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); + print(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); } // free memory @@ -284,28 +310,33 @@ } // decide for the best parameter - System.out.println(" Summary over parameter values:"); - int bestPara = startValue; + print(" Summary over parameter values:"); + double bestPara = startValue; double bestValue = Double.NEGATIVE_INFINITY; - for(Entry<Integer,Stat> entry : paraStats.entrySet()) { - int para = entry.getKey(); + for(Entry<Double,Stat> entry : paraStats.entrySet()) { + double para = entry.getKey(); Stat stat = entry.getValue(); - System.out.println(" value " + para + ": " + stat.prettyPrint("%")); + print(" value " + para + ": " + stat.prettyPrint("%")); if(stat.getMean() > bestValue) { bestPara = para; bestValue = stat.getMean(); } } - System.out.println(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); - System.out.println(" Learn on Outer fold:"); + print(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); + print(" Learn on Outer fold:"); // start a learning process with this parameter and evaluate it on the outer fold - start = new Start(confFile); + start = new CLI(confFile); + start.init(); AbstractLearningProblem lpOut = start.getLearningProblem(); - cm.applyConfigEntry(lpOut, "positiveExamples", Datastructures.individualListToStringSet(posLists.get(currOuterFold).getTrainList())); - cm.applyConfigEntry(lpOut, "negativeExamples", Datastructures.individualListToStringSet(negLists.get(currOuterFold).getTrainList())); + ((PosNegLP)lpOut).setPositiveExamples(new TreeSet<Individual>(posLists.get(currOuterFold).getTrainList())); + ((PosNegLP)lpOut).setNegativeExamples(new TreeSet<Individual>(negLists.get(currOuterFold).getTrainList())); AbstractCELA laOut = start.getLearningAlgorithm(); - cm.applyConfigEntry(laOut, parameter, (double)bestPara); + try { + PropertyUtils.setSimpleProperty(laOut, parameter, bestPara); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + } lpOut.init(); laOut.init(); @@ -332,15 +363,15 @@ double recall = 100 * (double) posCorrect.size() / (posCorrect.size() + posError.size()); double fmeasure = 2 * (precision * recall) / (precision + recall); - System.out.println(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); - System.out.println(" accuracy: " + df.format(accuracy) + "%"); - System.out.println(" precision: " + df.format(precision) + "%"); - System.out.println(" recall: " + df.format(recall) + "%"); - System.out.println(" F measure: " + df.format(fmeasure) + "%"); + print(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); + print(" accuracy: " + df.format(accuracy) + "%"); + print(" precision: " + df.format(precision) + "%"); + print(" recall: " + df.format(recall) + "%"); + print(" F measure: " + df.format(fmeasure) + "%"); if(verbose) { - System.out.println(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); - System.out.println(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); + print(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); + print(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); } // update overall statistics @@ -355,14 +386,13 @@ } // overall statistics - System.out.println(); - System.out.println("*******************"); - System.out.println("* Overall Results *"); - System.out.println("*******************"); - System.out.println("accuracy: " + accOverall.prettyPrint("%")); - System.out.println("F measure: " + fOverall.prettyPrint("%")); - System.out.println("precision: " + precisionOverall.prettyPrint("%")); - System.out.println("recall: " + recallOverall.prettyPrint("%")); + print("*******************"); + print("* Overall Results *"); + print("*******************"); + print("accuracy: " + accOverall.prettyPrint("%")); + print("F measure: " + fOverall.prettyPrint("%")); + print("precision: " + precisionOverall.prettyPrint("%")); + print("recall: " + recallOverall.prettyPrint("%")); } Modified: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-07 13:43:54 UTC (rev 4262) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-08 11:45:45 UTC (rev 4263) @@ -53,8 +53,8 @@ public class QTLEvaluation { int nrOfFolds = 10; - private int nrOfPosExamples = 100; - private int nrOfNegExamples = 100; + private int nrOfPosExamples = 300; + private int nrOfNegExamples = 300; List<String> posExamples = Lists.newArrayList( "http://dl-learner.org/carcinogenesis#d1", @@ -496,13 +496,13 @@ lp.setReasoner(reasoner); lp.init(); QTL2Disjunctive la = new QTL2Disjunctive(lp, reasoner); -// la.init(); -// la.start(); + la.init(); + la.start(); CrossValidation.outputFile = new File("log/qtl-cv.log"); CrossValidation.writeToFile = true; CrossValidation.multiThreaded = multiThreaded; - CrossValidation cv = new CrossValidation(la, lp, reasoner, nrOfFolds, false); +// CrossValidation cv = new CrossValidation(la, lp, reasoner, nrOfFolds, false); long endTime = System.currentTimeMillis(); System.err.println((endTime - startTime) + "ms"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-05-07 13:43:59
|
Revision: 4262 http://sourceforge.net/p/dl-learner/code/4262 Author: lorenz_b Date: 2014-05-07 13:43:54 +0000 (Wed, 07 May 2014) Log Message: ----------- Updated libs. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/SearchTreeNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/AbstractRelevanceMetric.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/RelevanceMetric.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTreeFactoryImpl.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorImpl.java trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java trunk/components-core/src/main/java/org/dllearner/core/AbstractReasonerComponent.java trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java trunk/components-core/src/main/java/org/dllearner/kb/OWLAPIOntology.java trunk/components-core/src/main/java/org/dllearner/kb/aquisitors/SparqlTupleAquisitorImproved.java trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java trunk/components-core/src/main/java/org/dllearner/reasoning/FastInstanceChecker.java trunk/components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown.java trunk/components-core/src/main/java/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL2.java trunk/components-core/src/main/resources/log4j.properties trunk/components-core/src/test/java/org/dllearner/algorithms/isle/DBpediaExperiment.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/LGGTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QALDExperiment.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/QTLTest.java trunk/components-core/src/test/java/org/dllearner/algorithms/qtl/TreeSubsumptionTest.java trunk/examples/family-benchmark/Brother.conf trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java trunk/interfaces/src/main/java/org/dllearner/cli/CrossValidation.java trunk/interfaces/src/main/java/org/dllearner/cli/SPARQLCrossValidation.java trunk/pom.xml trunk/protege/src/main/resources/META-INF/MANIFEST.MF trunk/scripts/pom.xml trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/DefaultRelevanceWeightings.java trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightedStableHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightings.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/EntityFrequencyCache.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/util/QueryTreeConverter.java Removed Paths: ------------- trunk/test/fuzzydll/fuzzyOWL2fuzzyDLparserOutput.fuzzyDL.txt Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2014-05-07 11:25:54 UTC (rev 4261) +++ trunk/components-core/pom.xml 2014-05-07 13:43:54 UTC (rev 4262) @@ -232,10 +232,10 @@ <artifactId>commons-pool</artifactId> </dependency> <dependency> - <groupId>org.semanticweb.elk</groupId> - <artifactId>elk-owlapi</artifactId> - <version>0.3.0</version> - </dependency> + <groupId>org.semanticweb.elk</groupId> + <artifactId>elk-owlapi</artifactId> + <version>0.4.1</version> +</dependency> <dependency> <groupId>de.tudresden.inf.lat.cel</groupId> <artifactId>reasoner</artifactId> @@ -281,7 +281,7 @@ <dependency> <groupId>org.aksw.jena-sparql-api</groupId> <artifactId>jena-sparql-api-core</artifactId> - <version>2.10.0-5-SNAPSHOT</version> + <version>2.10.0-8</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> Added: trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/DefaultRelevanceWeightings.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/DefaultRelevanceWeightings.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/DefaultRelevanceWeightings.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -0,0 +1,31 @@ +/** + * + */ +package org.dllearner.algorithms.elcopy; + +import org.dllearner.algorithms.isle.metrics.ChiSquareRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.DiceRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.JaccardRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.LLRRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.PMIRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.SCIRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.SignificantPMIRelevanceMetric; +import org.dllearner.algorithms.isle.metrics.TTestRelevanceMetric; + +/** + * @author Lorenz Buehmann + * + */ +public class DefaultRelevanceWeightings extends RelevanceWeightings{ + + public DefaultRelevanceWeightings() { + put(PMIRelevanceMetric.class, 1.0); + put(SignificantPMIRelevanceMetric.class, 1.0); + put(ChiSquareRelevanceMetric.class, 1.0); + put(TTestRelevanceMetric.class, 1.0); + put(JaccardRelevanceMetric.class, 1.0); + put(DiceRelevanceMetric.class, 1.0); + put(SCIRelevanceMetric.class, 1.0); + put(LLRRelevanceMetric.class, 1.0); + } +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java 2014-05-07 11:25:54 UTC (rev 4261) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/ELLearningAlgorithm.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -45,6 +45,7 @@ import org.dllearner.learningproblems.EvaluatedDescriptionPosNeg; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.ScorePosNeg; +import org.dllearner.learningproblems.ScoreTwoValued; import org.dllearner.refinementoperators.ELDown3; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.EvaluatedDescriptionSet; @@ -148,7 +149,10 @@ @Override public void init() throws ComponentInitException { // currently we use the stable heuristic - heuristic = new StableHeuristic(); + if(heuristic == null){ + heuristic = new StableHeuristic(); + } + candidates = new TreeSet<SearchTreeNode>(heuristic); if(ignoredConcepts != null) { @@ -167,6 +171,13 @@ bestEvaluatedDescriptions = new EvaluatedDescriptionSet(maxNrOfResults); } + /** + * @param heuristic the heuristic to set + */ + public void setHeuristic(ELHeuristic heuristic) { + this.heuristic = heuristic; + } + @Override public void start() { stop = false; @@ -237,7 +248,13 @@ } else { node.setCoveredNegatives(negCovers); } - node.setScore(accuracy); + node.setAccuracy(accuracy); + if(heuristic instanceof RelevanceWeightedStableHeuristic){ + node.setScore(((RelevanceWeightedStableHeuristic)heuristic).getNodeScore(node)); + } else { + node.setScore(accuracy); + } + // System.out.println(description + ":" + accuracy); // link to parent (unless start node) if(parentNode == null) { @@ -259,6 +276,7 @@ // for fully computing the evaluated description if(bestEvaluatedDescriptions.size() == 0 || ((EvaluatedDescriptionPosNeg)bestEvaluatedDescriptions.getWorst()).getCoveredNegatives().size() >= node.getCoveredNegatives()) { ScorePosNeg score = (ScorePosNeg) learningProblem.computeScore(description); + ((ScoreTwoValued)score).setAccuracy(node.getScore()); EvaluatedDescriptionPosNeg ed = new EvaluatedDescriptionPosNeg(description, score); bestEvaluatedDescriptions.add(ed); } @@ -329,7 +347,9 @@ //non of the equivalent classes must occur on the first level TreeSet<Description> toTest = new TreeSet<Description>(descriptionComparator); - toTest.add(classToDescribe); + if(classToDescribe != null){ + toTest.add(classToDescribe); + } while(!toTest.isEmpty()) { Description d = toTest.pollFirst(); if(occursOnFirstLevel(description, d)) { @@ -341,7 +361,9 @@ // none of the superclasses of the class to learn must appear on the // outermost property level TreeSet<Description> toTest = new TreeSet<Description>(descriptionComparator); - toTest.add(classToDescribe); + if(classToDescribe != null){ + toTest.add(classToDescribe); + } while(!toTest.isEmpty()) { Description d = toTest.pollFirst(); if(occursOnFirstLevel(description, d)) { Added: trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightedStableHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightedStableHeuristic.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightedStableHeuristic.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -0,0 +1,124 @@ +/** + * Copyright (C) 2007-2011, 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.algorithms.elcopy; + +import java.util.Arrays; +import java.util.List; + +import org.dllearner.algorithms.isle.metrics.RelevanceMetric; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Entity; +import org.dllearner.core.owl.NamedClass; + + +/** + * A stable comparator for search tree nodes. Stable means that the order + * of nodes will not change during the run of the learning algorithm. In + * this implementation, this is ensured by using only covered examples + * and tree size as criteria. + * + * @author Jens Lehmann + * + */ +public class RelevanceWeightedStableHeuristic implements ELHeuristic { + + private ELDescriptionTreeComparator cmp = new ELDescriptionTreeComparator(); + private RelevanceWeightings weightings; + private List<RelevanceMetric> relevanceMetrics; + private NamedClass classToDescribe; + + + public RelevanceWeightedStableHeuristic(NamedClass classToDescribe, RelevanceWeightings weightings, RelevanceMetric... relevanceMetrics) { + this.classToDescribe = classToDescribe; + this.weightings = weightings; + this.relevanceMetrics = Arrays.asList(relevanceMetrics); + } + + public RelevanceWeightedStableHeuristic(NamedClass classToDescribe, RelevanceWeightings weightings, List<RelevanceMetric> relevanceMetrics) { + this.classToDescribe = classToDescribe; + this.weightings = weightings; + this.relevanceMetrics = relevanceMetrics; + } + + public RelevanceWeightedStableHeuristic(NamedClass classToDescribe, RelevanceMetric... relevanceMetrics) { + this(classToDescribe, new DefaultRelevanceWeightings(), relevanceMetrics); + } + + public RelevanceWeightedStableHeuristic(NamedClass classToDescribe, List<RelevanceMetric> relevanceMetrics) { + this(classToDescribe, new DefaultRelevanceWeightings(), relevanceMetrics); + } + + /** + * @param weightings the weightings to set + */ + public void setWeightings(RelevanceWeightings weightings) { + this.weightings = weightings; + } + + /** + * @param relevanceMetrics the relevanceMetrics to set + */ + public void setRelevanceMetrics(List<RelevanceMetric> relevanceMetrics) { + this.relevanceMetrics = relevanceMetrics; + } + + /** + * @param classToDescribe the classToDescribe to set + */ + public void setClassToDescribe(NamedClass classToDescribe) { + this.classToDescribe = classToDescribe; + } + + public double getNodeScore(SearchTreeNode node){ + double score = node.getAccuracy(); + Description d = node.getDescriptionTree().transformToDescription(); + for (RelevanceMetric metric : relevanceMetrics) { + score += weightings.getWeight(metric.getClass()) * metric.getRelevance(classToDescribe, d); + } + return score; + } + + @Override + public int compare(SearchTreeNode o1, SearchTreeNode o2) { + +// int diff = o2.getCoveredNegatives() - o1.getCoveredNegatives(); + double score1 = o1.getScore(); + double score2 = o2.getScore(); + int diff = Double.compare(score1, score2); + if(diff>0) { + return 1; + } else if(diff<0) { + return -1; + } else { + + double sizeDiff = o2.getDescriptionTree().size - o1.getDescriptionTree().size; + + if(sizeDiff == 0) { + return cmp.compare(o1.getDescriptionTree(), o2.getDescriptionTree()); + } else if(sizeDiff>0) { + return 1; + } else { + return -1; + } + + } + } + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightings.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightings.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/RelevanceWeightings.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -0,0 +1,24 @@ +/** + * + */ +package org.dllearner.algorithms.elcopy; + +import java.util.HashMap; + +import org.dllearner.algorithms.isle.metrics.RelevanceMetric; + +/** + * @author Lorenz Buehmann + * + */ +public class RelevanceWeightings extends HashMap<Class<? extends RelevanceMetric>, Double>{ + + public double getWeight(RelevanceMetric metric){ + return get(metric.getClass()); + } + + public double getWeight(Class<? extends RelevanceMetric> metricClass){ + return get(metricClass); + } + +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/SearchTreeNode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/SearchTreeNode.java 2014-05-07 11:25:54 UTC (rev 4261) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/elcopy/SearchTreeNode.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -38,6 +38,7 @@ private boolean tooWeak = false; private double score; + protected double accuracy; public SearchTreeNode(ELDescriptionTree descriptionTree) { this.descriptionTree = descriptionTree; @@ -127,4 +128,18 @@ this.score = score; } + /** + * @return the accuracy + */ + public double getAccuracy() { + return accuracy; + } + + /** + * @param accuracy the accuracy to set + */ + public void setAccuracy(double accuracy) { + this.accuracy = accuracy; + } + } Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/EntityFrequencyCache.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/EntityFrequencyCache.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/syntactic/EntityFrequencyCache.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -0,0 +1,17 @@ +/** + * + */ +package org.dllearner.algorithms.isle.index.syntactic; + +import java.util.HashMap; +import java.util.Set; + +import org.dllearner.core.owl.Entity; + +/** + * @author Lorenz Buehmann + * + */ +public class EntityFrequencyCache extends HashMap<Set<Entity>, Long>{ + +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/AbstractRelevanceMetric.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/AbstractRelevanceMetric.java 2014-05-07 11:25:54 UTC (rev 4261) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/AbstractRelevanceMetric.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -5,8 +5,10 @@ import java.util.HashMap; import java.util.Map; +import java.util.Set; import org.dllearner.algorithms.isle.index.Index; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Entity; /** @@ -16,9 +18,12 @@ public abstract class AbstractRelevanceMetric implements RelevanceMetric { protected Index index; + protected String name; public AbstractRelevanceMetric(Index index) { this.index = index; + + name = getClass().getSimpleName().replace("RelevanceMetric", ""); } public static Map<Entity, Double> normalizeMinMax(Map<Entity, Double> hmEntity2Score) { @@ -53,5 +58,47 @@ } return hmEntity2Norm; } + + public String getName() { + return name; + } + + public double getRelevance(Entity entity, Description desc){ + Set<Entity> entities = desc.getSignature(); + double score = 0; + for (Entity otherEntity : entities) { + double relevance = getRelevance(entity, otherEntity); + if(!Double.isInfinite(relevance)){ + score += relevance/entities.size(); + } + } + return score; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AbstractRelevanceMetric other = (AbstractRelevanceMetric) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/RelevanceMetric.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/RelevanceMetric.java 2014-05-07 11:25:54 UTC (rev 4261) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/metrics/RelevanceMetric.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -20,6 +20,7 @@ package org.dllearner.algorithms.isle.metrics; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Entity; @@ -38,4 +39,6 @@ * @return */ double getNormalizedRelevance(Entity entity1, Entity entity2); + + double getRelevance(Entity entity, Description desc); } \ No newline at end of file Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-07 11:25:54 UTC (rev 4261) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2Disjunctive.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -1,5 +1,6 @@ package org.dllearner.algorithms.qtl; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -28,14 +29,19 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.Score; +import org.dllearner.core.config.ConfigOption; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Union; +import org.dllearner.kb.OWLAPIOntology; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.Heuristics; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.QueryTreeScore; +import org.dllearner.learningproblems.ScoreTwoValued; import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; import org.dllearner.utilities.owl.OWLAPIConverter; import org.semanticweb.owlapi.io.ToStringRenderer; @@ -51,12 +57,12 @@ import com.jamonapi.MonitorFactory; @ComponentAnn(name="query tree learner with noise (disjunctive)", shortName="qtl2dis", version=0.8) -public class QTL2Disjunctive extends AbstractCELA { +public class QTL2Disjunctive extends AbstractCELA implements Cloneable{ private static final Logger logger = Logger.getLogger(QTL2Disjunctive.class.getName()); - private LGGGenerator<String> lggGenerator = new LGGGeneratorImpl<String>(); + private LGGGenerator<String> lggGenerator; private Queue<EvaluatedQueryTree<String>> todoList; private SortedSet<EvaluatedQueryTree<String>> currentPartialSolutions; @@ -69,9 +75,6 @@ private Set<Individual> currentNegExamples; private Map<QueryTree<String>, Individual> tree2Individual; - - private double coverageWeight = 0.8; - private double specifityWeight = 0.2; private QueryTreeCache treeCache; @@ -79,8 +82,6 @@ private Model model; - private AbstractReasonerComponent reasoner; - private volatile boolean stop; private boolean isRunning; @@ -89,16 +90,39 @@ private List<EvaluatedQueryTree<String>> partialSolutions; + private EvaluatedDescription currentBestSolution; + + + + //Parameters + @ConfigOption(name = "noisePercentage", defaultValue="0.0", description="the (approximated) percentage of noise within the examples") + private double noisePercentage = 0.0; + @ConfigOption(defaultValue = "10", name = "maxExecutionTimeInSeconds", description = "maximum execution of the algorithm in seconds") + private int maxExecutionTimeInSeconds = 10; + private double minimumTreeScore = 0.2; + private double coverageWeight = 0.8; + private double specifityWeight = 0.1; + private double noise = 0.3; + private double coverageBeta = 0.7; + + private double posExampleWeight = 1; + public QTL2Disjunctive() {} public QTL2Disjunctive(PosNegLP learningProblem, AbstractReasonerComponent reasoner) throws LearningProblemUnsupportedException{ - this.lp = learningProblem; - this.reasoner = reasoner; + super(learningProblem, reasoner); + loadModel(); } - public QTL2Disjunctive(PosNegLP lp, Model model) { - this.lp = lp; - this.model = model; +// public QTL2Disjunctive(PosNegLP lp, Model model) { +// this.learningProblem = lp; +// this.model = model; +// } + + public QTL2Disjunctive(QTL2Disjunctive qtl) { + super(qtl.getLearningProblem(), qtl.getReasoner()); + this.model = ModelFactory.createDefaultModel(); + this.model.add(qtl.model); } public EvaluatedQueryTree<String> getBestSolution(){ @@ -110,6 +134,14 @@ */ @Override public void init() throws ComponentInitException { + + if(!(learningProblem instanceof PosNegLP)){ + throw new IllegalArgumentException("Only PosNeg learning problems are supported"); + } + lp = (PosNegLP) learningProblem; + + lggGenerator = new LGGGeneratorImpl<String>(); + logger.info("Initializing..."); treeCache = new QueryTreeCache(model); tree2Individual = new HashMap<QueryTree<String>, Individual>(lp.getPositiveExamples().size()+lp.getNegativeExamples().size()); @@ -120,6 +152,18 @@ currentNegExamples = new TreeSet<Individual>(lp.getNegativeExamples()); //get the query trees + generateTrees(); + + //some logging + subMon = MonitorFactory.getTimeMonitor("subsumption-mon"); + lggMon = MonitorFactory.getTimeMonitor("lgg-mon"); + + //console rendering of class expressions + ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); + ToStringRenderer.getInstance().setShortFormProvider(new SimpleShortFormProvider()); + } + + private void generateTrees(){ QueryTree<String> queryTree; for (Individual ind : lp.getPositiveExamples()) { queryTree = treeCache.getQueryTree(ind.getName()); @@ -131,14 +175,6 @@ tree2Individual.put(queryTree, ind); currentNegExampleTrees.add(queryTree); } - - //some logging - subMon = MonitorFactory.getTimeMonitor("subsumption-mon"); - lggMon = MonitorFactory.getTimeMonitor("lgg-mon"); - - //console rendering of class expressions - ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); - ToStringRenderer.getInstance().setShortFormProvider(new SimpleShortFormProvider()); } /* (non-Javadoc) @@ -146,6 +182,11 @@ */ @Override public void start() { + String setup = "Setup:"; + setup += "#Pos. examples:" + currentPosExamples.size(); + setup += "#Neg. examples:" + currentNegExamples.size(); + setup += "Coverage beta:" + coverageBeta; + logger.info(setup); logger.info("Running..."); long startTime = System.currentTimeMillis(); @@ -180,6 +221,7 @@ currentNegExamples.remove(tree2Individual.get(tree)); } } + currentBestSolution = buildCombinedSolution(); } while (!(stop || currentPosExampleTrees.isEmpty())); isRunning = false; @@ -187,22 +229,53 @@ long endTime = System.currentTimeMillis(); logger.info("Finished in " + (endTime-startTime) + "ms."); - EvaluatedDescription combinedSolution = buildCombinedSolution(); - System.out.println(OWLAPIConverter.getOWLAPIDescription(combinedSolution.getDescription())); + logger.info("Combined solution:\n" + OWLAPIConverter.getOWLAPIDescription(currentBestSolution.getDescription())); + logger.info(currentBestSolution.getScore()); } private EvaluatedDescription buildCombinedSolution(){ + if(partialSolutions.size() == 1){ + EvaluatedDescription combinedSolution = partialSolutions.get(0).asEvaluatedDescription(); + double accuracy = lp.getAccuracy(combinedSolution.getDescription()); + System.out.println(accuracy); + return combinedSolution; + } List<Description> disjuncts = new ArrayList<Description>(); + + Set<Individual> posCovered = new HashSet<Individual>(); + Set<Individual> negCovered = new HashSet<Individual>(); + + //build the union of all class expressions Description partialDescription; for (EvaluatedQueryTree<String> partialSolution : partialSolutions) { partialDescription = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( partialSolution.getTree().asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION)); disjuncts.add(partialDescription); + posCovered.addAll(partialSolution.getTreeScore().getCoveredPositives()); + negCovered.addAll(partialSolution.getTreeScore().getCoveredNegatives()); } Description unionDescription = new Union(disjuncts); - return new EvaluatedDescription(unionDescription, null); + Set<Individual> posNotCovered = Sets.difference(lp.getPositiveExamples(), posCovered); + Set<Individual> negNotCovered = Sets.difference(lp.getNegativeExamples(), negCovered); + + double accuracy = lp.getAccuracy(unionDescription); + System.out.println(accuracy); + + //compute the coverage + double recall = posCovered.size() / (double)lp.getPositiveExamples().size(); + double precision = (posCovered.size() + negCovered.size() == 0) + ? 0 + : posCovered.size() / (double)(posCovered.size() + negCovered.size()); + + double coverageScore = Heuristics.getFScore(recall, precision, coverageBeta); + +// ScoreTwoValued score = new ScoreTwoValued(posCovered, posNotCovered, negCovered, negNotCovered); +// score.setAccuracy(coverageScore); + QueryTreeScore score = new QueryTreeScore(coverageScore, coverageScore, posCovered, posNotCovered, negCovered, negNotCovered, -1, -1); + + return new EvaluatedDescription(unionDescription, score); } private void reset(){ @@ -216,6 +289,7 @@ } private void computeLGG(){ + logger.info("Computing best partial solution..."); currentlyBestScore = 0d; initTodoList(currentPosExampleTrees, currentNegExampleTrees); @@ -246,16 +320,17 @@ } currentlyBestScore = solution.getScore(); } + currentPartialSolutions.add(currentElement); } currentPartialSolutions.add(currentElement); // todoList.remove(currentElement); } while(!terminationCriteriaSatisfied()); long endTime = System.currentTimeMillis(); - logger.info("Finished in " + (endTime-startTime) + "ms."); - EvaluatedDescription bestSolution = getCurrentlyBestEvaluatedDescription(); + logger.info("...finished in " + (endTime-startTime) + "ms."); + EvaluatedDescription bestPartialSolution = currentPartialSolutions.first().asEvaluatedDescription(); - logger.info("Best solution:\n" + OWLAPIConverter.getOWLAPIDescription(bestSolution.getDescription()) + "\n(" + bestSolution.getScore() + ")"); + logger.info("Best partial solution:\n" + OWLAPIConverter.getOWLAPIDescription(bestPartialSolution.getDescription()) + "\n(" + bestPartialSolution.getScore() + ")"); logger.trace("LGG time: " + lggMon.getTotal() + "ms"); logger.trace("Avg. LGG time: " + lggMon.getAvg() + "ms"); @@ -278,7 +353,7 @@ */ @Override public Description getCurrentlyBestDescription() { - return getCurrentlyBestEvaluatedDescription().getDescription(); + return currentBestSolution.getDescription(); } /* (non-Javadoc) @@ -286,8 +361,7 @@ */ @Override public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { - EvaluatedQueryTree<String> bestSolution = currentPartialSolutions.first(); - return bestSolution.asEvaluatedDescription(); + return currentBestSolution; } /* (non-Javadoc) @@ -298,14 +372,18 @@ return isRunning; } +// @Autowired +// public void setLearningProblem(PosNegLP learningProblem) { +// this.lp = learningProblem; +// } + @Autowired - public void setLearningProblem(PosNegLP learningProblem) { - this.lp = learningProblem; + public void setReasoner(AbstractReasonerComponent reasoner){ + super.setReasoner(reasoner); + loadModel(); } - @Autowired - public void setReasoner(AbstractReasonerComponent reasoner){ - this.reasoner = reasoner; + private void loadModel(){ model = ModelFactory.createDefaultModel(); for (KnowledgeSource ks : reasoner.getSources()) { if(ks instanceof OWLFile){ @@ -314,6 +392,14 @@ } catch (IOException e) { e.printStackTrace(); } + } else if(ks instanceof OWLAPIOntology){ + ByteArrayInputStream bais = new ByteArrayInputStream(((OWLAPIOntology) ks).getConverter().convert(((OWLAPIOntology) ks).getOntology())); + model.read(bais, null); + try { + bais.close(); + } catch (IOException e) { + e.printStackTrace(); + } } } } @@ -328,14 +414,14 @@ private EvaluatedQueryTree<String> evaluate(QueryTree<String> tree, boolean useSpecifity){ //1. get a score for the coverage = recall oriented //compute positive examples which are not covered by LGG - Set<QueryTree<String>> uncoveredPositiveExampleTrees = getUncoveredTrees(tree, currentPosExampleTrees); - Set<Individual> uncoveredPosExamples = new HashSet<Individual>(); + List<QueryTree<String>> uncoveredPositiveExampleTrees = getUncoveredTrees(tree, currentPosExampleTrees); + Set<Individual> uncoveredPosExamples = new TreeSet<Individual>(); for (QueryTree<String> queryTree : uncoveredPositiveExampleTrees) { uncoveredPosExamples.add(tree2Individual.get(queryTree)); } //compute negative examples which are covered by LGG Collection<QueryTree<String>> coveredNegativeExampleTrees = getCoveredTrees(tree, currentNegExampleTrees); - Set<Individual> coveredNegExamples = new HashSet<Individual>(); + Set<Individual> coveredNegExamples = new TreeSet<Individual>(); for (QueryTree<String> queryTree : coveredNegativeExampleTrees) { coveredNegExamples.add(tree2Individual.get(queryTree)); } @@ -346,7 +432,8 @@ ? 0 : coveredPositiveExamples / (double)(coveredPositiveExamples + coveredNegativeExampleTrees.size()); - double coverageScore = Heuristics.getFScore(recall, precision); + double beta = 0.5; + double coverageScore = Heuristics.getFScore(recall, precision, beta); //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented int nrOfSpecificNodes = 0; @@ -364,8 +451,8 @@ double score = coverageWeight * coverageScore + specifityWeight * specifityScore; QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, - Sets.difference(currentPosExamples, uncoveredPosExamples), uncoveredPosExamples, - coveredNegExamples, Sets.difference(currentNegExamples, coveredNegExamples), + new TreeSet<Individual>(Sets.difference(currentPosExamples, uncoveredPosExamples)), uncoveredPosExamples, + coveredNegExamples, new TreeSet<Individual>(Sets.difference(currentNegExamples, coveredNegExamples)), specifityScore, nrOfSpecificNodes); // QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, @@ -400,8 +487,8 @@ * @param allTrees * @return */ - private Set<QueryTree<String>> getUncoveredTrees(QueryTree<String> tree, List<QueryTree<String>> allTrees){ - Set<QueryTree<String>> uncoveredTrees = new LinkedHashSet<QueryTree<String>>(); + private List<QueryTree<String>> getUncoveredTrees(QueryTree<String> tree, List<QueryTree<String>> allTrees){ + List<QueryTree<String>> uncoveredTrees = new ArrayList<QueryTree<String>>(); for (QueryTree<String> queryTree : allTrees) { boolean subsumed = queryTree.isSubsumedBy(tree); if(!subsumed){ @@ -470,4 +557,33 @@ } todoList.add(solution); } + + /** + * @param noisePercentage the noisePercentage to set + */ + public void setNoisePercentage(double noisePercentage) { + this.noisePercentage = noisePercentage; + } + + /** + * @param maxExecutionTimeInSeconds the maxExecutionTimeInSeconds to set + */ + public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) { + this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; + } + + /** + * @param coverageBeta the coverageBeta to set + */ + public void setCoverageBeta(double coverageBeta) { + this.coverageBeta = coverageBeta; + } + + /* (non-Javadoc) + * @see java.lang.Object#clone() + */ + @Override + public Object clone() throws CloneNotSupportedException { + return new QTL2Disjunctive(this); + } } Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QTL2DisjunctiveMT.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -0,0 +1,559 @@ +package org.dllearner.algorithms.qtl; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.PriorityBlockingQueue; +import java.util.concurrent.TimeUnit; + +import org.apache.log4j.Logger; +import org.dllearner.algorithms.qtl.cache.QueryTreeCache; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl.LiteralNodeConversionStrategy; +import org.dllearner.algorithms.qtl.operations.lgg.EvaluatedQueryTree; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; +import org.dllearner.core.AbstractCELA; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.ComponentAnn; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.learningproblems.QueryTreeScore; +import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; +import org.dllearner.utilities.owl.OWLAPIConverter; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.util.SimpleShortFormProvider; +import org.springframework.beans.factory.annotation.Autowired; + +import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl; + +import com.google.common.collect.Sets; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; + +@ComponentAnn(name="query tree learner with noise (disjunctive)", shortName="qtl2dis", version=0.8) +public class QTL2DisjunctiveMT extends AbstractCELA { + + + private static final Logger logger = Logger.getLogger(QTL2DisjunctiveMT.class.getName()); + + private LGGGenerator<String> lggGenerator = new LGGGeneratorImpl<String>(); + + private BlockingQueue<EvaluatedQueryTree<String>> todoList; + private SortedSet<EvaluatedQueryTree<String>> solutions; + + private double currentlyBestScore = 0d; + + private List<QueryTree<String>> currentPosExampleTrees; + private List<QueryTree<String>> currentNegExampleTrees; + + private Map<QueryTree<String>, Individual> tree2Indivual; + + private double coverageWeight = 0.8; + private double specifityWeight = 0.2; + + private QueryTreeCache treeCache; + + private PosNegLP lp; + + private Model model; + + private AbstractReasonerComponent reasoner; + + private volatile boolean stop; + private boolean isRunning; + + private Monitor subMon; + private Monitor lggMon; + + private final EvaluatedQueryTree<String> STOP_ELEMENT = new EvaluatedQueryTree<String>(new QueryTreeImpl<String>("STOP"), null, null, null); + + + public QTL2DisjunctiveMT() {} + + public QTL2DisjunctiveMT(PosNegLP learningProblem, AbstractReasonerComponent reasoner) throws LearningProblemUnsupportedException{ + this.lp = learningProblem; + this.reasoner = reasoner; + + } + + public QTL2DisjunctiveMT(PosNegLP lp, Model model) { + this.lp = lp; + this.model = model; + } + + public EvaluatedQueryTree<String> getBestSolution(){ + return solutions.first(); + } + + /* (non-Javadoc) + * @see org.dllearner.core.Component#init() + */ + @Override + public void init() throws ComponentInitException { + logger.info("Initializing..."); + treeCache = new QueryTreeCache(model); + tree2Indivual = new HashMap<QueryTree<String>, Individual>(lp.getPositiveExamples().size()+lp.getNegativeExamples().size()); + + currentPosExampleTrees = new ArrayList<QueryTree<String>>(lp.getPositiveExamples().size()); + currentNegExampleTrees = new ArrayList<QueryTree<String>>(lp.getNegativeExamples().size()); + + //get the query trees + QueryTree<String> queryTree; + for (Individual ind : lp.getPositiveExamples()) { + queryTree = treeCache.getQueryTree(ind.getName()); + tree2Indivual.put(queryTree, ind); + currentPosExampleTrees.add(queryTree); + } + for (Individual ind : lp.getNegativeExamples()) { + queryTree = treeCache.getQueryTree(ind.getName()); + tree2Indivual.put(queryTree, ind); + currentNegExampleTrees.add(treeCache.getQueryTree(ind.getName())); + } + + //some logging + subMon = MonitorFactory.getTimeMonitor("subsumption-mon"); + lggMon = MonitorFactory.getTimeMonitor("lgg-mon"); + + //console rendering of class expressions + ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); + ToStringRenderer.getInstance().setShortFormProvider(new SimpleShortFormProvider()); + } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#start() + */ + @Override + public void start() { + logger.info("Running..."); + stop = false; + isRunning = true; + long startTime = System.currentTimeMillis(); + + subMon = MonitorFactory.getTimeMonitor("subsumption-mon"); + lggMon = MonitorFactory.getTimeMonitor("lgg-mon"); + + + //outer loop: compute LGG, pick best solution and remove all covered positive and negative examples + List<EvaluatedQueryTree<String>> unionSolutions = new ArrayList<EvaluatedQueryTree<String>>(); + do { + //compute LGG + computeLGG(); + + //pick best solution computed so far + EvaluatedQueryTree<String> bestSolution = solutions.first(); + unionSolutions.add(bestSolution); + logger.info("#Uncovered pos. examples:" + bestSolution.getFalseNegatives().size()); + + //remove all covered examples + QueryTree<String> tree; + for (Iterator<QueryTree<String>> iterator = currentPosExampleTrees.iterator(); iterator.hasNext();) { + tree = iterator.next(); + if(tree.isSubsumedBy(bestSolution.getTree())){ + iterator.remove(); + } + } + for (Iterator<QueryTree<String>> iterator = currentNegExampleTrees.iterator(); iterator.hasNext();) { + tree = iterator.next(); + if(tree.isSubsumedBy(bestSolution.getTree())){ + iterator.remove(); + } + } + } while (!(stop || currentPosExampleTrees.isEmpty())); + + + } + + private void computeLGG(){ + currentlyBestScore = 0d; + initTodoList(currentPosExampleTrees, currentNegExampleTrees); + long startTime = System.currentTimeMillis(); + int nrOfThreads = Runtime.getRuntime().availableProcessors() - 1; + nrOfThreads = 2; + ExecutorService es = Executors.newFixedThreadPool(nrOfThreads); + for(int i = 0; i < nrOfThreads; i++){ + es.submit(new QueryTreeProcessor()); + } + es.shutdown(); + try { + es.awaitTermination(1, TimeUnit.HOURS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + long endTime = System.currentTimeMillis(); + logger.info("Finished in " + (endTime-startTime) + "ms."); + EvaluatedDescription bestSolution = getCurrentlyBestEvaluatedDescription(); + ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); + ToStringRenderer.getInstance().setShortFormProvider(new SimpleShortFormProvider()); +// solutions.first().getTree().dump(); + logger.info("Best solution:\n" + OWLAPIConverter.getOWLAPIDescription(bestSolution.getDescription()) + "\n(" + bestSolution.getScore() + ")"); + + logger.trace("LGG time: " + lggMon.getTotal() + "ms"); + logger.trace("Avg. LGG time: " + lggMon.getAvg() + "ms"); + logger.trace("#LGG computations: " + lggMon.getHits()); + logger.trace("Subsumption test time: " + subMon.getTotal() + "ms"); + logger.trace("Avg. subsumption test time: " + subMon.getAvg() + "ms"); + logger.trace("#Subsumption tests: " + subMon.getHits()); + } + + /* (non-Javadoc) + * @see org.dllearner.core.StoppableLearningAlgorithm#stop() + */ + @Override + public void stop() { + stop = true; + } + + /* (non-Javadoc) + * @see org.dllearner.core.AbstractCELA#getCurrentlyBestDescription() + */ + @Override + public Description getCurrentlyBestDescription() { + return getCurrentlyBestEvaluatedDescription().getDescription(); + } + + /* (non-Javadoc) + * @see org.dllearner.core.AbstractCELA#getCurrentlyBestEvaluatedDescription() + */ + @Override + public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { + EvaluatedQueryTree<String> bestSolution = solutions.first(); + Description description = DLLearnerDescriptionConvertVisitor.getDLLearnerDescription( + bestSolution.getTree().asOWLClassExpression(LiteralNodeConversionStrategy.FACET_RESTRICTION)); + return new EvaluatedDescription(description, bestSolution.getTreeScore()); + } + + /* (non-Javadoc) + * @see org.dllearner.core.StoppableLearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + return isRunning; + } + + @Autowired + public void setLearningProblem(PosNegLP learningProblem) { + this.lp = learningProblem; + } + + @Autowired + public void setReasoner(AbstractReasonerComponent reasoner){ + this.reasoner = reasoner; + model = ModelFactory.createDefaultModel(); + for (KnowledgeSource ks : reasoner.getSources()) { + if(ks instanceof OWLFile){ + try { + model.read(((OWLFile) ks).getURL().openStream(), null); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * @return the treeCache + */ + public QueryTreeCache getTreeCache() { + return treeCache; + } + + private EvaluatedQueryTree<String> evaluate(QueryTree<String> tree, boolean useSpecifity){ + //1. get a score for the coverage = recall oriented + //compute positive examples which are not covered by LGG + Collection<QueryTree<String>> uncoveredPositiveExampleTrees = getUncoveredTrees(tree, currentPosExampleTrees); + Set<Individual> uncoveredPosExamples = new HashSet<Individual>(); + for (QueryTree<String> queryTree : uncoveredPositiveExampleTrees) { + uncoveredPosExamples.add(tree2Indivual.get(queryTree)); + } + //compute negative examples which are covered by LGG + Collection<QueryTree<String>> coveredNegativeExampleTrees = getCoveredTrees(tree, currentNegExampleTrees); + Set<Individual> coveredNegExamples = new HashSet<Individual>(); + for (QueryTree<String> queryTree : coveredNegativeExampleTrees) { + coveredNegExamples.add(tree2Indivual.get(queryTree)); + } + //compute score + int coveredPositiveExamples = currentPosExampleTrees.size() - uncoveredPositiveExampleTrees.size(); + double recall = coveredPositiveExamples / (double)currentPosExampleTrees.size(); + double precision = (coveredNegativeExampleTrees.size() + coveredPositiveExamples == 0) + ? 0 + : coveredPositiveExamples / (double)(coveredPositiveExamples + coveredNegativeExampleTrees.size()); + + double coverageScore = recall;//Heuristics.getFScore(recall, precision); + + //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented + int nrOfSpecificNodes = 0; + for (QueryTree<String> childNode : tree.getChildrenClosure()) { + if(!childNode.getUserObject().equals("?")){ + nrOfSpecificNodes++; + } + } + double specifityScore = Math.log(nrOfSpecificNodes); + + //3.compute the total score + double score = coverageWeight * coverageScore + specifityWeight * specifityScore; + + QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, + uncoveredPosExamples, Sets.difference(lp.getPositiveExamples(), uncoveredPosExamples), + coveredNegExamples, Sets.difference(lp.getNegativeExamples(), coveredNegExamples), + specifityScore, nrOfSpecificNodes); + + EvaluatedQueryTree<String> evaluatedTree = new EvaluatedQueryTree<String>(tree, uncoveredPositiveExampleTrees, coveredNegativeExampleTrees, queryTreeScore); + + return evaluatedTree; + } + + /** + * Initializes the todo list with all distinct trees contained in the given list {@code trees}. + * Firstly, distinct trees are computed and afterwards, for each tree a score is computed. + * @param trees + */ + private void initTodoList(List<QueryTree<String>> posExamples, List<QueryTree<String>> negExamples){ + todoList = new PriorityBlockingQueue<EvaluatedQueryTree<String>>(); + solutions = new TreeSet<EvaluatedQueryTree<String>>(); +// EvaluatedQueryTree<String> dummy = new EvaluatedQueryTree<String>(new QueryTreeImpl<String>((N)"TOP"), trees, 0d); +// todoList.add(dummy); + //compute distinct trees + Collection<QueryTree<String>> distinctTrees = new ArrayList<QueryTree<String>>(); + for (QueryTree<String> queryTree : posExamples) { + boolean distinct = true; + for (QueryTree<String> otherTree : distinctTrees) { + if(!queryTree.equals(otherTree)){ + if(queryTree.isSameTreeAs(otherTree)){ + distinct = false; + break; + } + } + } + if(distinct){ + distinctTrees.add(queryTree); + } + } + for (QueryTree<String> queryTree : distinctTrees) {//System.out.println(queryTree.getStringRepresentation()); + EvaluatedQueryTree<String> evaluatedQueryTree = evaluate(queryTree, false); + todoList.add(evaluatedQueryTree); + } + } + + /** + * Return all trees from the given list {@code allTrees} which are not already subsumed by {@code tree}. + * @param tree + * @param allTrees + * @return + */ + private Collection<QueryTree<String>> getCoveredTrees(QueryTree<String> tree, List<QueryTree<String>> trees){ + Collection<QueryTree<String>> coveredTrees = new ArrayList<QueryTree<String>>(); + for (QueryTree<String> queryTree : trees) { + boolean subsumed = queryTree.isSubsumedBy(tree); + if(subsumed){ + coveredTrees.add(queryTree); + } + } + return coveredTrees; + } + + /** + * Return all trees from the given list {@code allTrees} which are not already subsumed by {@code tree}. + * @param tree + * @param allTrees + * @return + */ + private Collection<QueryTree<String>> getUncoveredTrees(QueryTree<String> tree, List<QueryTree<String>> allTrees){ + Collection<QueryTree<String>> uncoveredTrees = new ArrayList<QueryTree<String>>(); + for (QueryTree<String> queryTree : allTrees) { + boolean subsumed = queryTree.isSubsumedBy(tree); + if(!subsumed){ + uncoveredTrees.add(queryTree); + } + } + return uncoveredTrees; + } + + private boolean sameTrees(QueryTree<String> tree1, QueryTree<String> tree2){ + return tree1.isSubsumedBy(tree2) && tree2.isSubsumedBy(tree1); + } + + private synchronized boolean terminationCriteriaSatisfied(){ + return stop || todoList.isEmpty() || currentPosExampleTrees.isEmpty(); + } + + /** + * Add tree to todo list if not already contained in that list or the solutions. + * @param solution + */ + private void todo(EvaluatedQueryTree<String> solution){ + //check if not already contained in todo list + for (EvaluatedQueryTree<String> evTree : todoList) { + if(sameTrees(solution.getTree(), evTree.getTree())){ + return; + } + } + //check if not already contained in solutions + for (EvaluatedQueryTree<String> evTree : solutions) { + if(sameTrees(solution.getTree(), evTree.getTree())){ + return; + } + } + try { + todoList.put(solution); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + class QueryTreeProcessor implements Runnable { + + volatile boolean isRunning; + LGGGenerator<String> lggGenerator = new LGGGeneratorImpl<String>(); + + /** + * + */ + public QueryTreeProcessor() { + } + + /* (non-Javadoc) + * @see java.lang.Runnable#run() + */ + @Override + public void run() { + long startTime = System.currentTimeMillis(); + while(!terminationCriteriaSatisfied()){ + double currentlyBestScore = 0d; + try { + long t1 = System.currentTimeMillis(); + EvaluatedQueryTree<String> evaluatedQueryTree = todoList.take(); + long t2 = System.currentTimeMillis(); + System.out.println(Thread.currentThread().getId() + "\t waiting time:" + (t2-t1)); + for (QueryTree<String> example : evaluatedQueryTree.getFalseNegatives()) { + //compute the LGG +// lggMon.start(); + QueryTree<String> lgg = lggGenerator.getLGG(evaluatedQueryTree.getTree(), example); +// lggMon.stop(); + + //evaluate the LGG + EvaluatedQueryTree<String> solution = evaluate(lgg, true); + + if(solution.getScore() >= currentlyBestScore){ + //add to todo list, if not already contained in todo list or solution list + todo(solution); + if(solution.getScore() > currentlyBestScore){ + logger.info("Got better solution:" + solution.getTreeScore()); + } + currentlyBestScore = solution.getScore(); + } + } + long t3 = System.currentTimeMillis(); + System.out.println(Thread.currentThread().getId() + "\t processing time:" + (t3-t2)); + // add currently processed tree to solutions + solutions.add(evaluatedQueryTree); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + System.out.println(System.currentTimeMillis() + ":" + Thread.currentThread().getId() + " finished"); + } + + private EvaluatedQueryTree<String> evaluate(QueryTree<String> tree, boolean useSpecifity){ + //1. get a score for the coverage = recall oriented + //compute positive examples which are not covered by LGG + Collection<QueryTree<String>> uncoveredPositiveExampleTrees = getUncoveredTrees(tree, currentPosExampleTrees); + Set<Individual> uncoveredPosExamples = new HashSet<Individual>(); + for (QueryTree<String> queryTree : uncoveredPositiveExampleTrees) { + uncoveredPosExamples.add(tree2Indivual.get(queryTree)); + } + //compute negative examples which are covered by LGG + Collection<QueryTree<String>> coveredNegativeExampleTrees = getCoveredTrees(tree, currentNegExampleTrees); + Set<Individual> coveredNegExamples = new HashSet<Individual>(); + for (QueryTree<String> queryTree : coveredNegativeExampleTrees) { + coveredNegExamples.add(tree2Indivual.get(queryTree)); + } + //compute score + int coveredPositiveExamples = currentPosExampleTrees.size() - uncoveredPositiveExampleTrees.size(); + double recall = coveredPositiveExamples / (double)currentPosExampleTrees.size(); + double precision = (coveredNegativeExampleTrees.size() + coveredPositiveExamples == 0) + ? 0 + : coveredPositiveExamples / (double)(coveredPositiveExamples + coveredNegativeExampleTrees.size()); + + double coverageScore = recall;//Heuristics.getFScore(recall, precision); + + //2. get a score for the specifity of the query, i.e. how many edges/nodes = precision oriented + int nrOfSpecificNodes = 0; + for (QueryTree<String> childNode : tree.getChildrenClosure()) { + if(!childNode.getUserObject().equals("?")){ + nrOfSpecificNodes++; + } + } + double specifityScore = Math.log(nrOfSpecificNodes); + + //3.compute the total score + double score = coverageWeight * coverageScore + specifityWeight * specifityScore; + + QueryTreeScore queryTreeScore = new QueryTreeScore(score, coverageScore, + uncoveredPosExamples, Sets.difference(lp.getPositiveExamples(), uncoveredPosExamples), + coveredNegExamples, Sets.difference(lp.getNegativeExamples(), coveredNegExamples), + specifityScore, nrOfSpecificNodes); + + EvaluatedQueryTree<String> evaluatedTree = new EvaluatedQueryTree<String>(tree, uncoveredPositiveExampleTrees, coveredNegativeExampleTrees, queryTreeScore); + + return evaluatedTree; + } + + /** + * Return all trees from the given list {@code allTrees} which are not already subsumed by {@code tree}. + * @param tree + * @param allTrees + * @return + */ + private Collection<QueryTree<String>> getCoveredTrees(QueryTree<String> tree, List<QueryTree<String>> trees){ + Collection<QueryTree<String>> coveredTrees = new ArrayList<QueryTree<String>>(); + for (QueryTree<String> queryTree : trees) { + boolean subsumed = queryTree.isSubsumedBy(tree); + if(subsumed){ + coveredTrees.add(queryTree); + } + } + return coveredTrees; + } + + /** + * Return all trees from the given list {@code allTrees} which are not already subsumed by {@code tree}. + * @param tree + * @param allTrees + * @return + */ + private Collection<QueryTree<String>> getUncoveredTrees(QueryTree<String> tree, List<QueryTree<String>> allTrees){ + Collection<QueryTree<String>> uncoveredTrees = new ArrayList<QueryTree<String>>(); + for (QueryTree<String> queryTree : allTrees) { + boolean subsumed = queryTree.isSubsumedBy(tree); + if(!subsumed){ + uncoveredTrees.add(queryTree); + } + } + return uncoveredTrees; + } + + } + +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/QueryTreeHeuristic.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -0,0 +1,79 @@ +/** + * + */ +package org.dllearner.algorithms.qtl; + +import java.util.Comparator; +import java.util.Set; + +import org.dllearner.algorithms.qtl.operations.lgg.EvaluatedQueryTree; +import org.dllearner.core.AbstractComponent; +import org.dllearner.core.ComponentAnn; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.Heuristic; +import org.dllearner.core.owl.Individual; +import org.dllearner.learningproblems.Heuristics; +import org.dllearner.learningproblems.QueryTreeScore; +import org.dllearner.utilities.owl.ConceptComparator; + +/** + * @author Lorenz Buehmann + * + */ +@ComponentAnn(name = "QueryTreeHeuristic", shortName = "qtree_heuristic", version = 0.1) +public class QueryTreeHeuristic extends AbstractComponent implements Heuristic, Comparator<EvaluatedQueryTree<String>>{ + + // F score beta value + private double coverageBeta = 1; + + private double coverageWeight = 0.8; + + private double specifityWeight = 0.1; + + // syntactic comparison as final comparison criterion + private ConceptComparator conceptComparator = new ConceptComparator(); + + /* (non-Javadoc) + * @see org.dllearner.core.Component#init() + */ + @Override + public void init() throws ComponentInitException { + } + + public double getScore(EvaluatedQueryTree<String> tree){ + QueryTreeScore treeScore = tree.getTreeScore(); + + //TODO + double score = treeScore.getScore(); + + return score; + } + + private double getPredictedAccuracy(EvaluatedQueryTree<String> tree){ + QueryTreeScore treeScore = tree.getTreeScore(); + + Set<Individual> truePositives = treeScore.getCoveredPositives(); + Set<Individual> trueNegatives = treeScore.getNotCoveredNegatives(); + Set<Individual> falsePositives = treeScore.getNotCoveredPositives(); + Set<Individual> falseNegatives = treeScore.getCoveredNegatives(); + return 0; + + } + + /* (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + @Override + public int compare(EvaluatedQueryTree<String> tree1, EvaluatedQueryTree<String> tree2) { + double diff = getScore(tree1) - getScore(tree2); + + if (diff > 0) { + return 1; + } else if (diff < 0) { + return -1; + } else { + return conceptComparator.compare(tree1.asEvaluatedDescription().getDescription(), tree2.asEvaluatedDescription().getDescription()); + } + } + +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-07 11:25:54 UTC (rev 4261) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/datastructures/impl/QueryTreeImpl.java 2014-05-07 13:43:54 UTC (rev 4262) @@ -1488,7 +1488,7 @@ private String prefixed(Map<String, String> prefixes, String uri){ if(uri.startsWith("http://")){ - for (Entry<String, String> entry : prefixes.entrySet()) {System.out.println(entry); + for (Entry<String, String> entry : prefixes.entrySet()) { String prefix = entry.getKey(); String ns = entry.getValue(); if(uri.startsWith(ns)){ Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/qtl/impl/QueryTre... [truncated message content] |
From: <lor...@us...> - 2014-05-07 11:25:58
|
Revision: 4261 http://sourceforge.net/p/dl-learner/code/4261 Author: lorenz_b Date: 2014-05-07 11:25:54 +0000 (Wed, 07 May 2014) Log Message: ----------- Added eprocurement eval script. Added Paths: ----------- trunk/scripts/src/main/java/org/dllearner/scripts/OWLAxiomsHTMLWriter.java trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java trunk/scripts/src/main/java/org/dllearner/scripts/pattern/FixPointDetection.java trunk/scripts/src/main/java/org/dllearner/scripts/pattern/UserEvaluation.java trunk/scripts/src/main/resources/db_settings.ini Added: trunk/scripts/src/main/java/org/dllearner/scripts/OWLAxiomsHTMLWriter.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/OWLAxiomsHTMLWriter.java (rev 0) +++ trunk/scripts/src/main/java/org/dllearner/scripts/OWLAxiomsHTMLWriter.java 2014-05-07 11:25:54 UTC (rev 4261) @@ -0,0 +1,91 @@ +package org.dllearner.scripts; + +import java.io.File; +import java.io.FileOutputStream; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.SortedMap; +import java.util.TreeMap; + +import org.dllearner.utilities.MapUtils; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl; + +public class OWLAxiomsHTMLWriter { + + public static void main(String[] args) throws Exception{ + if(args.length != 2){ + System.out.println("Usage: OWLAxiomsHTMLWriter <ontology> <targetFile>"); + } + ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); + + String ontologyURL = args[0]; + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory dataFactory = man.getOWLDataFactory(); + OWLOntology ontology = man.loadOntologyFromOntologyDocument(new File(ontologyURL)); + OWLAnnotationProperty anProp = dataFactory.getOWLAnnotationProperty(IRI.create("http://www.dl-learner.org/ontologies/enrichment.owl#confidence")); + + StringBuilder sb = new StringBuilder(); + DecimalFormat dfPercent = new DecimalFormat("0.00%"); + sb.append("<html>\n"); + sb.append("<table border=\"3\">\n"); + sb.append("<thead><tr><th>Source Class</th><th>Equivalent Class Expression</th><th>Accuracy</th></tr></thead>\n"); + sb.append("<tbody>\n"); + + SortedMap<OWLClass, Map<OWLClassExpression, Double>> map = new TreeMap<OWLClass, Map<OWLClassExpression,Double>>(); + for (OWLEquivalentClassesAxiom axiom : ontology.getAxioms(AxiomType.EQUIVALENT_CLASSES)) { + List<OWLClassExpression> classExpressionsAsList = axiom.getClassExpressionsAsList(); + OWLClass left = classExpressionsAsList.get(0).asOWLClass(); + if(!left.toStringID().startsWith("http://dbpedia.org/ontology/"))continue;//skip not DBpedia + OWLClassExpression right = classExpressionsAsList.get(1); + OWLLiteral lit = (OWLLiteral) axiom.getAnnotations(anProp).iterator().next().getValue(); + double accuracy = lit.parseDouble(); + Map<OWLClassExpression, Double> equivalentClasses = map.get(left); + if(equivalentClasses == null){ + equivalentClasses = new HashMap<OWLClassExpression, Double>(); + map.put(left, equivalentClasses); + } + equivalentClasses.put(right, accuracy); + } + + for (Entry<OWLClass, Map<OWLClassExpression, Double>> entry : map.entrySet()) { + OWLClass cls = entry.getKey(); + Map<OWLClassExpression, Double> equivalentClasses = entry.getValue(); + List<Entry<OWLClassExpression, Double>> sorted = MapUtils.sortByValues(equivalentClasses); + sb.append("<tr><th rowspan=\"" + (sorted.size()+1) + "\">" + cls.toString() + "</th>\n"); + for (Entry<OWLClassExpression, Double> expr : sorted) { + OWLClassExpression classExpression = expr.getKey(); + Double value = expr.getValue(); + sb.append("<tr>"); + sb.append("<td>" + classExpression.toString() + "</td>"); + sb.append("<td>" + dfPercent.format(value.doubleValue()) + "</td>"); + sb.append("</tr>\n"); + } + + } + + sb.append("</tbody>\n"); + sb.append("</table>\n"); + sb.append("</html>\n"); + + FileOutputStream fos = new FileOutputStream(new File(args[1])); + fos.write(sb.toString().getBytes()); + fos.close(); + } + +} Added: trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java (rev 0) +++ trunk/scripts/src/main/java/org/dllearner/scripts/RAChallenge.java 2014-05-07 11:25:54 UTC (rev 4261) @@ -0,0 +1,299 @@ +/** + * + */ +package org.dllearner.scripts; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FilenameFilter; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.algorithms.celoe.OEHeuristicRuntime; +import org.dllearner.algorithms.elcopy.ELLearningAlgorithm; +import org.dllearner.algorithms.qtl.QueryTreeFactory; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.impl.QueryTreeFactoryImpl; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; +import org.dllearner.core.AbstractCELA; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGeneratorImpl; +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.refinementoperators.RhoDRDown; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.ToStringRenderer; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.SimpleShortFormProvider; + +import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl; + +import com.hp.hpl.jena.query.QueryExecution; +import com.hp.hpl.jena.query.QueryExecutionFactory; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.ResultSetFormatter; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.rdf.model.RDFNode; +import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.rdf.model.StmtIterator; +import com.hp.hpl.jena.vocabulary.OWL; +import com.hp.hpl.jena.vocabulary.RDF; + +/** + * @author Lorenz Buehmann + * + */ +public class RAChallenge { + + + private static boolean useEL = false; + + static Map<String, String> prefixes = new HashMap<>(); + + private static String baseURI = "http://bio2rdf.org/ra.challenge:"; + + static { + +// prefixes.put("ra", "http://bio2rdf.org/ra.challenge:"); + prefixes.put("ra-voc", "http://bio2rdf.org/ra.challenge_vocabulary:"); + prefixes.put("dbsnp", "http://bio2rdf.org/dbsnp:"); + prefixes.put("xsd", "http://www.w3.org/2001/XMLSchema#"); + prefixes.put("foaf", "http://xmlns.com/foaf/0.1/"); + prefixes.put("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); + prefixes.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + prefixes.put("drug-voc", "http://bio2rdf.org/drugbank_vocabulary:"); + + + } + + public static void main(String[] args) throws Exception{ + //load the data + File dataDir = new File(args[0]); + File[] files = dataDir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".nt") || name.endsWith(".ttl") || name.endsWith(".rdf") || name.endsWith(".owl"); + } + }); + System.out.println("loading data..."); + Model model = ModelFactory.createDefaultModel(); + for (File file : files) { + model.read(new FileInputStream(file), null, "TURTLE"); + } + + analyzeData(model); + + //get the positive and negative examples via SPARQL + //<http://bio2rdf.org/ra.challenge:1877000> <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> . + System.out.println("extracting pos/neg examples..."); + SortedSet<Individual> posExamples = new TreeSet<Individual>(); + SortedSet<Individual> negExamples = new TreeSet<Individual>(); + String query = "SELECT ?s WHERE {?s <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> \"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>} limit 400"; + QueryExecution qe = QueryExecutionFactory.create(query, model); + ResultSet rs = qe.execSelect(); + QuerySolution qs; + while(rs.hasNext()){ + qs = rs.next(); + posExamples.add(new Individual(qs.getResource("s").getURI())); + } + query = "SELECT ?s WHERE {?s <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> \"false\"^^<http://www.w3.org/2001/XMLSchema#boolean>} limit 400"; + qe = QueryExecutionFactory.create(query, model); + rs = qe.execSelect(); + while(rs.hasNext()){ + qs = rs.next(); + negExamples.add(new Individual(qs.getResource("s").getURI())); + } + qe.close(); + System.out.println("#pos examples: " + posExamples.size()); + System.out.println("#neg examples: " + negExamples.size()); + + //remove triples with property non-responder + model.remove(model.listStatements(null, model.createProperty("http://bio2rdf.org/ra.challenge_vocabulary:non-responder"), (RDFNode)null)); + + //enrich with additional data + enrich(model); + + //check the LGG +// computeLGG(model, posExamples); + + //convert JENA model to OWL API ontology + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + model.write(baos , "N-TRIPLES"); + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLOntology ontology = man.loadOntologyFromOntologyDocument(new ByteArrayInputStream(baos.toByteArray())); + + //init knowledge source + KnowledgeSource ks = new OWLAPIOntology(ontology); + + //init reasoner + System.out.println("initializing reasoner..."); + OWLAPIReasoner baseReasoner = new OWLAPIReasoner(ks); +// baseReasoner.setReasonerTypeString("elk"); + baseReasoner.init(); + FastInstanceChecker rc = new FastInstanceChecker(ks); + rc.setReasonerComponent(baseReasoner); + rc.setBaseURI(baseURI); + rc.setPrefixes(prefixes); + rc.init(); + + //init learning problem + System.out.println("initializing learning problem..."); + PosNegLPStandard lp = new PosNegLPStandard(rc, posExamples, negExamples); + lp.setUseApproximations(true); + lp.init(); + + //init learning algorithm + System.out.println("initializing learning algorithm..."); + AbstractCELA la; + if(useEL){ + la = new ELLearningAlgorithm(lp, rc); + ((ELLearningAlgorithm) la).setNoisePercentage(30); + ((ELLearningAlgorithm) la).setMaxNrOfResults(50); + ((ELLearningAlgorithm) la).setTreeSearchTimeSeconds(10); + } else { + OEHeuristicRuntime heuristic = new OEHeuristicRuntime(); + heuristic.setExpansionPenaltyFactor(0.1); + la = new CELOE(lp, rc); + ((CELOE) la).setHeuristic(heuristic); + ((CELOE) la).setMaxExecutionTimeInSeconds(100); + ((CELOE) la).setNoisePercentage(50); + ((CELOE) la).setMaxNrOfResults(50); + ((CELOE) la).setWriteSearchTree(true); + ((CELOE) la).setReplaceSearchTree(true); + ((CELOE) la).setStartClass(new NamedClass("http://xmlns.com/foaf/0.1/Person")); + RhoDRDown op = new RhoDRDown(); + op.setUseHasValueConstructor(true); + op.setUseObjectValueNegation(true); + op.setReasoner(rc); + op.init(); +// ((CELOE) la).setOperator(op); + } + la.init(); + + la.start(); + } + + /** + * Do some statistical queries. + * @param model + */ + private static void analyzeData(Model model){ + String query = "SELECT (COUNT(DISTINCT ?s)AS ?cnt) WHERE {?s <http://bio2rdf.org/ra.challenge_vocabulary:has-two> ?o.} "; + QueryExecution qe = QueryExecutionFactory.create(query, model); + ResultSet rs = qe.execSelect(); + System.out.println(ResultSetFormatter.asText(rs)); + + query = "SELECT ?o (COUNT(?s) AS ?cnt) WHERE {?s <http://bio2rdf.org/ra.challenge_vocabulary:has-two> ?o." +// + "OPTIONAL{?s_res <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> \"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>.FILTER(?s=s_res)} " +// + "?s_non_res <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> \"false\"^^<http://www.w3.org/2001/XMLSchema#boolean>" + + "}" + + " GROUP BY ?o ORDER BY DESC(?cnt)"; + qe = QueryExecutionFactory.create(query, model); + rs = qe.execSelect(); + System.out.println(ResultSetFormatter.asText(rs)); + + query = "SELECT ?o (COUNT(?s) AS ?cnt) WHERE {" + + "?s <http://bio2rdf.org/ra.challenge_vocabulary:has-two> ?o." + + "?s <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> \"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>." + + "}" + + " GROUP BY ?o ORDER BY DESC(?cnt)"; + qe = QueryExecutionFactory.create(query, model); + rs = qe.execSelect(); + System.out.println(ResultSetFormatter.asText(rs)); + + query = "SELECT ?o (COUNT(?s) AS ?total) (Min(?cnt_res) as ?responder) (Min(?cnt_non_res) as ?non_responder) WHERE {" + + "?s <http://bio2rdf.org/ra.challenge_vocabulary:has-two> ?o." + + "{SELECT ?o (COUNT(?s) AS ?cnt_res) WHERE {" + + "?s <http://bio2rdf.org/ra.challenge_vocabulary:has-two> ?o." + + "?s <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> \"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>." + + "} GROUP BY ?o}" + + "{SELECT ?o (COUNT(?s) AS ?cnt_non_res) WHERE {" + + "?s <http://bio2rdf.org/ra.challenge_vocabulary:has-two> ?o." + + "?s <http://bio2rdf.org/ra.challenge_vocabulary:non-responder> \"false\"^^<http://www.w3.org/2001/XMLSchema#boolean>." + + "}" + + " GROUP BY ?o}} GROUP BY ?o ORDER BY DESC(?total)"; + qe = QueryExecutionFactory.create(query, model); + rs = qe.execSelect(); + System.out.println(ResultSetFormatter.asText(rs)); + } + + private static void computeLGG(Model model, SortedSet<Individual> posExamples){ + QueryTreeFactory<String> queryTreeFactory = new QueryTreeFactoryImpl(); + + List<QueryTree<String>> posExampleTrees = new ArrayList<QueryTree<String>>(); + for (Individual ex : posExamples) { + QueryTreeImpl<String> tree = queryTreeFactory.getQueryTree(ex.getName(), model); + posExampleTrees.add(tree); + } + + LGGGenerator<String> lggGenerator = new LGGGeneratorImpl<String>(); + QueryTree<String> lgg = lggGenerator.getLGG(posExampleTrees); + String lggString = lgg.getStringRepresentation(true); + lggString = lggString.replace(baseURI, ""); + for (Entry<String, String> entry : prefixes.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + lggString = lggString.replace(value, key + ":"); + } + System.out.println(lggString); + + OWLClassExpression classExpression = lgg.asOWLClassExpression(); + ToStringRenderer.getInstance().setRenderer(new ManchesterOWLSyntaxOWLObjectRendererImpl()); + ToStringRenderer.getInstance().setShortFormProvider(new SimpleShortFormProvider()); + System.out.println(classExpression); + } + + private static void enrich(Model model) throws MalformedURLException, FileNotFoundException{ + System.out.println("enriching data..."); + SparqlEndpoint endpoint = new SparqlEndpoint(new URL("http://cu.drugbank.bio2rdf.org/sparql")); + +// StmtIterator stmtIterator = model.listStatements(null, RDF.type, (RDFNode)null); +// Model classes = ModelFactory.createDefaultModel(); +// while(stmtIterator.hasNext()){ +// Statement st = stmtIterator.next(); +// classes.add(classes.createStatement(st.getObject().asResource(), RDF.type, OWL.Class)); +// } +// classes.write(new FileOutputStream("classes.nt"), "TURTLE"); + + ConciseBoundedDescriptionGenerator cbdGen = new ConciseBoundedDescriptionGeneratorImpl(endpoint, "cache/drugbank"); + List<RDFNode> drugs = model.listObjectsOfProperty(model.getProperty("http://bio2rdf.org/ra.challenge_vocabulary:drug")).toList(); + Model drugbankData = ModelFactory.createDefaultModel(); + Model cbd; + for (RDFNode drug : drugs) { + cbd = cbdGen.getConciseBoundedDescription(drug.asResource().getURI(), 0, true); + drugbankData.add(cbd); + } + drugbankData.setNsPrefix("drug-voc", "http://bio2rdf.org/drugbank_vocabulary:"); + drugbankData.setNsPrefix("drug-res", "http://bio2rdf.org/drugbank_resource:"); + drugbankData.setNsPrefix("drug", "http://bio2rdf.org/drugbank:"); + + drugbankData.write(new FileOutputStream("drugbank.ttl"), "TURTLE", null); + model.add(drugbankData); + + + } +} Added: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java (rev 0) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EProcurementUseCase.java 2014-05-07 11:25:54 UTC (rev 4261) @@ -0,0 +1,290 @@ +/** + * + */ +package org.dllearner.scripts.evaluation; + +import static org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.Strategy.SIBLING; +import static org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.Strategy.SUPERCLASS; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedSet; + +import org.apache.log4j.Logger; +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.algorithms.elcopy.ELLearningAlgorithm; +import org.dllearner.algorithms.qtl.QueryTreeFactory; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.impl.QueryTreeFactoryImpl; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGenerator; +import org.dllearner.algorithms.qtl.operations.lgg.LGGGeneratorImpl; +import org.dllearner.core.AbstractCELA; +import org.dllearner.core.AbstractKnowledgeSource; +import org.dllearner.core.AbstractLearningProblem; +import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.kb.LocalModelBasedSparqlEndpointKS; +import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator; +import org.dllearner.kb.sparql.ConciseBoundedDescriptionGeneratorImpl; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.SPARQLReasoner; +import org.dllearner.refinementoperators.RhoDRDown; +import org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2; +import org.dllearner.utilities.owl.OWLEntityTypeAdder; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLOntology; + +import com.google.common.collect.Sets; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.vocabulary.OWL; +import com.hp.hpl.jena.vocabulary.RDFS; + +/** + * @author Lorenz Buehmann + * + */ +public class EProcurementUseCase { + + + private static final Logger logger = Logger.getLogger(EProcurementUseCase.class.getName()); + static final int maxNrOfPositiveExamples = 100; + static final int maxNrOfNegativeExamples = 200; + static boolean posOnly = false; + static int maxCBDDepth = 2; + static int maxNrOfResults = 100; + static int maxExecutionTimeInSeconds = 200; + static double noiseInPercentage = 50; + static boolean useNegation = false; + static boolean useAllConstructor = false; + static String testFolder = "logs/eprocurement"; + + static boolean useEL = false; + private static int maxClassExpressionDepth = 2; + + static Map<String, String> prefixes = new HashMap<String, String>();; + static { + prefixes.put("pc", "http://purl.org/procurement/public-contracts#"); + prefixes.put("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); + prefixes.put("skos", "http://www.w3.org/2004/02/skos/core#"); + prefixes.put("dcterms", "http://purl.org/dc/terms/"); + prefixes.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + prefixes.put("activities", "http://purl.org/procurement/public-contracts-activities#"); + prefixes.put("gr", "http://purl.org/goodrelations/v1#"); + prefixes.put("schema", "http://schema.org/"); + + + } + + /** + * @param args + */ + public static void main(String[] args) throws Exception{ + NamedClass posClass = new NamedClass("http://purl.org/procurement/public-contracts#SuccessfulTender"); + NamedClass negClass = new NamedClass("http://purl.org/procurement/public-contracts#UnsuccessfulTender"); + + //1. setup the knowledge base + Model model = ModelFactory.createDefaultModel(); + //the data + model.read(new FileInputStream("../test/eprocurement/dl-learner-sample-with-classes-pco.rdf"), null); + //the schema + Model schema = ModelFactory.createDefaultModel(); + schema.read(new FileInputStream("../test/eprocurement/pco.rdf"), null); + schema.add(schema.getResource("http://purl.org/procurement/public-contracts#SuccessfulTender"), + OWL.disjointWith, + schema.getResource("http://purl.org/procurement/public-contracts#UnsuccessfulTender")); + schema.add(schema.getResource("http://purl.org/procurement/public-contracts#SuccessfulTender"), + RDFS.subClassOf, + schema.getResource("http://purl.org/procurement/public-contracts#Tender")); + schema.add(schema.getResource("http://purl.org/procurement/public-contracts#UnsuccessfulTender"), + RDFS.subClassOf, + schema.getResource("http://purl.org/procurement/public-contracts#Tender")); +// schema.read(new URL("http://opendata.cz/pco/public-contracts.ttl").openStream(), null, "TURTLE"); + model.add(schema); + // get positive examples + SortedSet<Individual> positiveExamples = getExamples(model, posClass); + // get negative examples +// SortedSet<Individual> negativeExamples = getNegativeExamples(model, cls, positiveExamples); + SortedSet<Individual> negativeExamples = getExamples(model, negClass); + //get the lgg of the pos. examples +// showLGG(model, positiveExamples); + // build a sample of the kb + model = getSample(model, Sets.union(positiveExamples, negativeExamples)); + //add inferred entity types + OWLEntityTypeAdder.addEntityTypes(model); + //the ontology + model.add(schema); + //convert all into DL-Learner kb object + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + model.write(baos, "TURTLE"); + OWLOntology ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(new ByteArrayInputStream(baos.toByteArray())); + AbstractKnowledgeSource ks = new OWLAPIOntology(ontology); + ks.init(); + + + + //2. setup the reasoner + AbstractReasonerComponent rc = new FastInstanceChecker(ks); + rc.init(); + + //3. setup the learning problem + AbstractLearningProblem lp; +// lp = new ClassLearningProblem(rc); +// ((ClassLearningProblem)lp).setClassToDescribe(cls); +// ((ClassLearningProblem)lp).setEquivalence(true); + lp = new PosNegLPStandard(rc, positiveExamples, negativeExamples); + lp.init(); + + //4. setup the learning algorithm + AbstractCELA la; + if(useEL){ + la = new ELLearningAlgorithm(lp, rc); + ((ELLearningAlgorithm)la).setNoisePercentage(noiseInPercentage); +// ((ELLearningAlgorithm)la).setStartClass(startClass); + ((ELLearningAlgorithm)la).setIgnoredConcepts(Sets.newHashSet(posClass)); + ((ELLearningAlgorithm)la).setClassToDescribe(posClass); + ((ELLearningAlgorithm)la).setTreeSearchTimeSeconds(maxExecutionTimeInSeconds); + ((ELLearningAlgorithm)la).setMaxNrOfResults(maxNrOfResults); + ((ELLearningAlgorithm)la).setMaxClassExpressionDepth(maxClassExpressionDepth ); +// la = new ELLearningAlgorithmDisjunctive(lp, reasoner); + } else { + //set up the refinement operator and the allowed OWL constructs + RhoDRDown rop = new RhoDRDown(); + rop.setReasoner(rc); + rop.setUseNegation(useNegation); + rop.setUseAllConstructor(useAllConstructor); + rop.init(); + //build CELOE la + CELOE laTmp = new CELOE(lp, rc); + laTmp.setMaxNrOfResults(maxNrOfResults); + laTmp.setOperator(rop); + laTmp.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); +// laTmp.setStartClass(startClass); + laTmp.setNoisePercentage(noiseInPercentage); + new File(testFolder).mkdirs(); + laTmp.setSearchTreeFile(testFolder + "searchTree.txt"); + laTmp.setWriteSearchTree(true); +// isle.setTerminateOnNoiseReached(true); + laTmp.setIgnoredConcepts(Collections.singleton(posClass)); + laTmp.setReplaceSearchTree(true); + laTmp.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + laTmp.setExpandAccuracy100Nodes(true); + la = laTmp; + } + la.init(); + + //5. run + la.start(); + + + } + + private static void showLGG(Model model, SortedSet<Individual> positiveExamples){ + LGGGenerator<String> lggGen = new LGGGeneratorImpl<String>(); + QueryTree<String> lgg = lggGen.getLGG(buildTrees(model, positiveExamples)); + String s = lgg.getStringRepresentation(); + for (Entry<String, String> entry : prefixes.entrySet()) { + s = s.replace(entry.getValue(), entry.getKey() + ":"); + } + System.out.println(s); + ((QueryTreeImpl<String>) lgg).asGraph(); + } + + private static SortedSet<Individual> getExamples(Model model, NamedClass cls){ + logger.info("Generating examples..."); + SortedSet<Individual> individuals = new SPARQLReasoner(new LocalModelBasedSparqlEndpointKS(model)).getIndividuals(cls, 1000); + List<Individual> individualsList = new ArrayList<>(individuals); +// Collections.shuffle(individualsList, new Random(1234)); + individuals.clear(); + individuals.addAll(individualsList.subList(0, Math.min(maxNrOfPositiveExamples, individualsList.size()))); + logger.info("Done. Got " + individuals.size() + ": " + individuals); + return individuals; + } + + private static SortedSet<Individual> getPositiveExamples(Model model, NamedClass cls){ + logger.info("Generating positive examples..."); + SortedSet<Individual> individuals = new SPARQLReasoner(new LocalModelBasedSparqlEndpointKS(model)).getIndividuals(cls, 1000); + List<Individual> individualsList = new ArrayList<>(individuals); +// Collections.shuffle(individualsList, new Random(1234)); + individuals.clear(); + individuals.addAll(individualsList.subList(0, Math.min(maxNrOfPositiveExamples, individualsList.size()))); + logger.info("Done. Got " + individuals.size() + ": " + individuals); + return individuals; + } + + private static SortedSet<Individual> getNegativeExamples(Model model, NamedClass classToDescribe, Set<Individual> positiveExamples){ + logger.info("Generating positive examples..."); + SortedSet<Individual> individuals = new AutomaticNegativeExampleFinderSPARQL2(new SPARQLReasoner(new LocalModelBasedSparqlEndpointKS(model))).getNegativeExamples(classToDescribe, positiveExamples, Arrays.asList(SIBLING, SUPERCLASS), maxNrOfNegativeExamples); + logger.info("Done. Got " + individuals.size() + ": " + individuals); + return individuals; + } + + private static Model getSample(Model model, Individual individual){ + logger.info("Generating sample..."); + ConciseBoundedDescriptionGenerator cbdGen = new ConciseBoundedDescriptionGeneratorImpl(model, maxCBDDepth); + Model sample = cbdGen.getConciseBoundedDescription(individual.getName(), maxCBDDepth, true); + logger.info("Done. Got " + sample.size() + " triples."); + return sample; + } + + private static Model getSample(Model model, Set<Individual> individuals){ + logger.info("Generating sample..."); + ConciseBoundedDescriptionGenerator cbdGen = new ConciseBoundedDescriptionGeneratorImpl(model, maxCBDDepth); + Model sample = ModelFactory.createDefaultModel(); + Model cbd; + for (Individual individual : individuals) { +// System.out.println("##########################"); +// System.out.println(individual); + try { + cbd = cbdGen.getConciseBoundedDescription(individual.getName(), maxCBDDepth, true); +// showTree(individual, model); + sample.add(cbd); + } catch (Exception e) { + e.printStackTrace(); + } + } + logger.info("Done. Got " + sample.size() + " triples."); + return sample; + } + + private static QueryTree<String> buildTree(Individual ind, Model model){ + QueryTreeFactory<String> qf = new QueryTreeFactoryImpl(); + QueryTreeImpl<String> queryTree = qf.getQueryTree(ind.getName(), model); + return queryTree; + } + + private static List<QueryTree<String>> buildTrees(Model model, Collection<Individual> individuals){ + List<QueryTree<String>> trees = new ArrayList<QueryTree<String>>(); + for (Individual individual : individuals) { + trees.add(buildTree(individual, getSample(model, individual))); + } + return trees; + } + + private static void showTree(Individual ind, Model model){ + QueryTree<String> tree = buildTree(ind, model); + String s = tree.getStringRepresentation(); + + for (Entry<String, String> entry : prefixes.entrySet()) { + s = s.replace(entry.getValue(), entry.getKey() + ":"); + } + System.out.println(s); + } + + +} Added: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java (rev 0) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/QTLEvaluation.java 2014-05-07 11:25:54 UTC (rev 4261) @@ -0,0 +1,516 @@ +/** + * + */ +package org.dllearner.scripts.evaluation; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.algorithms.qtl.QTL2; +import org.dllearner.algorithms.qtl.QTL2Disjunctive; +import org.dllearner.algorithms.qtl.QueryTreeFactory; +import org.dllearner.algorithms.qtl.datastructures.QueryTree; +import org.dllearner.algorithms.qtl.datastructures.impl.QueryTreeImpl; +import org.dllearner.algorithms.qtl.impl.QueryTreeFactoryImpl; +import org.dllearner.cli.CrossValidation; +import org.dllearner.cli.SPARQLCrossValidation; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.owl.Individual; +import org.dllearner.kb.LocalModelBasedSparqlEndpointKS; +import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.SPARQLReasoner; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import com.google.common.collect.Lists; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; + +/** + * @author Lorenz Buehmann + * + */ +public class QTLEvaluation { + + int nrOfFolds = 10; + private int nrOfPosExamples = 100; + private int nrOfNegExamples = 100; + + List<String> posExamples = Lists.newArrayList( + "http://dl-learner.org/carcinogenesis#d1", + "http://dl-learner.org/carcinogenesis#d10", + "http://dl-learner.org/carcinogenesis#d101", + "http://dl-learner.org/carcinogenesis#d102", + "http://dl-learner.org/carcinogenesis#d103", + "http://dl-learner.org/carcinogenesis#d106", + "http://dl-learner.org/carcinogenesis#d107", + "http://dl-learner.org/carcinogenesis#d108", + "http://dl-learner.org/carcinogenesis#d11", + "http://dl-learner.org/carcinogenesis#d12", + "http://dl-learner.org/carcinogenesis#d13", + "http://dl-learner.org/carcinogenesis#d134", + "http://dl-learner.org/carcinogenesis#d135", + "http://dl-learner.org/carcinogenesis#d136", + "http://dl-learner.org/carcinogenesis#d138", + "http://dl-learner.org/carcinogenesis#d140", + "http://dl-learner.org/carcinogenesis#d141", + "http://dl-learner.org/carcinogenesis#d144", + "http://dl-learner.org/carcinogenesis#d145", + "http://dl-learner.org/carcinogenesis#d146", + "http://dl-learner.org/carcinogenesis#d147", + "http://dl-learner.org/carcinogenesis#d15", + "http://dl-learner.org/carcinogenesis#d17", + "http://dl-learner.org/carcinogenesis#d19", + "http://dl-learner.org/carcinogenesis#d192", + "http://dl-learner.org/carcinogenesis#d193", + "http://dl-learner.org/carcinogenesis#d195", + "http://dl-learner.org/carcinogenesis#d196", + "http://dl-learner.org/carcinogenesis#d197", + "http://dl-learner.org/carcinogenesis#d198", + "http://dl-learner.org/carcinogenesis#d199", + "http://dl-learner.org/carcinogenesis#d2", + "http://dl-learner.org/carcinogenesis#d20", + "http://dl-learner.org/carcinogenesis#d200", + "http://dl-learner.org/carcinogenesis#d201", + "http://dl-learner.org/carcinogenesis#d202", + "http://dl-learner.org/carcinogenesis#d203", + "http://dl-learner.org/carcinogenesis#d204", + "http://dl-learner.org/carcinogenesis#d205", + "http://dl-learner.org/carcinogenesis#d21", + "http://dl-learner.org/carcinogenesis#d22", + "http://dl-learner.org/carcinogenesis#d226", + "http://dl-learner.org/carcinogenesis#d227", + "http://dl-learner.org/carcinogenesis#d228", + "http://dl-learner.org/carcinogenesis#d229", + "http://dl-learner.org/carcinogenesis#d231", + "http://dl-learner.org/carcinogenesis#d232", + "http://dl-learner.org/carcinogenesis#d234", + "http://dl-learner.org/carcinogenesis#d236", + "http://dl-learner.org/carcinogenesis#d239", + "http://dl-learner.org/carcinogenesis#d23_2", + "http://dl-learner.org/carcinogenesis#d242", + "http://dl-learner.org/carcinogenesis#d245", + "http://dl-learner.org/carcinogenesis#d247", + "http://dl-learner.org/carcinogenesis#d249", + "http://dl-learner.org/carcinogenesis#d25", + "http://dl-learner.org/carcinogenesis#d252", + "http://dl-learner.org/carcinogenesis#d253", + "http://dl-learner.org/carcinogenesis#d254", + "http://dl-learner.org/carcinogenesis#d255", + "http://dl-learner.org/carcinogenesis#d26", + "http://dl-learner.org/carcinogenesis#d272", + "http://dl-learner.org/carcinogenesis#d275", + "http://dl-learner.org/carcinogenesis#d277", + "http://dl-learner.org/carcinogenesis#d279", + "http://dl-learner.org/carcinogenesis#d28", + "http://dl-learner.org/carcinogenesis#d281", + "http://dl-learner.org/carcinogenesis#d283", + "http://dl-learner.org/carcinogenesis#d284", + "http://dl-learner.org/carcinogenesis#d288", + "http://dl-learner.org/carcinogenesis#d29", + "http://dl-learner.org/carcinogenesis#d290", + "http://dl-learner.org/carcinogenesis#d291", + "http://dl-learner.org/carcinogenesis#d292", + "http://dl-learner.org/carcinogenesis#d30", + "http://dl-learner.org/carcinogenesis#d31", + "http://dl-learner.org/carcinogenesis#d32", + "http://dl-learner.org/carcinogenesis#d33", + "http://dl-learner.org/carcinogenesis#d34", + "http://dl-learner.org/carcinogenesis#d35", + "http://dl-learner.org/carcinogenesis#d36", + "http://dl-learner.org/carcinogenesis#d37", + "http://dl-learner.org/carcinogenesis#d38", + "http://dl-learner.org/carcinogenesis#d42", + "http://dl-learner.org/carcinogenesis#d43", + "http://dl-learner.org/carcinogenesis#d44", + "http://dl-learner.org/carcinogenesis#d45", + "http://dl-learner.org/carcinogenesis#d46", + "http://dl-learner.org/carcinogenesis#d47", + "http://dl-learner.org/carcinogenesis#d48", + "http://dl-learner.org/carcinogenesis#d49", + "http://dl-learner.org/carcinogenesis#d5", + "http://dl-learner.org/carcinogenesis#d51", + "http://dl-learner.org/carcinogenesis#d52", + "http://dl-learner.org/carcinogenesis#d53", + "http://dl-learner.org/carcinogenesis#d55", + "http://dl-learner.org/carcinogenesis#d58", + "http://dl-learner.org/carcinogenesis#d6", + "http://dl-learner.org/carcinogenesis#d7", + "http://dl-learner.org/carcinogenesis#d84", + "http://dl-learner.org/carcinogenesis#d85_2", + "http://dl-learner.org/carcinogenesis#d86", + "http://dl-learner.org/carcinogenesis#d87", + "http://dl-learner.org/carcinogenesis#d88", + "http://dl-learner.org/carcinogenesis#d89", + "http://dl-learner.org/carcinogenesis#d9", + "http://dl-learner.org/carcinogenesis#d91", + "http://dl-learner.org/carcinogenesis#d92", + "http://dl-learner.org/carcinogenesis#d93", + "http://dl-learner.org/carcinogenesis#d95", + "http://dl-learner.org/carcinogenesis#d96", + "http://dl-learner.org/carcinogenesis#d98", + "http://dl-learner.org/carcinogenesis#d99", + "http://dl-learner.org/carcinogenesis#d100", + "http://dl-learner.org/carcinogenesis#d104", + "http://dl-learner.org/carcinogenesis#d105", + "http://dl-learner.org/carcinogenesis#d109", + "http://dl-learner.org/carcinogenesis#d137", + "http://dl-learner.org/carcinogenesis#d139", + "http://dl-learner.org/carcinogenesis#d14", + "http://dl-learner.org/carcinogenesis#d142", + "http://dl-learner.org/carcinogenesis#d143", + "http://dl-learner.org/carcinogenesis#d148", + "http://dl-learner.org/carcinogenesis#d16", + "http://dl-learner.org/carcinogenesis#d18", + "http://dl-learner.org/carcinogenesis#d191", + "http://dl-learner.org/carcinogenesis#d206", + "http://dl-learner.org/carcinogenesis#d230", + "http://dl-learner.org/carcinogenesis#d233", + "http://dl-learner.org/carcinogenesis#d235", + "http://dl-learner.org/carcinogenesis#d237", + "http://dl-learner.org/carcinogenesis#d238", + "http://dl-learner.org/carcinogenesis#d23_1", + "http://dl-learner.org/carcinogenesis#d24", + "http://dl-learner.org/carcinogenesis#d240", + "http://dl-learner.org/carcinogenesis#d241", + "http://dl-learner.org/carcinogenesis#d243", + "http://dl-learner.org/carcinogenesis#d244", + "http://dl-learner.org/carcinogenesis#d246", + "http://dl-learner.org/carcinogenesis#d248", + "http://dl-learner.org/carcinogenesis#d250", + "http://dl-learner.org/carcinogenesis#d251", + "http://dl-learner.org/carcinogenesis#d27", + "http://dl-learner.org/carcinogenesis#d273", + "http://dl-learner.org/carcinogenesis#d274", + "http://dl-learner.org/carcinogenesis#d278", + "http://dl-learner.org/carcinogenesis#d286", + "http://dl-learner.org/carcinogenesis#d289", + "http://dl-learner.org/carcinogenesis#d3", + "http://dl-learner.org/carcinogenesis#d39", + "http://dl-learner.org/carcinogenesis#d4", + "http://dl-learner.org/carcinogenesis#d40", + "http://dl-learner.org/carcinogenesis#d41", + "http://dl-learner.org/carcinogenesis#d50", + "http://dl-learner.org/carcinogenesis#d54", + "http://dl-learner.org/carcinogenesis#d56", + "http://dl-learner.org/carcinogenesis#d57", + "http://dl-learner.org/carcinogenesis#d8", + "http://dl-learner.org/carcinogenesis#d85_1", + "http://dl-learner.org/carcinogenesis#d90", + "http://dl-learner.org/carcinogenesis#d94", + "http://dl-learner.org/carcinogenesis#d97", + "http://dl-learner.org/carcinogenesis#d296", + "http://dl-learner.org/carcinogenesis#d305", + "http://dl-learner.org/carcinogenesis#d306", + "http://dl-learner.org/carcinogenesis#d307", + "http://dl-learner.org/carcinogenesis#d308", + "http://dl-learner.org/carcinogenesis#d311", + "http://dl-learner.org/carcinogenesis#d314", + "http://dl-learner.org/carcinogenesis#d315", + "http://dl-learner.org/carcinogenesis#d316", + "http://dl-learner.org/carcinogenesis#d320", + "http://dl-learner.org/carcinogenesis#d322", + "http://dl-learner.org/carcinogenesis#d323", + "http://dl-learner.org/carcinogenesis#d325", + "http://dl-learner.org/carcinogenesis#d329", + "http://dl-learner.org/carcinogenesis#d330", + "http://dl-learner.org/carcinogenesis#d331", + "http://dl-learner.org/carcinogenesis#d332", + "http://dl-learner.org/carcinogenesis#d333", + "http://dl-learner.org/carcinogenesis#d336", + "http://dl-learner.org/carcinogenesis#d337" + ); + + List<String> negExamples = Lists.newArrayList( + "http://dl-learner.org/carcinogenesis#d110", + "http://dl-learner.org/carcinogenesis#d111", + "http://dl-learner.org/carcinogenesis#d114", + "http://dl-learner.org/carcinogenesis#d116", + "http://dl-learner.org/carcinogenesis#d117", + "http://dl-learner.org/carcinogenesis#d119", + "http://dl-learner.org/carcinogenesis#d121", + "http://dl-learner.org/carcinogenesis#d123", + "http://dl-learner.org/carcinogenesis#d124", + "http://dl-learner.org/carcinogenesis#d125", + "http://dl-learner.org/carcinogenesis#d127", + "http://dl-learner.org/carcinogenesis#d128", + "http://dl-learner.org/carcinogenesis#d130", + "http://dl-learner.org/carcinogenesis#d133", + "http://dl-learner.org/carcinogenesis#d150", + "http://dl-learner.org/carcinogenesis#d151", + "http://dl-learner.org/carcinogenesis#d154", + "http://dl-learner.org/carcinogenesis#d155", + "http://dl-learner.org/carcinogenesis#d156", + "http://dl-learner.org/carcinogenesis#d159", + "http://dl-learner.org/carcinogenesis#d160", + "http://dl-learner.org/carcinogenesis#d161", + "http://dl-learner.org/carcinogenesis#d162", + "http://dl-learner.org/carcinogenesis#d163", + "http://dl-learner.org/carcinogenesis#d164", + "http://dl-learner.org/carcinogenesis#d165", + "http://dl-learner.org/carcinogenesis#d166", + "http://dl-learner.org/carcinogenesis#d169", + "http://dl-learner.org/carcinogenesis#d170", + "http://dl-learner.org/carcinogenesis#d171", + "http://dl-learner.org/carcinogenesis#d172", + "http://dl-learner.org/carcinogenesis#d173", + "http://dl-learner.org/carcinogenesis#d174", + "http://dl-learner.org/carcinogenesis#d178", + "http://dl-learner.org/carcinogenesis#d179", + "http://dl-learner.org/carcinogenesis#d180", + "http://dl-learner.org/carcinogenesis#d181", + "http://dl-learner.org/carcinogenesis#d183", + "http://dl-learner.org/carcinogenesis#d184", + "http://dl-learner.org/carcinogenesis#d185", + "http://dl-learner.org/carcinogenesis#d186", + "http://dl-learner.org/carcinogenesis#d188", + "http://dl-learner.org/carcinogenesis#d190", + "http://dl-learner.org/carcinogenesis#d194", + "http://dl-learner.org/carcinogenesis#d207", + "http://dl-learner.org/carcinogenesis#d208_1", + "http://dl-learner.org/carcinogenesis#d209", + "http://dl-learner.org/carcinogenesis#d210", + "http://dl-learner.org/carcinogenesis#d211", + "http://dl-learner.org/carcinogenesis#d212", + "http://dl-learner.org/carcinogenesis#d213", + "http://dl-learner.org/carcinogenesis#d214", + "http://dl-learner.org/carcinogenesis#d215", + "http://dl-learner.org/carcinogenesis#d217", + "http://dl-learner.org/carcinogenesis#d218", + "http://dl-learner.org/carcinogenesis#d219", + "http://dl-learner.org/carcinogenesis#d220", + "http://dl-learner.org/carcinogenesis#d224", + "http://dl-learner.org/carcinogenesis#d256", + "http://dl-learner.org/carcinogenesis#d257", + "http://dl-learner.org/carcinogenesis#d258", + "http://dl-learner.org/carcinogenesis#d261", + "http://dl-learner.org/carcinogenesis#d262", + "http://dl-learner.org/carcinogenesis#d263", + "http://dl-learner.org/carcinogenesis#d264", + "http://dl-learner.org/carcinogenesis#d265", + "http://dl-learner.org/carcinogenesis#d266", + "http://dl-learner.org/carcinogenesis#d267", + "http://dl-learner.org/carcinogenesis#d269", + "http://dl-learner.org/carcinogenesis#d271", + "http://dl-learner.org/carcinogenesis#d276", + "http://dl-learner.org/carcinogenesis#d280", + "http://dl-learner.org/carcinogenesis#d285", + "http://dl-learner.org/carcinogenesis#d287", + "http://dl-learner.org/carcinogenesis#d293", + "http://dl-learner.org/carcinogenesis#d294", + "http://dl-learner.org/carcinogenesis#d59", + "http://dl-learner.org/carcinogenesis#d60", + "http://dl-learner.org/carcinogenesis#d61", + "http://dl-learner.org/carcinogenesis#d63", + "http://dl-learner.org/carcinogenesis#d64", + "http://dl-learner.org/carcinogenesis#d65", + "http://dl-learner.org/carcinogenesis#d69", + "http://dl-learner.org/carcinogenesis#d70", + "http://dl-learner.org/carcinogenesis#d71", + "http://dl-learner.org/carcinogenesis#d72", + "http://dl-learner.org/carcinogenesis#d73", + "http://dl-learner.org/carcinogenesis#d74", + "http://dl-learner.org/carcinogenesis#d75", + "http://dl-learner.org/carcinogenesis#d76", + "http://dl-learner.org/carcinogenesis#d77", + "http://dl-learner.org/carcinogenesis#d78", + "http://dl-learner.org/carcinogenesis#d79", + "http://dl-learner.org/carcinogenesis#d80", + "http://dl-learner.org/carcinogenesis#d81", + "http://dl-learner.org/carcinogenesis#d82", + "http://dl-learner.org/carcinogenesis#d112", + "http://dl-learner.org/carcinogenesis#d113", + "http://dl-learner.org/carcinogenesis#d115", + "http://dl-learner.org/carcinogenesis#d118", + "http://dl-learner.org/carcinogenesis#d120", + "http://dl-learner.org/carcinogenesis#d122", + "http://dl-learner.org/carcinogenesis#d126", + "http://dl-learner.org/carcinogenesis#d129", + "http://dl-learner.org/carcinogenesis#d131", + "http://dl-learner.org/carcinogenesis#d132", + "http://dl-learner.org/carcinogenesis#d149", + "http://dl-learner.org/carcinogenesis#d152", + "http://dl-learner.org/carcinogenesis#d153", + "http://dl-learner.org/carcinogenesis#d157", + "http://dl-learner.org/carcinogenesis#d158", + "http://dl-learner.org/carcinogenesis#d167", + "http://dl-learner.org/carcinogenesis#d168", + "http://dl-learner.org/carcinogenesis#d175", + "http://dl-learner.org/carcinogenesis#d176", + "http://dl-learner.org/carcinogenesis#d177", + "http://dl-learner.org/carcinogenesis#d182", + "http://dl-learner.org/carcinogenesis#d187", + "http://dl-learner.org/carcinogenesis#d189", + "http://dl-learner.org/carcinogenesis#d208_2", + "http://dl-learner.org/carcinogenesis#d216", + "http://dl-learner.org/carcinogenesis#d221", + "http://dl-learner.org/carcinogenesis#d222", + "http://dl-learner.org/carcinogenesis#d223", + "http://dl-learner.org/carcinogenesis#d225", + "http://dl-learner.org/carcinogenesis#d259", + "http://dl-learner.org/carcinogenesis#d260", + "http://dl-learner.org/carcinogenesis#d268", + "http://dl-learner.org/carcinogenesis#d270", + "http://dl-learner.org/carcinogenesis#d282", + "http://dl-learner.org/carcinogenesis#d295", + "http://dl-learner.org/carcinogenesis#d62", + "http://dl-learner.org/carcinogenesis#d66", + "http://dl-learner.org/carcinogenesis#d67", + "http://dl-learner.org/carcinogenesis#d68", + "http://dl-learner.org/carcinogenesis#d83", + "http://dl-learner.org/carcinogenesis#d297", + "http://dl-learner.org/carcinogenesis#d298", + "http://dl-learner.org/carcinogenesis#d299", + "http://dl-learner.org/carcinogenesis#d300", + "http://dl-learner.org/carcinogenesis#d302", + "http://dl-learner.org/carcinogenesis#d303", + "http://dl-learner.org/carcinogenesis#d304", + "http://dl-learner.org/carcinogenesis#d309", + "http://dl-learner.org/carcinogenesis#d312", + "http://dl-learner.org/carcinogenesis#d313", + "http://dl-learner.org/carcinogenesis#d317", + "http://dl-learner.org/carcinogenesis#d318", + "http://dl-learner.org/carcinogenesis#d319", + "http://dl-learner.org/carcinogenesis#d324", + "http://dl-learner.org/carcinogenesis#d326", + "http://dl-learner.org/carcinogenesis#d327", + "http://dl-learner.org/carcinogenesis#d328", + "http://dl-learner.org/carcinogenesis#d334", + "http://dl-learner.org/carcinogenesis#d335" + ); + + private Model model; + private OWLOntology ontology; + private QueryTreeFactory<String> queryTreeFactory; + private List<QueryTree<String>> posExampleTrees; + private List<QueryTree<String>> negExampleTrees; + private PosNegLP lp; + + + + public QTLEvaluation() throws ComponentInitException { + queryTreeFactory = new QueryTreeFactoryImpl(); + queryTreeFactory.setMaxDepth(3); + + loadDataset(); + + loadExamples(); + } + + private void loadDataset(){ + File file = new File("../examples/carcinogenesis/carcinogenesis.owl"); + model = ModelFactory.createDefaultModel(); + try { + model.read(new FileInputStream(file), null, "RDF/XML"); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + try { + ontology = man.loadOntologyFromOntologyDocument(file); + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); + } + } + + private void loadExamples() throws ComponentInitException{ + + Collections.shuffle(posExamples, new Random(1)); + Collections.shuffle(negExamples, new Random(2)); + posExamples = posExamples.subList(0, Math.min(posExamples.size(), nrOfPosExamples)); + negExamples = negExamples.subList(0, Math.min(negExamples.size(), nrOfNegExamples)); + +// posExamples.clear(); +// String string = "http://dl-learner.org/carcinogenesis#d101, http://dl-learner.org/carcinogenesis#d103, http://dl-learner.org/carcinogenesis#d107, http://dl-learner.org/carcinogenesis#d108, http://dl-learner.org/carcinogenesis#d135, http://dl-learner.org/carcinogenesis#d139, http://dl-learner.org/carcinogenesis#d14, http://dl-learner.org/carcinogenesis#d141, http://dl-learner.org/carcinogenesis#d143, http://dl-learner.org/carcinogenesis#d147, http://dl-learner.org/carcinogenesis#d17, http://dl-learner.org/carcinogenesis#d19, http://dl-learner.org/carcinogenesis#d193, http://dl-learner.org/carcinogenesis#d198, http://dl-learner.org/carcinogenesis#d228, http://dl-learner.org/carcinogenesis#d236, http://dl-learner.org/carcinogenesis#d242, http://dl-learner.org/carcinogenesis#d244, http://dl-learner.org/carcinogenesis#d273, http://dl-learner.org/carcinogenesis#d275, http://dl-learner.org/carcinogenesis#d28, http://dl-learner.org/carcinogenesis#d283, http://dl-learner.org/carcinogenesis#d286, http://dl-learner.org/carcinogenesis#d291, http://dl-learner.org/carcinogenesis#d292, http://dl-learner.org/carcinogenesis#d307, http://dl-learner.org/carcinogenesis#d31, http://dl-learner.org/carcinogenesis#d325, http://dl-learner.org/carcinogenesis#d33, http://dl-learner.org/carcinogenesis#d333, http://dl-learner.org/carcinogenesis#d34, http://dl-learner.org/carcinogenesis#d36, http://dl-learner.org/carcinogenesis#d38, http://dl-learner.org/carcinogenesis#d4, http://dl-learner.org/carcinogenesis#d40, http://dl-learner.org/carcinogenesis#d44, http://dl-learner.org/carcinogenesis#d51, http://dl-learner.org/carcinogenesis#d85_2, http://dl-learner.org/carcinogenesis#d98, http://dl-learner.org/carcinogenesis#d99"; +// String[] split = string.split(","); +// for (String s : split) { +// posExamples.add(s.trim()); +// } +// negExamples.clear(); +// string = "http://dl-learner.org/carcinogenesis#d112, http://dl-learner.org/carcinogenesis#d116, http://dl-learner.org/carcinogenesis#d117, http://dl-learner.org/carcinogenesis#d119, http://dl-learner.org/carcinogenesis#d157, http://dl-learner.org/carcinogenesis#d160, http://dl-learner.org/carcinogenesis#d161, http://dl-learner.org/carcinogenesis#d162, http://dl-learner.org/carcinogenesis#d163, http://dl-learner.org/carcinogenesis#d167, http://dl-learner.org/carcinogenesis#d169, http://dl-learner.org/carcinogenesis#d175, http://dl-learner.org/carcinogenesis#d177, http://dl-learner.org/carcinogenesis#d184, http://dl-learner.org/carcinogenesis#d194, http://dl-learner.org/carcinogenesis#d208_2, http://dl-learner.org/carcinogenesis#d209, http://dl-learner.org/carcinogenesis#d217, http://dl-learner.org/carcinogenesis#d256, http://dl-learner.org/carcinogenesis#d257, http://dl-learner.org/carcinogenesis#d260, http://dl-learner.org/carcinogenesis#d271, http://dl-learner.org/carcinogenesis#d276, http://dl-learner.org/carcinogenesis#d282, http://dl-learner.org/carcinogenesis#d287, http://dl-learner.org/carcinogenesis#d294, http://dl-learner.org/carcinogenesis#d298, http://dl-learner.org/carcinogenesis#d300, http://dl-learner.org/carcinogenesis#d309, http://dl-learner.org/carcinogenesis#d319, http://dl-learner.org/carcinogenesis#d326, http://dl-learner.org/carcinogenesis#d328, http://dl-learner.org/carcinogenesis#d334, http://dl-learner.org/carcinogenesis#d60, http://dl-learner.org/carcinogenesis#d61, http://dl-learner.org/carcinogenesis#d66, http://dl-learner.org/carcinogenesis#d75, http://dl-learner.org/carcinogenesis#d79, http://dl-learner.org/carcinogenesis#d80, http://dl-learner.org/carcinogenesis#d83"; +// split = string.split(","); +// for (String s : split) { +// negExamples.add(s.trim()); +// } + + posExampleTrees = new ArrayList<QueryTree<String>>(); + for (String ex : posExamples) { + QueryTreeImpl<String> tree = queryTreeFactory.getQueryTree(ex, model); + posExampleTrees.add(tree); + } + + negExampleTrees = new ArrayList<QueryTree<String>>(); + for (String ex : negExamples) { + QueryTreeImpl<String> tree = queryTreeFactory.getQueryTree(ex, model); + negExampleTrees.add(tree); + } + + int cnt = 1; + for(QueryTree<String> tree : posExampleTrees){ +// System.out.println("TREE " + cnt); +// tree.dump(); +// +// System.out.println("-----------------------------"); + cnt++; +// System.out.println(((QueryTreeImpl<String>)tree).toQuery()); + } + + SortedSet<Individual> pos = new TreeSet<Individual>(); + for (String ex : posExamples) { + pos.add(new Individual(ex)); + } + SortedSet<Individual> neg = new TreeSet<Individual>(); + for (String ex : negExamples) { + neg.add(new Individual(ex)); + } + lp = new PosNegLPStandard(); + lp.setPositiveExamples(pos); + lp.setNegativeExamples(neg); + } + + public void run(boolean multiThreaded) throws ComponentInitException, LearningProblemUnsupportedException{ + long startTime = System.currentTimeMillis(); + FastInstanceChecker reasoner = new FastInstanceChecker(new OWLAPIOntology(ontology)); + reasoner.init(); + lp.setReasoner(reasoner); + lp.init(); + QTL2Disjunctive la = new QTL2Disjunctive(lp, reasoner); + la.init(); + la.start(); + +// CrossValidation.outputFile = new File("log/qtl-cv.log"); +// CrossValidation.writeToFile = true; +// CrossValidation.multiThreaded = multiThreaded; +// CrossValidation cv = new CrossValidation(la, lp, reasoner, nrOfFolds, false); + long endTime = System.currentTimeMillis(); + System.err.println((endTime - startTime) + "ms"); + } + + + public static void main(String[] args) throws Exception { + boolean multiThreaded = Boolean.valueOf(args[0]); + new QTLEvaluation().run(multiThreaded); + } + +} Added: trunk/scripts/src/main/java/org/dllearner/scripts/pattern/FixPointDetection.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/pattern/FixPointDetection.java (rev 0) +++ trunk/scripts/src/main/java/org/dllearner/scripts/pattern/FixPointDetection.java 2014-05-07 11:25:54 UTC (rev 4261) @@ -0,0 +1,281 @@ +/** + * + */ +package org.dllearner.scripts.pattern; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; +import java.util.Set; +import java.util.TreeMap; +import java.util.prefs.Preferences; + +import org.ini4j.IniPreferences; +import org.ini4j.InvalidFileFormatException; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.io.OWLObjectRenderer; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl; + +import com.google.common.base.Charsets; +import com.google.common.base.Joiner; +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Multimap; +import com.google.common.io.Files; + +/** + * @author Lorenz Buehmann + * + */ +public class FixPointDetection { + + private OWLObjectRenderer axiomRenderer = new ManchesterOWLSyntaxOWLObjectRendererImpl(); + + public FixPointDetection() { + initDBConnection(); + + File dir = new File("pattern-fixpoint"); + dir.mkdir(); + } + + private Connection conn; + private PreparedStatement ps; + + private void initDBConnection() { + try { + InputStream is = this.getClass().getClassLoader().getResourceAsStream("db_settings.ini"); + Preferences prefs = new IniPreferences(is); + String dbServer = prefs.node("database").get("server", null); + String dbName = prefs.node("database").get("name", null); + String dbUser = prefs.node("database").get("user", null); + String dbPass = prefs.node("database").get("pass", null); + + Class.forName("com.mysql.jdbc.Driver"); + String url = "jdbc:mysql://" + dbServer + "/" + dbName; + conn = DriverManager.getConnection(url, dbUser, dbPass); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (InvalidFileFormatException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + try { + ps = conn.prepareStatement("SELECT occurrences FROM Ontology_Pattern WHERE pattern_id=? AND ontology_id=?"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + + private List<Integer> getProcessedOntologies() throws SQLException{ + List<Integer> ids = new ArrayList<Integer>(); + ResultSet rs = conn.createStatement().executeQuery("SELECT DISTINCT id FROM Ontology"); + while(rs.next()){ + int id = rs.getInt(1); + ... [truncated message content] |