SPARQL - 从远程端点插入数据

SPARQL - Insert data from remote endpoint

如何查询远程端点(如 DBPedia or Wikidata 的端点)并将生成的三元组插入本地图中?到目前为止,我知道有 INSERT、ADD、COPY 等命令可用于此类任务。 我不明白的是如何在更新我的本地图表时处理远程端点。有人可以提供一个最小示例或主要步骤吗?
我在 Windows 上使用 Apache Jena Fuseki v2,这是我目前的查询:

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wd: <http://www.wikidata.org/entity/>

INSERT 
  { GRAPH <???> { ?s ?p ?o } } #don't know what to insert here for "GRAPH"
WHERE
  { GRAPH  <???> #don't know what to insert here for "GRAPH" either
    {                           #a working example query for wikidata:
      ?s wdt:P31 wd:Q5.         #humans
      ?s wdt:P54 wd:Q43310.     #germans
      ?s wdt:P1344 wd:Q79859.   #part of world cup 2014
      ?s ?p ?o.
    }
  }

我正在查询的本地端点是 http://localhost:3030/mylocaldb/update。我读到 /update 是编辑数据库所必需的(不过我不确定我是否理解正确)。
到目前为止我的方法是否正确?或者是否需要更多东西,例如 SPARQL 之外的额外脚本?

取自 SPARQL 1.1 Update W3C specs:

语法是

( WITH  IRIref )?
INSERT  QuadPattern 
( USING ( NAMED )?  IRIref )*
WHERE GroupGraphPattern

If the INSERT template specifies GRAPH blocks then these will be the graphs affected. Otherwise, the operation will be applied to the default graph, or, respectively, to the graph specified in the WITH clause, if one was specified. If no USING (NAMED) clause is present, then the pattern in the WHERE clause will be matched against the Graph Store, otherwise against the dataset specified by the USING (NAMED) clauses. The matches against the WHERE clause create bindings to be applied to the template for determining triples to be inserted (following the same rules as for DELETE/INSERT).

所以这基本上意味着,如果你想将它存储在默认图形中,你可以省略 INSERT 部分的 GRAPH 定义,否则它将是你想要的图形存储数据。

关于 WHERE 子句,通常您必须在此处使用 SERVICE 关键字以在 Wikidata 端点 (https://query.wikidata.org/bigdata/namespace/wdq/sparql) 上应用联合查询:

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wd: <http://www.wikidata.org/entity/>

INSERT 
  { ?s ?p ?o }
WHERE
  { SERVICE  <https://query.wikidata.org/bigdata/namespace/wdq/sparql> 
    {                           #a working example query for wikidata:
      ?s wdt:P31 wd:Q5.         #humans
      ?s wdt:P54 wd:Q43310.     #germans
      ?s wdt:P1344 wd:Q79859.   #part of world cup 2014
      ?s ?p ?o.
    }
  }

我用 Apache Jena 对其进行了测试,它向我的本地数据集中插入了 4462 个三元组。