简体   繁体   English

将三元组上传到 Fuseki 数据集中避免 IRI 冲突

[英]Upload triples into Fuseki dataset avoiding IRI clashes

I have created a dataset using the web GUI of Apache Jena Fuseki and now I would like to programmatically upload some triples into the remote dataset using RDFConnection .我已经使用 Apache Jena Fuseki 的 Web GUI 创建了一个数据集,现在我想使用RDFConnection以编程方式将一些三元组上传到远程数据集。

The triples that I would like to upload come from different sources and I want to avoid creating RDF nodes that have IRIs already present in the remote dataset.我想上传的三元组来自不同的来源,我想避免创建远程数据集中已经存在 IRI 的 RDF 节点。 Is there a way to do that without explicitly querying the remote dataset?有没有办法在不显式查询远程数据集的情况下做到这一点? Returning a list of all the IRIs is a waste of resources.返回所有 IRI 的列表是一种资源浪费。

For instance, if I have this dataset (in Turtle syntax) in my remote triple store:例如,如果我的远程三元组存储中有这个数据集(使用 Turtle 语法):

<iri_1> a foaf:Person
<iri_2> a foaf:Person
...
<iri_n> a foaf:Person

and I would like to add a new individual of foaf:Person which is not the same of the existing ones, how do I generate an IRI for the new individual without the risk of using one already existing in the remote dataset?并且我想添加一个新的foaf:Person个体,它与现有个体不同,我如何为新个体生成 IRI 而不使用远程数据集中已经存在的个体?

From your example it looks like each subject is named after the number of occurrences of the class.从您的示例中,看起来每个主题都以类的出现次数命名。 To keep doing this, I would count the number of foaf:Persons there are (trivial and quick sparql query) and just offset new subjects from the count.为了继续这样做,我会计算 foaf:Persons 的数量(简单而快速的 sparql 查询),然后从计数中抵消新的主题。

If you can't contact the database then I would just generate uuids, which should never clash.如果您无法联系数据库,那么我只会生成 uuid,它永远不会发生冲突。 The subjects won't be visually appealing, but they certainly won't clash.主题不会在视觉上吸引人,但它们肯定不会发生冲突。 You should be able to use UUID out of java.util .您应该能够使用java.util UUID RDFUnit has an example of generating unique IRIs using JennaUUID , which should also work for you. RDFUnit有一个例子生成使用独特的虹膜JennaUUID ,这也应该为你工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM