OpenRefine + RDF:处理重复出现的情况

发布于 2025-01-15 03:44:25 字数 1225 浏览 2 评论 0原文

使用带有 RDF 扩展的 OpenRefine 将 XML 转换为 RDF。这是 OR 中的示例记录。

输入图片这里的描述

我一直在寻找一种方法来处理重复出现的情况,在本例中是动物 - 较窄中的两次。这就是我得到的:

@prefix ex: <http://example.com/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

ex:mammals a skos:Concept;
skos:narrower "ex:cats, ex:cows" .

在此处输入图像描述

在 RDF 节点窗格中,我将窄条映射到文本,并使用下面的 GREL 将所有出现的内容与 ex:< /代码>前缀。

forEach(row.record.cells['animals - narrower'].value,v,'ex:'+v).join(', ')

几乎就是我想要的。理想情况下,不应有引号:

ex:mammals a skos:Concept;
skos:narrower ex:cats, ex:cows .

换句话说,我想映射到 URI 类型,但为了更好的易读性,我想保留 ex: 前缀,而不是完整的 URI。另外,我想将它们保留为一个“skos:narrower”谓词的重复对象,而不是每次出现时都包含谓词+对象的行。

我知道如何使用编辑器删除引号。我只是希望有一种比我找到的更好的方法。

此外,我知道如何将重复出现的情况分散到各个新列并映射每个新列,但在现实生活中,我必须将 100 多个列映射到少数目标 skos 字段。这不是自动化的目的。

Converting XML to RDF using OpenRefine with the RDF-extension. Here's a sample record in OR.

enter image description here

I've been looking for a way to handle repeated occurrences, in this case two in animals - narrower. This is what I got to:

@prefix ex: <http://example.com/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

ex:mammals a skos:Concept;
skos:narrower "ex:cats, ex:cows" .

enter image description here

In the RDF node pane, I'm mapping the narrowers to text, and use below GREL to get all the occurrence on one line with the ex: prefix.

forEach(row.record.cells['animals - narrower'].value,v,'ex:'+v).join(', ')

It's almost what I want. Ideally, there should be no quotes:

ex:mammals a skos:Concept;
skos:narrower ex:cats, ex:cows .

In other words, I want to map to a URI type, but for better legibility, I want to keep the ex: prefix, rather than the full URI. Also I want to keep them as a repeated objects to the one `skos:narrower' predicate, not a line with predicate + object for each occurrence.

I know how to get rid of the quotes using an editor. I'm just hoping there's a better way than the one I've found.

Also, I know how to spread repeated occurrences over individual new columns and map each new column, but in real life I would have to map over 100 columns to only a handful of target skos fields. That's not what automation is for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流云如水 2025-01-22 03:44:25

与此同时,RDF-Transform出现了。它有这个问题的答案。它的工作方式略有不同,此屏幕截图中突出显示的哺乳动物就是例证。

RDF-转换显示重复的 prefLabels。

一个警告:我看到 此问题在 Windows 10 中使用 JRE 运行扩展。我发现的解决方法是使用 WSL 中的 RDF-Transform 插件运行 OpenRefine。

Meanwhile, RDF-Transform emerged. It has the answer to this question. There is a slight difference in the way it works, exemplified by the highlighted mammals in this screenshot.

RDF-Transform showing repeated prefLabels.

One caveat: I am seeing this issue running the extension in Windows 10 with with the JRE. The workaround that I found is to run OpenRefine with RDF-Transform plugin from WSL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文