[英]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.