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 **它完美的作品 –