我无法理解如何使用Jena查询DBpedia . 在像here(清单4)这样的教程中,模型初始化如下:
// Open the bloggers RDF graph from the filesystem
InputStream in = new FileInputStream(new File("bloggers.rdf"));
// Create an empty in-memory model and populate it from the graph
Model model = ModelFactory.createMemModelMaker().createModel();
model.read(in,null); // null base URI, since model URIs are absolute
in.close();
假设我想编写一个列出巴黎教堂的查询 . 在SPARQL中它看起来像(取自this mailing list message):
PREFIX p: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX geo: <http://www.georss.org/georss/>
SELECT DISTINCT ?m ?n ?p ?d
WHERE {
?m rdfs:label ?n.
?m skos:subject ?c.
?c skos:broader category:Churches_in_Paris.
?m p:abstract ?d.
?m geo:point ?p
FILTER ( lang(?n) = "fr" )
FILTER ( lang(?d) = "fr" )
}
这个查询在Java中如何看待?特别是,我对如何初始化模型对象感兴趣 .
1 回答
浏览了大量的页面后,我找到了答案 . 也许我没有明确地提出这个问题,但无论如何,下面的代码对我有用 .
我在dbpedia-discussion of www.mail-archive.com page找到了这个答案 .