我试图根据以下CONSTRUCT查询推断一些新的三元组:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX gpml: <http://vocabularies.wikipathways.org/gpml#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT {
?line rdf:type wp:DirectedInteraction .
}
WHERE {
?pathway dc:identifier ?wpIdentifier .{
SELECT DISTINCT * WHERE {
?datanode2 dc:identifier ?dn2Identifier .
?datanode2 rdf:type gpml:DataNode .
?datanode2 dcterms:isPartOf ?pathway .
?datanode2 gpml:graphid ?dn2GraphId .
?line gpml:graphref ?dn2GraphId .
FILTER (?datanode2 != ?datanode1)
FILTER (!regex(str(?datanode2), "noIdentifier")) .
{
SELECT DISTINCT * WHERE {
?datanode1 dc:identifier ?dn1Identifier .
?datanode1 gpml:graphid ?dn1GraphId .
?datanode1 rdf:type gpml:DataNode .
?datanode1 dcterms:isPartOf ?pathway .
?line gpml:graphref ?dn1GraphId .
?line rdf:type gpml:Interaction .
?line gpml:arrowTowards ?target .
?line gpml:arrowHead "Arrow"^^xsd:string .
?line gpml:graphid ?lineGraphId .
?line dcterms:isPartOf ?pathway .}}
FILTER (!regex(str(?datanode1), "noIdentifier")) .
}
}
}
提交给基于virtuoso的SPARQL端点时,它会返回预期的结果。但是,如果针对基于Jena的端点提交相同的查询,则返回0个三元组。
public static void main(String[] args) throws IOException {
Model model = FileManager.get().loadModel("/tmp/wpContent_v0.0.72733_20131216.ttl");
BufferedReader constructQueryText = new BufferedReader(new FileReader("sparqlQueries/DirectedInteraction.construct"));
StringBuilder sb = new StringBuilder();
String line = constructQueryText.readLine();
while (line != null) {
sb.append(line);
sb.append('\n');
line = constructQueryText.readLine();
}
String queryText = sb.toString();
Query query = QueryFactory.create(queryText);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
Model results = queryExecution.execConstruct();
basicCalls.saveRDF2File(results, "/tmp/directedInteractions.ttl", "TURTLE");
System.out.println(results.size());
System.out.println(model.size());
}
我已经调试了两天以上,我似乎无法找到任何错误。
如何将CONSTRUCT查询写入基于virtuoso的端点以及发送到Jena实现的端点是否存在差异?