From: <lor...@us...> - 2011-08-16 14:49:05
|
Revision: 3052 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3052&view=rev Author: lorenz_b Date: 2011-08-16 14:48:58 +0000 (Tue, 16 Aug 2011) Log Message: ----------- Continued enrichment vocabulary. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-16 10:08:40 UTC (rev 3051) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/SimpleSubclassLearner.java 2011-08-16 14:48:58 UTC (rev 3052) @@ -54,6 +54,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; @@ -158,8 +159,10 @@ } private void addIndividualsWithTypes(Map<Individual, SortedSet<NamedClass>> ind2Types, int limit, int offset){ - String query = String.format("SELECT DISTINCT ?ind ?type WHERE {?ind a <%s>. ?ind a ?type} LIMIT %d OFFSET %d", classToDescribe.getName(), limit, offset); +// String query = String.format("SELECT DISTINCT ?ind ?type WHERE {?ind a <%s>. ?ind a ?type} LIMIT %d OFFSET %d", classToDescribe.getName(), limit, offset); + String query = String.format("SELECT DISTINCT ?ind ?type WHERE {?ind a ?type. {SELECT ?ind {?ind a <%s>} LIMIT %d OFFSET %d}}", classToDescribe.getName(), limit, offset); + ResultSet rs = new SparqlQuery(query, ks.getEndpoint()).send(); Individual ind; NamedClass newType; @@ -176,6 +179,7 @@ } types.add(newType); } + } private void createEvaluatedDescriptions(Map<Individual, SortedSet<NamedClass>> individual2Types){ Modified: trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-16 10:08:40 UTC (rev 3051) +++ trunk/components-core/src/main/java/org/dllearner/core/EvaluatedAxiom.java 2011-08-16 14:48:58 UTC (rev 3052) @@ -3,6 +3,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.commons.codec.digest.DigestUtils; @@ -13,6 +14,7 @@ import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLAnnotation; import org.semanticweb.owlapi.model.OWLAnnotationAxiom; +import org.semanticweb.owlapi.model.OWLAnnotationSubject; import org.semanticweb.owlapi.model.OWLAxiom; import org.semanticweb.owlapi.model.OWLDataFactory; import org.semanticweb.owlapi.model.OWLNamedIndividual; @@ -57,9 +59,11 @@ ManchesterOWLSyntaxObjectRenderer r = new ManchesterOWLSyntaxObjectRenderer(pw, new ManchesterOWLSyntaxPrefixNameShortFormProvider(new DefaultPrefixManager())); OWLAxiom ax = OWLAPIConverter.getOWLAPIAxiom(axiom); ax.accept(r); + System.out.println(sw.toString()); OWLAxiom ax1 = f.getOWLClassAssertionAxiom(EnrichmentVocabulary.Suggestion, ind); OWLAxiom ax2 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.hasAxiom, ind, sw.toString()); +// f.getOWLAnnotationAssertionAxiom(f.getOWLAnnotationProperty(IRI.create("annoProp")), ind.getIRI(), ax); OWLAxiom ax3 = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.confidence, ind, score.getAccuracy()); List<OWLAxiom> axioms = new ArrayList<OWLAxiom>(); Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-08-16 10:08:40 UTC (rev 3051) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/SPARQLReasoner.java 2011-08-16 14:48:58 UTC (rev 3052) @@ -467,6 +467,22 @@ } return superClasses; } + + public SortedSet<Description> getSuperClasses(Description description, boolean direct){ + if(!(description instanceof NamedClass)){ + throw new IllegalArgumentException("Only named classes are supported."); + } + SortedSet<Description> superClasses = new TreeSet<Description>(); + //this query is virtuoso specific + String query = String.format("SELECT DISTINCT ?y WHERE {" + + "{ SELECT ?x ?y WHERE { ?x rdfs:subClassOf ?y } }" + + "OPTION ( TRANSITIVE, T_DISTINCT, t_in(?x), t_out(?y), t_step('path_id') as ?path, t_step(?x) as ?route, t_step('step_no') AS ?jump, T_DIRECTION 3 )" + + "FILTER ( ?x = <%s> )}", ((NamedClass)description).getURI().toString()); + + + + return superClasses; + } @Override public SortedSet<Description> getSubClasses(Description description) { Modified: trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-16 10:08:40 UTC (rev 3051) +++ trunk/components-core/src/main/java/org/dllearner/utilities/EnrichmentVocabulary.java 2011-08-16 14:48:58 UTC (rev 3052) @@ -17,13 +17,19 @@ //the classes public static final OWLClass ChangeSet = factory.getOWLClass(IRI.create(NS + "ChangeSet")); + public static final OWLClass SuggestionSet = factory.getOWLClass(IRI.create(NS + "SuggestionSet")); + public static final OWLClass Suggestion = factory.getOWLClass(IRI.create(NS + "Suggestion")); public static final OWLClass Parameter = factory.getOWLClass(IRI.create(NS + "Parameter")); + public static final OWLClass Creation = factory.getOWLClass(IRI.create(NS + "Creation")); + public static final OWLClass AlgorithmRun = factory.getOWLClass(IRI.create(NS + "AlgorithmRun")); + + //the object properties - public static final OWLObjectProperty creation = factory.getOWLObjectProperty(IRI.create(NS + "creation")); + public static final OWLObjectProperty creator = factory.getOWLObjectProperty(IRI.create(NS + "creatr")); // public static final OWLObjectProperty hasAxiom = factory.getOWLObjectProperty(IRI.create(NS + "hasAxiom")); @@ -31,6 +37,8 @@ public static final OWLObjectProperty hasInput = factory.getOWLObjectProperty(IRI.create(NS + "hasInput")); + public static final OWLObjectProperty hasSuggestion = factory.getOWLObjectProperty(IRI.create(NS + "hasSuggestion")); + public static final OWLObjectProperty hasParameter = factory.getOWLObjectProperty(IRI.create(NS + "hasParameter")); public static final OWLObjectProperty usedAlgorithm = factory.getOWLObjectProperty(IRI.create(NS + "usedAlgorithm")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |