我现在正在接受耶拿和SPARQL,我正在努力解决这些问题
我试图从以下本体中获取类型。
uspv:R3 a pv:Report.
uspv:R3 pv:atTime uspv:R3t.
uspv:R3t a owltime:Interval;
owltime:hasDateTimeDescription uspv:R3dtDescription.
uspv:R3dtDescription owltime:unitType owltime:unitYear;
owltime:year "1871"^^xsd:gYear.
uspv:R3 pv:category pv:riot.
uspv:R3 pv:motivation pv:political.
uspv:R3 pv:motivation pv:race.
uspv:R3 pv:fatalities uspv:R3f.
uspv:R3f a pv:FatalitiesValue;
pv:unstructuredFatalities "0"^^xsd:string;
pv:fatalitiesValue "0"^^xsd:integer.
uspv:R3 pv:location uspv:R3l.
uspv:R3l a pv:Location;
pv:unstructuredLocation "Putnam Co"^^xsd:string.
uspv:R3 pv:source uspv:R3s.
uspv:R3s a pv:Source;
pv:unstructuredSource "Gilje"^^xsd:string.
uspv:R3 pv:description "Race riot during an election to replace a murdered black official. Trelease, p.319\n"^^xsd:string.
这只是 TTL 文件的一小部分,我设法阅读并创建了一个模型。现在我尝试使用以下代码来检索类型。
private static void query() {
String queryString = "" +
"PREFIX da: <http://dacura.cs.tcd.ie/data/politicalviolence/uspv/>" +
"PREFIX w3: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"SELECT ?type" +
"WHERE { da:R3t w3:type ?type. }";
com.hp.hpl.jena.query.Query query = QueryFactory.create(queryString);
QueryExecution qExe = QueryExecutionFactory.sparqlService( "http://dbpedia.org/sparql", query );
ResultSet results = qExe.execSelect();
ResultSetFormatter.out(System.out, results, query) ;
}
我的输出只是:
-------------
| typeWHERE |
=============
-------------
我认为我并没有真正了解查询的概念。拜托,有人可以帮我这个例子吗?