我在此网站MESH Query上执行此代码,它会返回正确的结果 但是当我使用Jena执行时,它返回null。 在耶拿
String s = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX meshv: <http://id.nlm.nih.gov/mesh/vocab#>
PREFIX mesh: <http://id.nlm.nih.gov/mesh/>
PREFIX mesh2015: <http://id.nlm.nih.gov/mesh/2015/>
PREFIX mesh2016: <http://id.nlm.nih.gov/mesh/2016/>
PREFIX mesh2017: <http://id.nlm.nih.gov/mesh/2017/>
SELECT ?d ?dName ?c ?cName
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
?d a meshv:Descriptor .
?d meshv:concept ?c .
?d rdfs:label ?dName .
?c rdfs:label ?cName
FILTER(REGEX(?dName,'infection','i') || REGEX(?cName,'infection','i'))
}
ORDER BY ?d ";
Query query = QueryFactory.create(s);
QueryExecution qe = QueryExecutionFactory.sparqlService("http://id.nlm.nih.gov/mesh/sparql", query );
ResultSet results = qe.execSelect();
ResultSetFormatter.out(System.out, results, query);
答案 0 :(得分:2)
您必须使用QueryEngineHTTP
,以便通过HTTP参数inference=true
启用推理:
Query query = QueryFactory.create(s);
QueryEngineHTTP qe = new QueryEngineHTTP("http://id.nlm.nih.gov/mesh/sparql", query );
qe.addPAram("inference", "true")
ResultSet results = qe.execSelect();
ResultSetFormatter.out(System.out, results, query);
答案 1 :(得分:0)
我编辑了查询,但我有一个不同的结果,因为&#34; http://id.nlm.nih.gov/mesh/sparql&#34;不知道meshv:Descriptor所以我删除了它,现在我试图重新构造查询以获得相同的结果