这是一张我的OpenRefine项目的照片。我需要将skos的所有实例:CloseMacth从一个RDF/XML列中提取到一个单独的OpenRefine列中。
这是我的RDF/XML代码:
<rdf:RDF xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/1999/02/22-rdf-schema#" xmlns:cs="http://purl.org/vocab/changeset/schema#" xmlns:skosxl="http://www.w3.org/2008/05/skos-xl#">
<rdf:Description rdf:about="http://id.loc.gov/authorities/subjects/sh85145648">
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
<skos:prefLabel xml:lang="en">Water-supply</skos:prefLabel>
<skosxl:altLabel>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2008/05/skos-xl#Label"/>
<skosxl:literalForm xml:lang="en">Availability, Water</skosxl:literalForm>
</rdf:Description>
</skosxl:altLabel>
<skosxl:altLabel>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2008/05/skos-xl#Label"/>
<skosxl:literalForm xml:lang="en">Water availability</skosxl:literalForm>
</rdf:Description>
</skosxl:altLabel>
<skosxl:altLabel>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2008/05/skos-xl#Label"/>
<skosxl:literalForm xml:lang="en">Water resources</skosxl:literalForm>
</rdf:Description>
</skosxl:altLabel>
<skos:closeMatch rdf:resource="http://www.yso.fi/onto/yso/p9967"/>
<skos:closeMatch rdf:resource="http://id.worldcat.org/fast/1172350"/>
<skos:closeMatch rdf:resource="http://www.wikidata.org/entity/Q1061108"/>
<skos:closeMatch rdf:resource="http://id.worldcat.org/fast/1172350"/>
<skos:closeMatch rdf:resource="http://www.wikidata.org/entity/Q1061108"/>
<skos:closeMatch rdf:resource="http://www.yso.fi/onto/yso/p9967"/>
<skos:changeNote>
<cs:ChangeSet>
<cs:subjectOfChange rdf:resource="http://id.loc.gov/authorities/subjects/sh85145648"/>
<cs:creatorName rdf:resource="http://id.loc.gov/vocabulary/organizations/dlc"/>
<cs:createdDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">1986-02-11T00:00:00</cs:createdDate>
<cs:changeReason rdf:datatype="http://www.w3.org/2001/XMLSchema#string">new</cs:changeReason>
</cs:ChangeSet>
</skos:changeNote>
<skos:changeNote>
<cs:ChangeSet>
<cs:subjectOfChange rdf:resource="http://id.loc.gov/authorities/subjects/sh85145648"/>
<cs:creatorName rdf:resource="http://id.loc.gov/vocabulary/organizations/dlc"/>
<cs:createdDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2016-11-17T07:36:37</cs:createdDate>
<cs:changeReason rdf:datatype="http://www.w3.org/2001/XMLSchema#string">revised</cs:changeReason>
</cs:ChangeSet>
</skos:changeNote>
</rdf:Description>
</rdf:RDF>我尝试使用这个代码value.parseHtml().select('skos|closematch')来添加一个基于RDF/XML列的列,但是它不起作用。
发布于 2022-10-17 19:00:52
你的代码非常接近。您是否正在检查预览栏的显示以帮助指导您?
您的代码返回一个由六个XML元素组成的数组。你错过的是:
forEach()htmlAttr()join()中的单个值的内容总而言之,它看起来像:forEach(value.parseHtml().select('skos|closeMatch'), element, element.htmlAttr('rdf:resource')).join('|')
我实际上是从内到外构建的,方法是从一个元素开始:value.parseHtml().select('skos|closeMatch')[0],查看它的外观,然后在用forEach(...).join('|')包装整个事物之前添加.htmlAttr('rdf:resource') (显然,您可以选择最有用的分隔符)。
Update:您的数据有重复项,因此您可能需要添加.uniques(),如:
forEach(value.parseHtml().select('skos|closeMatch'), element, element.htmlAttr('rdf:resource')).uniques().join('|')
发布于 2022-10-15 20:02:07
你想要的结果是什么?我刚刚将您的代码复制到OR的剪贴板中,并选择rdf:Description作为第一个XML元素。我假设您的问题中的代码只是一个简短的示例,您实际上在rdf:RDF元素(即)中有几个rdf:RDF,因此您可以为每个rdf:Description获得一个记录。
这就是我在“配置解析选项”窗格中得到的.

当我创建Project并切换到行模式时,这就是我得到的结果。

第三列是你所说的(?):
skos的所有实例:CloseMacth从一个RDF/XML列到OpenRefine中的一个单独列。
如果没有,请澄清编辑你的问题。
https://stackoverflow.com/questions/74080138
复制相似问题