0

嘿伙计们,我的 sparql 查询有问题,谁能帮助我。

String queryString = 
 "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
 "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
 "PREFIX type: <http://dbpedia.org/class/yago/>"+
 "PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>"+
 "PREFIX prop: <http://dbpedia.org/property/>"+
 "PREFIX foaf:  <http://xmlns.com/foaf/0.1/>"+
 "SELECT "+ 
 "?description "+
 "FROM <http://dbpedia.org/page/Arctic_Monkeys> "+
"WHERE " +
"{"+
"?x foaf:depiction ?description."+
"}";

Query query = QueryFactory.create(queryString);
    //initializing queryExecution factory with remote service.
    QueryExecution qexec=QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
    //query execution and result processing
    try {
        //simple select
        ResultSet results = qexec.execSelect();
        ResultSetFormatter.out(System.out, results, query);
    }
    finally{
        qexec.close();
    }
}

它不会从 dbpedia 检索所需的数据。我想从一个特定的 dbpedia 页面检索数据

4

1 回答 1

1

识别页面的 IRI 错误。不是page,而是resource。此外,它是图中的资源,而不是(据我所知)命名图,因此您不需要FROM在查询中使用。这是一个有效的查询:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
SELECT ?depiction
WHERE {
  <http://dbpedia.org/resource/Arctic_Monkeys> foaf:depiction ?depiction
}

结果有一排,一张北极猴子在味精玩的照片

于 2013-05-16T16:13:10.243 回答