1
我有一个SPARQL查询SPARQL查询结果在耶拿语法
同样的查询给门徒和耶拿之间的不同结果的结果的问题
在门徒,查询是:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?subject
WHERE { ?subject rdfs:label ?object}
结果是:字符串(症状的标签)
在耶拿,代码:
String path = "file:///D:/onto/owl ontologies/symp.owl";
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
String stringQuery
= "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
+ "SELECT ?symptoms "
+ " WHERE { ?symptoms rdfs:label ?object }";
Query query = QueryFactory.create(stringQuery);
QueryExecution executeQuery = QueryExecutionFactory.create(query,model);
org.apache.jena.query.ResultSet res = executeQuery.execSelect();
model.read(path);
while (res.hasNext()) {
QuerySolution qs = res.nextSolution();
Resource symp = qs.getResource("symptoms");
System.out.println(symp);
}
结果是:这些URI
使用的本体:http://purl.obolibrary.org/obo/symp.owl
我怎样才能得到只有标签 “症状” 感谢您的帮助。
非常感谢你** @ AKSW **它完美的作品 –