RMLio / yarrrml-parser

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

Support nested functions in the shortcut #190

Open bjdmeest opened 1 year ago

bjdmeest commented 1 year ago

Issue type: :unicorn: Feature

Description

Support nested functions using the YARRRML shortcuts

Why it is useful

Shorter YARRRML

Existing features it breaks

None

below works

prefixes:
  ex: "http://example.com/"
  idlab-fn: http://example.com/idlab/function/
  grel: http://users.ugent.be/~bjdmeest/function/grel.ttl#

mappings:
  person:
    sources:
      - ['data.json~jsonpath', '$.persons[*]']
    s: http://example.com/$(firstname)
    po:
      - [a, foaf:Person]
      - p: ex:name
        o:
          function: grel:controls_if
          parameters:
            - parameter: grel:bool_b
              value:
                function: idlab-fn:equal
                parameters:
                  - [grel:valueParameter, $(firstname)]
                  - [grel:valueParameter2, "John"]
            - [grel:any_true, $(firstname)]
            - [grel:any_false, "Jack"]

But the shortcut version doesn't work

prefixes:
  ex: "http://example.com/"
  idlab-fn: http://example.com/idlab/function/
  grel: http://users.ugent.be/~bjdmeest/function/grel.ttl#

mappings:
  person:
    sources:
      - ['data.json~jsonpath', '$.persons[*]']
    s: http://example.com/$(firstname)
    po:
      - [a, foaf:Person]
      - p: ex:name
        o: grel:controls_if(grel:bool_b = idlab-fn:equal(grel:valueParameter = $(firstname), grel:valueParameter2 = "John"), grel:any_true = $(firstname), grel:any_false = "Jack")