RDF4j v3.0.0导出图中没有推断的三元组

时间:2019-09-25 14:15:22

标签: rdf4j

在版本3.0.0中,

,因为推断的三元组已添加到实际图形中(而不是像以前那样添加到默认图形中),是否可以以某种方式导出/获取没有推断的三元组的实际图形? 非常感谢。

1 个答案:

答案 0 :(得分:0)

是的,这是可能的。

1。通过Java API

您可以通过几种方式从命名图http://example.org/graph1中检索语句。在此处显示两种选择:

 IRI graph1 = valueFactory.createIRI("http://example.org/graph1");

 try(RepositoryConnection conn = repository.getConnection()) {

     // option 1: getStatements of everything in a named graph, setting
     // includeInferred to false
     RepositoryResult<Statement> result = conn.getStatement(null, null, null, false, graph1);

    // option 2: using export with an RDFHandler (export never includes inferred triples)
    RDFHandler collector = new StatementCollector(); 
    conn.export(graph1, collector);
 }

2。通过RDF4J Workbench

在工作台中执行此操作的最简单方法是使用SPARQL CONSTRUCT查询:

construct from <http://example.org/graph1> where { ?s ?p ?o }

在单击“执行”之前,请确保未选中“包括推断的语句”选项。然后在查询结果屏幕上,选择您喜欢的下载格式,然后点击“下载”。