0

I'm using Pellet with OWL API in order to populate the ontologies and Jena to make some query. The problem is that I don't obtain results when querying for labels. My Code is:

 reasoner=PelletReasonerFactory.getInstance().createReasoner
 KnowledgeBase kb = reasoner.getKB();
PelletInfGraph graph = new org.mindswap.pellet.jena.PelletReasoner().bind( kb );
InfModel model = ModelFactory.createInfModel( graph );
Query q = QueryFactory.create(query );
QueryExecution qe = QueryExecutionFactory.create( q, model );
ResultSet rs = qe.execSelect(); 
ResultSetFormatter.out( rs );

If I ask for a label, for example using
Select ?x ?y WHERE { ?x rdfs:label ?y.}
I obtain an empty string as label. The query works in protegè giving the labels requested. Any suggestion?

A snippet of the ontology:

  <Thing rdf:about="onto.owl#Erba">
    <rdf:type rdf:resource="http://linkedgeodata.org/ontology/Municipality"/>
    <rdf:type rdf:resource="http://linkedgeodata.org/ontology/Place"/>
    <rdf:type rdf:resource="onto.owl#Comune"/>
    <rdf:type rdf:resource="onto.owl#Localizzazione"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Erba</rdfs:label>
    <Locations:haLocalizzazione rdf:resource="onto.owl#Italia"/>
    <Locations:haLocalizzazione rdf:resource="onto.owl#Como"/>
    <Locations:haLocalizzazione rdf:resource="onto.owl#Lombardia"/>
    <Locations:haProvincia rdf:resource="onto.owl#Como"/>
</Thing>

Here the maven pom file of the project:

 <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
    <dependencies>
   <dependency>
         <groupId>org.json</groupId>
         <artifactId>json</artifactId>
          <version>20141113</version>
       </dependency> 

    <dependency>
       <groupId>net.sourceforge.owlapi</groupId>
       <artifactId>owlapi-distribution</artifactId>
       <version>4.0.2</version>
    </dependency>

    <dependency>  
    <groupId>xml-apis</groupId>  
    <artifactId>xml-apis</artifactId>  
    <version>1.4.01</version>  
</dependency>  

    <dependency>
    <groupId>net.sourceforge.owlapi</groupId>
    <artifactId>pellet-profiler-ignazio1977</artifactId>
    <version>2.4.0-ignazio1977</version>
    </dependency>

    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-nop</artifactId>
    <version>1.7.12</version>
    </dependency>

    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
     </dependency>

    </dependencies>
Discipulos
  • 423
  • 8
  • 23
  • Have you ensured your InfModel object has been populated? Also can you post a snippet of your ontology that would return positive results from your query? – Kunal Khaladkar Sep 18 '15 at 04:46
  • Hello, the query I'm trying to perform works in protegè, so the query is correct. The post is updated with a snippet. – Discipulos Sep 19 '15 at 06:54
  • 1
    If you do `model.write(System.out)` is the model being printed to the console correctly? – Kunal Khaladkar Sep 20 '15 at 18:28
  • For a strange reason, the program loops and no output is printed, however the query is executed correctly except labels. – Discipulos Sep 21 '15 at 09:05
  • Instead, if i use jena: `OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF); FileManager.get().loadModel(thefile);` where thefile is the exported inferences of Pellet, everything works. There is a way to pass the inferences of Pellet to Jena without writing on file ? – Discipulos Nov 10 '15 at 12:11

0 Answers0