gpt4 book ai didi

java - DBpedia Jena 查询返回空值

转载 作者:搜寻专家 更新时间:2023-11-01 02:28:25 26 4
gpt4 key购买 nike

我只是想在 DBpedia 上运行一个小查询,查询本身有效,请参阅 here ,但我不明白为什么在与 Jena 一起这样做时它会返回,我得到 null。

String service = "http://dbpedia.org/sparql";
String queryString = "";
queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label" +
"WHERE {" +
"<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y ."+
"?y rdfs:label ?label ."+
"FILTER (LANG(?label) = 'en')"+
"}";

Query query = QueryFactory.create(queryString);
QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest(service, query);
ResultSet results = qexec.execSelect();
for ( ; results.hasNext() ; ) {
QuerySolution soln = results.nextSolution() ;
System.out.println(soln.getLiteral("label"));
}

有什么建议吗?

最佳答案

太尴尬了,查询有空格问题:

String service = "http://dbpedia.org/sparql";
String queryString = "";
queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label " +
"WHERE {" +
"<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y ."+
"?y rdfs:label ?label ."+
"FILTER (LANG(?label) = 'en')"+
"}";

关于java - DBpedia Jena 查询返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15663510/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com