首页 > 解决方案 > 检查具有非确定性(基于 UUID)URI 的 RDF 模型之间的差异?

问题描述

我和一所大学分别将电子健康记录实例化为三元组。 我们想比较我们的 10k 到 100k 三元组的集合,看看它们是否具有相同的形状。

作为一项策略,我基于 UUID 创建 URI,因此其中没有嵌入任何语义。我想坚持这个政策,因为我和我的大学真的在尝试从整体上比较现有的工作流程。

我知道如何在 TopBraid Composer 中比较两个 RDF 文件,但我认为如果我们有相同的数据模式但不同的 URI,它不会有用。我将我的三元组存储在 Ontotext GraphDB 中,但很高兴使用任何其他工具。

例如,关于 person ...fe54977c174a和 person ...的三元组4bcdc1c8abf9应该被认为是等价的,但 ...fe54977c174a和 ...ae00dc86b3bb不应该。 这可行吗?

ASK我不希望对手工制作的 SPARQL语句进行抽查。

@prefix ns0: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.com/4f79ea05-2358-4f43-a335-fe54977c174a>
  a <http://example.com/Person> ;
  ns0:gender ns0:Male ;
  ns0:participatesIn ns0:5d2dfc7b-994c-4933-b787-f7971dae397c .

ns0:5d2dfc7b-994c-4933-b787-f7971dae397c
  a ns0:HealthCareEncounter ;
  ns0:startDate "2019-05-01"^^xsd:date ;
  ns0:hasOutput ns0:a129ca96-c6d2-4a07-a4eb-4cf9ce23a314 .

ns0:a129ca96-c6d2-4a07-a4eb-4cf9ce23a314
  a ns0:Diagnosis ;
  ns0:mentions ns0:Headache .

具有与此相同的形状(尽管 URI 不同):

@prefix ns0: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.com/a740d254-084c-4621-b06d-4bcdc1c8abf9>
  a <http://example.com/Person> ;
  ns0:gender ns0:Male ;
  ns0:participatesIn ns0:060d2091-b4f7-406d-ab0d-75b39b400823 .

ns0:060d2091-b4f7-406d-ab0d-75b39b400823
  a ns0:HealthCareEncounter ;
  ns0:startDate "2019-05-01"^^xsd:date ;
  ns0:hasOutput ns0:bc549711-ed9d-4db6-8cf9-d43022903ef7 .

ns0:bc549711-ed9d-4db6-8cf9-d43022903ef7
  a ns0:Diagnosis ;
  ns0:mentions ns0:Headache .

但这在结构上是不同的(由于不同的性别和诊断提及):

@prefix ns0: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.com/aa3a977a-999a-4c5c-9524-ae00dc86b3bb>
  a <http://example.com/Person> ;
  ns0:gender ns0:Female ;
  ns0:participatesIn ns0:b31a62a5-337a-454d-a637-85aefef26684 .

ns0:b31a62a5-337a-454d-a637-85aefef26684
  a ns0:HealthCareEncounter ;
  ns0:startDate "2019-05-01"^^xsd:date ;
  ns0:hasOutput ns0:6566d543-773e-4649-b589-66eb3d0f3165 .

ns0:6566d543-773e-4649-b589-66eb3d0f3165
  a ns0:Diagnosis ;
  ns0:mentions ns0:Nausea .

标签: sparqlrdfgraphdbtopbraid-composer

解决方案


Eclipse Rdf4j(与 GraphDB 捆绑)包含一个图同构实用程序:Models.isomorphic。默认情况下,它只执行空白节点到空白节点的映射。所以你有两个选择:

  1. 用(字典映射的)空白节点替换图中的每个 IRI。使用 HashMap 和一些循环或流式魔法应该很容易做到这一点。
  2. 查看 Models 实用程序的代码,并调整它执行空白节点映射的位以改为执行 IRI 映射。

推荐阅读