OpenRefine + RDF:处理重复出现的情况
使用带有 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.
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" .
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与此同时,RDF-Transform出现了。它有这个问题的答案。它的工作方式略有不同,此屏幕截图中突出显示的哺乳动物就是例证。
一个警告:我看到 此问题在 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.
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.