RMLio / yarrrml-parser

A YARRRML parser library and CLI in Javascript
MIT License
41 stars 17 forks source link

<#FunctionMap> reusability in YARRRML #134

Closed robert-mieth closed 3 years ago

robert-mieth commented 3 years ago

Issue type: :question: Question

Whenever I need to reuse (nested or more complex) functions in multiple maps, I use function maps in RML.

Something like:

_:function1
    fnml:functionValue [
    rr:predicateObjectMap _:join ;
    rr:predicateObjectMap [
            rr:predicate grel:p_array_a ;                   
            rr:objectMap [ rr:constant "http://example.com" ]
        ] ;
    rr:predicateObjectMap _:separator ;
    rr:predicateObjectMap _:random ;
    ] .

Is there also a notation in YARRRML that allows the definition of such function maps? I've had a look at https://rml.io/yarrrml/spec/#functions and https://rml.io/yarrrml/tutorial/getting-started/, but did not come across something.

pheyvaer commented 3 years ago

Hi @robert-mieth

Thank your for your question! There is no direct support in YARRRML for this, but maybe anchors (which are part of YAML) might be helpful here. https://www.educative.io/blog/advanced-yaml-syntax-cheatsheet#anchors

Let me know if this resolves your issue!

robert-mieth commented 3 years ago

Hi @pheyvaer

Thank you for your quick reply! Anchors and aliases seem like a great way to deal with exact duplicates of sequences/dictionaries.

As a side note: I've also tried to modify anchors (for parameters:) with overrides/extensions, but with little success. This could be helpful if one were to reuse the same function map in different maps, but with a specific parameter for each map (such as a specific URI).

Thanks again!