0

我使用 Pellet 和 OWL API 来填充本体和 Jena 进行一些查询。问题是我在查询标签时没有获得结果。我的代码是:

 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 );

如果我要求一个标签,例如使用
Select ?x ?y WHERE { ?x rdfs:label ?y.}
我获得一个空字符串作为标签。该查询在 protegè 中工作,提供所请求的标签。有什么建议吗?

本体的片段:

  <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>

这里是项目的maven pom文件:

 <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>
4

0 回答 0