英文:
Generating condition-based rdf:type triples using YARRRML mapping
问题
我正在进行一个需要根据数据中的值分配rdf:type
的实现。
示例:
ID,Species
1,Rat
2,Eagle
ID-1应分配类型为"Animal",ID-2应分配类型为"Bird"。
我在条件映射方面遇到了困难。我尝试了这个YARRRML映射:
- p: a
o:
value: http://example.com/Animal
condition:
function: idlab-fn:equal
parameters:
- [grel:valueParameter, $(Species)]
- [grel:valueParameter2, "Rat"]
英文:
I’m working on an implementation that requires assigning rdf:type
based upon a value in the data.
Example:
<!-- language: lang-none -->
ID,Species
1,Rat
2,Eagle
ID-1 should be assigned type as "Animal" and ID-2 should be assigned type as "Bird".
I’m stuck with the conditional mapping. I tried this YARRRML mapping:
<!-- language: lang-yaml -->
- p: a
o:
value: http://example.com/Animal
condition:
function: idlab-fn:equal
parameters:
- [grel:valueParameter, $(Species)]
- [grel:valueParameter2, "Rat"]
答案1
得分: 1
问题可能在于条件是在对象级别而不是高一级别定义的(请参见 https://rml.io/yarrrml/spec/#conditions),以下似乎有效(在 Matey 上进行了测试):
prefixes:
ex: "http://example.com/"
idlab-fn: "http://example.com/idlab/function/"
grel: "http://users.ugent.be/~bjdmeest/function/grel.ttl#"
mappings:
person:
sources:
- ['test.csv~csv']
s: http://example.com/$(ID)
po:
- p: rdf:type
o: ex:Animal~iri
condition:
function: idlab-fn:equal
parameters:
- [grel:valueParameter, "Rat"]
- [grel:valueParameter2, $(Species)]
- [ex:name, $(Species)]
英文:
The problem might be that the condition is defined at the object instead of one level higher (see https://rml.io/yarrrml/spec/#conditions), the following seems to work (tested on Matey)
prefixes:
ex: "http://example.com/"
idlab-fn: "http://example.com/idlab/function/"
grel: "http://users.ugent.be/~bjdmeest/function/grel.ttl#"
mappings:
person:
sources:
- ['test.csv~csv']
s: http://example.com/$(ID)
po:
- p: rdf:type
o: ex:Animal~iri
condition:
function: idlab-fn:equal
parameters:
- [grel:valueParameter, "Rat"]
- [grel:valueParameter2, $(Species)]
- [ex:name, $(Species)]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论