Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function composition in subject URI template #231

Closed
namedgraph opened this issue Dec 12, 2023 · 7 comments
Closed

Function composition in subject URI template #231

namedgraph opened this issue Dec 12, 2023 · 7 comments

Comments

@namedgraph
Copy link

namedgraph commented Dec 12, 2023

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?

@bjdmeest
Copy link
Collaborator

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]

@namedgraph
Copy link
Author

Thank you!

@namedgraph
Copy link
Author

namedgraph commented Dec 13, 2023

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.

@namedgraph namedgraph reopened this Dec 13, 2023
@namedgraph
Copy link
Author

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'
}

@bjdmeest
Copy link
Collaborator

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) ]

@bjdmeest
Copy link
Collaborator

tracking in RMLio/yarrrml-parser#206

@namedgraph
Copy link
Author

Thanks, this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants