From: <lor...@us...> - 2013-05-24 07:56:31
|
Revision: 3983 http://sourceforge.net/p/dl-learner/code/3983 Author: lorenz_b Date: 2013-05-24 07:56:26 +0000 (Fri, 24 May 2013) Log Message: ----------- Avoid NPE. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLEntityTypeAdder.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2013-05-22 15:35:39 UTC (rev 3982) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/properties/FunctionalObjectPropertyAxiomLearner.java 2013-05-24 07:56:26 UTC (rev 3983) @@ -164,7 +164,7 @@ public static void main(String[] args) throws Exception{ FunctionalObjectPropertyAxiomLearner l = new FunctionalObjectPropertyAxiomLearner(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia())); - l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/ontology/currency")); + l.setPropertyToDescribe(new ObjectProperty("http://dbpedia.org/property/father")); l.setMaxExecutionTimeInSeconds(20); l.setForceSPARQL_1_0_Mode(true); l.init(); Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java 2013-05-22 15:35:39 UTC (rev 3982) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java 2013-05-24 07:56:26 UTC (rev 3983) @@ -203,18 +203,21 @@ if (subClass.equals(superClass)) { return true; } else { - for (Description moreGeneralClass : subsumptionHierarchyUp.get(subClass)) { - - // search the upper classes of the subclass - if (moreGeneralClass instanceof NamedClass) { - if (isSubclassOf((NamedClass) moreGeneralClass, superClass)) { - return true; + SortedSet<Description> superClasses = subsumptionHierarchyUp.get(subClass); + if(superClasses != null){ + for (Description moreGeneralClass : subsumptionHierarchyUp.get(subClass)) { + + // search the upper classes of the subclass + if (moreGeneralClass instanceof NamedClass) { + if (isSubclassOf((NamedClass) moreGeneralClass, superClass)) { + return true; + } + // we reached top, so we can return false (if top is a + // direct upper + // class, then no other upper classes can exist) + } else { + return false; } - // we reached top, so we can return false (if top is a - // direct upper - // class, then no other upper classes can exist) - } else { - return false; } } // we cannot reach the class via any of the upper classes, Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-05-22 15:35:39 UTC (rev 3982) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2013-05-24 07:56:26 UTC (rev 3983) @@ -651,7 +651,7 @@ String query = " SELECT DISTINCT ?ind WHERE {"+ - "?ind ?p ?o ."+ + "?ind a ?o .?o <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://www.w3.org/2002/07/owl#Class>"+ filterStr+ " }"; if(limit != 0) { query += " LIMIT " + limit; Modified: trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLEntityTypeAdder.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLEntityTypeAdder.java 2013-05-22 15:35:39 UTC (rev 3982) +++ trunk/components-core/src/main/java/org/dllearner/utilities/owl/OWLEntityTypeAdder.java 2013-05-24 07:56:26 UTC (rev 3983) @@ -3,7 +3,6 @@ import java.util.HashSet; import java.util.Set; -import com.google.common.collect.Sets; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.RDFNode; @@ -28,7 +27,8 @@ while(iterator.hasNext()){ Statement st = iterator.next(); Property predicate = st.getPredicate(); - if(!predicate.getURI().startsWith(RDF.getURI()) && !predicate.getURI().startsWith(RDFS.getURI())){ + if(!predicate.getURI().startsWith(RDF.getURI()) && !predicate.getURI().startsWith(RDFS.getURI()) + && !predicate.getURI().startsWith(OWL.getURI())){ RDFNode object = st.getObject(); if(object.isLiteral()){ dataPropertyPredicates.add(predicate); @@ -38,13 +38,6 @@ } } iterator.close(); - - for (Property property : Sets.difference(objectPropertyPredicates, dataPropertyPredicates)) { - model.add(property, RDF.type, OWL.ObjectProperty); - } - for (Property property : Sets.difference(dataPropertyPredicates, objectPropertyPredicates)) { - model.add(property, RDF.type, OWL.DatatypeProperty); - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |