Jena 和 Pellet 搜索标签 returns 错误
Jena and Pellet search on label returns error
我已经在这里工作了几个小时,试图让 Pellet 与 Jenna 一起工作。现在我终于到了它正在工作的地步。查询 类 和推断 类 进展顺利。例如:
SELECT * WHERE { ?x rdf:type uni:Adult}
然而,当尝试使用此查询标签时:
SELECT * WHERE { ?x ?y "Vincent"^^xsd:string}
returns:
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 查询我的 ontology 的 altlabels?
该警告只是说推理器忽略了注释属性上声明的范围。您的查询应该不会受到影响。
好吧,这有点愚蠢。结果我不小心用 OWL/XML 导出了我的 ontology,将其另存为 RDF/XML 修复了这个问题。
我已经在这里工作了几个小时,试图让 Pellet 与 Jenna 一起工作。现在我终于到了它正在工作的地步。查询 类 和推断 类 进展顺利。例如:
SELECT * WHERE { ?x rdf:type uni:Adult}
然而,当尝试使用此查询标签时:
SELECT * WHERE { ?x ?y "Vincent"^^xsd:string}
returns:
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 查询我的 ontology 的 altlabels?
该警告只是说推理器忽略了注释属性上声明的范围。您的查询应该不会受到影响。
好吧,这有点愚蠢。结果我不小心用 OWL/XML 导出了我的 ontology,将其另存为 RDF/XML 修复了这个问题。