我正在使用带有OWL API的Pellet来填充本体和Jena进行一些查询。问题是我在查询标签时没有获得结果。我的代码是:
Path
如果我要求标签,例如使用
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 );
我得到一个空字符串作为标签。该查询适用于protegè,提供所请求的标签。有什么建议吗?
本体论的片段:
Select ?x ?y
WHERE { ?x rdfs:label ?y.}
这是项目的maven pom文件:
<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>