0

我现在去耶拿和 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 |
=============
-------------

我想我并没有真正理解查询的概念。拜托,有人可以帮我举这个例子吗?

4

0 回答 0