RMLio / rmlmapper-java

The RMLMapper executes RML rules to generate high quality Linked Data from multiple originally (semi-)structured data sources

Home Page:http://rml.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function composition in subject URI template

namedgraph opened this issue · comments

This YARRRML generates RML in Matey but does not generate any RDF using the default data.json with persons:

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

mappings:
  person:
    sources:
      - ['data.json~jsonpath', '$.persons[*]']
    s:
      function: grel:array_join
      parameters:
        - [ grel:p_array_a, "https://example.org/" ]
        - parameter: grel:p_array_a
            value:
              function: grel:string_md5
              parameters:
                - [ grel:valueParameter, $(firstname)]
    po:
      - [a, foaf:Person]

What are we doing wrong?

the indentation of value was wrong, creating bogus RML, you can try below

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

mappings:
  person:
    sources:
      - ['data.json~jsonpath', '$.persons[*]']
    s:
      function: grel:array_join
      parameters:
        - [ grel:p_array_a, "https://example.org/" ]
        - parameter: grel:p_array_a
          value:
            function: grel:string_md5
            parameters:
              - [ grel:valueParameter, $(firstname)]
    po:
      - [a, foaf:Person]

Hmm.. I tried applying the same logic to graph but it does not seem to work:

    graph:
      function: grel:array_join
      parameters:
        - [ grel:p_array_a, "bridgestone-qualifications:" ]
        - parameter: grel:p_array_a
          value:
            function: grel:string_md5
            parameters:
              - [ grel:valueParameter, $(label) ]

I get "Could not generate RML rules." in Matey.

This is the yarrrml-parser error:

TypeError: mapping.graphs.forEach is not a function
    at expandTargetsInMapping (/opt/homebrew/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:239:20)
    at expandMappings (/opt/homebrew/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:57:9)
    at expand (/opt/homebrew/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:36:3)
    at RMLGenerator.convert (/opt/homebrew/lib/node_modules/@rmlio/yarrrml-parser/lib/abstract-generator.js:60:30)
    at Object.<anonymous> (/opt/homebrew/lib/node_modules/@rmlio/yarrrml-parser/bin/parser.js:107:23)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'INVALID_YARRRML'
}

That's probably a small bug of the parser, we'll fix it, but in the meantime I think you can just put the graph object in an a array:

graph:
  - function: grel:array_join
    parameters:
      - [ grel:p_array_a, "bridgestone-qualifications:" ]
      - parameter: grel:p_array_a
        value:
          function: grel:string_md5
          parameters:
            - [ grel:valueParameter, $(label) ]

Thanks, this works.