[英]Jena and Pellet search on label returns error
我已經在這里待了幾個小時,試圖讓Pellet與Jenna合作。 現在,我終於明白了它正在起作用。 查詢類和推斷的類進展順利。 例如:
SELECT * WHERE { ?x rdf:type uni:Adult}
但是,當嘗試使用此查詢標簽時:
SELECT * WHERE { ?x ?y "Vincent"^^xsd:string}
返回:
org.mindswap.pellet.jena.PelletReasoner@1b13b5d
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX uni: <http://localhost/SemanticSearch/semanticsearch.owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT *
WHERE
{ ?x ?y "Vincent"^^xsd:string }
{
"head": {
"vars": [ "x" , "y" ]
} ,
"results": {
"bindings": [
mrt 18, 2015 1:06:41 PM org.mindswap.pellet.jena.graph.loader.DefaultGraphLoader addUnsupportedFeature
WARNING: Unsupported axiom: Ignoring range axiom for AnnotationProperty http://www.w3.org/2000/01/rdf-schema#label
mrt 18, 2015 1:06:41 PM org.mindswap.pellet.jena.graph.loader.DefaultGraphLoader addUnsupportedFeature
WARNING: Unsupported axiom: Ignoring range axiom for AnnotationProperty http://localhost/SemanticSearch/semanticsearch.owl#altLabel
]
}
}
我的完整代碼如下:
Model rawModel = ModelFactory.createDefaultModel();
Reasoner r = PelletReasonerFactory.theInstance().create();
Model data = FileManager.get().loadModel("file:C:/wamp/www/SemanticSearch/workspace/SemanticSearch/src/semanticsearch.owl");
InfModel model = ModelFactory.createInfModel(r, data);
InputStream in = new FileInputStream(new File("C:/wamp/www/SemanticSearch/semanticsearch.owl"));
System.out.println(model.getReasoner());
String sparqlQueryString1= "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#>"+
" PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
" PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"+
" PREFIX uni: <http://localhost/SemanticSearch/semanticsearch.owl#>"+
" SELECT * WHERE { ?x ?y \"Vincent\"^^xsd:string}";
System.out.println(sparqlQueryString1);
Query query = QueryFactory.create(sparqlQueryString1);
QueryExecution qexec = QueryExecutionFactory.create(query, model);
ResultSet results = qexec.execSelect();
//ORGINEEL ResultSetFormatter.out(System.out, results, query);
//ALS RDF ResultSetFormatter.outputAsRDF("", results);
ResultSetFormatter.outputAsJSON(results);
qexec.close() ;
}
Jena中不提供查詢字符串嗎? 甚至在我使用Pellet時也沒有? 還有其他方法可以使用Jena和Pellet查詢我的本體的altlabel嗎?
該警告僅表示推理程序將忽略注釋屬性上聲明的范圍。 您的查詢不應受到它的影響。
好吧,這有點愚蠢。 原來,我不小心使用OWL / XML導出了本體,將其另存為RDF / XML修復了此問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.