【问题标题】:RMLStreamer Function grel:array_join produces inconsistent resultsRMLStreamer 函数 grel:array_join 产生不一致的结果
【发布时间】:2021-11-01 03:03:34
【问题描述】:

在 RMLStreamer 中,grel:arra_join 函数不会产生预期的结果。

映射文件(mapping.ttl)

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix grel:     <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .
@prefix idlab-fn: <http://example.com/idlab/function/> .
@prefix fno:      <https://w3id.org/function/ontology#> .
@prefix gist: <http://ontologies.semanticarts.com/gist#>.
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#> .
@base <http://example.com/base/> .

<TriplesMap1> a rr:TriplesMap;
              rml:logicalSource [
                                    rml:source "student.csv";
                                    rml:referenceFormulation ql:CSV
                                ];
              rr:subjectMap [
                                rr:template "http://example.com/{ID}/{Name}";
                                rr:class foaf:Person
                            ];
              rr:predicateObjectMap [
                                        rr:predicate ex:id ;
                                        rr:objectMap [ rml:reference "ID" ]
                                    ];
              rr:predicateObjectMap [
                                        rr:predicate gist:end;
                                        rr:objectMap <#FunctionMapDateTimeEnd>
                                    ].

<#FunctionMapDateTimeEnd> a fnml:FunctionTermMap;
                          rr:datatype  xsd:dateTime;
                          fnml:functionValue [
                                         rml:logicalSource "student.csv";
                                         rr:predicateObjectMap [
                                                 rr:predicate fno:executes;
                                                 rr:objectMap [ rr:constant grel:array_join ] ;
                                                               ] ;
                                         rr:predicateObjectMap [
                                                 rr:predicate grel:p_array_a ;
                                                 rr:objectMap [ rml:reference "date" ] ;
                                                                ] ;
                                         rr:predicateObjectMap [
                                                rr:predicate grel:p_array_a ;
                                                rr:objectMap [ rr:constant "T12:00:00.000Z"; ] ;
                                                               ] ;
                                             ].

学生.csv

ID,Name,Comment,Class,date
1,Venus,A&B,A,2019-11-01

输出

<http://example.com/1/Venus> <http://ontologies.semanticarts.com/gist#end> "T12:00:00.000Z2019-11-01"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://example.com/1/Venus> <http://example.com/id> "1" .
<http://example.com/1/Venus> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .

输出的问题是 grel:array_join 的连接顺序。多次执行相同的文件会产生不同的结果。

<http://example.com/1/Venus> <http://ontologies.semanticarts.com/gist#end> "T12:00:00.000Z2019-11-01"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://example.com/1/Venus> <http://ontologies.semanticarts.com/gist#end> "2019-11-01T12:00:00.000Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .

但是,预期的输出是每次都以给定的顺序 (2019-11-01T12:00:00.000Z) 加入列表。

与 RMLMapper 相同的映射文件产生一致且正确的结果,并以给定的顺序加入列表。

其他函数,如 grel:toUpperCase 和 idlab-fn:toUpperCaseURL 工作正常,并在 RMLStreamer 和 RMLMapper 中产生正确的结果

【问题讨论】:

    标签: rdf rml-rdf


    【解决方案1】:

    为了解决您的具体问题,您是否尝试过将 &lt;#FunctionMapDateTimeEnd&gt; 替换为带有模板 "{date}T12:00:00.000Z" 的模板值术语映射?或者,您可以link your own function 连接两个字符串。如果该函数使用命名参数,则默认情况下会保留它们的顺序。

    更一般地说,在 RML+FnO 数组参数中保留顺序确实存在一些已知问题,尽管也有修复这些问题的工作,例如参见 this issuerelated community group page

    【讨论】:

    • 感谢您提出解决此特殊情况的解决方案[rr:template "{date}T12:00:00.000Z"; rr:termType rr:Literal;]; 但是,我面临的主要问题是从数据中读取 URL 作为rr:subjectMap IRI 的基础。 SubjectMap 不允许rr:template "{url}"。我发现的解决方案之一建议使用 array_join stackoverflow.com/questions/65900785/… PS:在您的 [this issue] 的答案链接中不起作用。
    猜你喜欢
    • 1970-01-01
    • 2012-01-16
    • 1970-01-01
    • 2017-06-10
    • 1970-01-01
    • 2021-09-06
    • 2017-08-18
    • 2019-12-06
    • 1970-01-01
    相关资源
    最近更新 更多