RMLio / yarrrml-parser

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

graphs only work on array notation (cfr. tutorial example) #167

Closed wouterbeek closed 8 months ago

wouterbeek commented 2 years ago

Issue type: :bug: Bug

The example on https://rml.io/yarrrml/tutorial/getting-started/#complete-yarrrml-document does not work.

Description

When I run this tool using the example documented on the above shared link, the following error message is emitted:

TypeError: mapping.graphs.forEach is not a function
    at expandTargetsInMapping (/usr/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:235:20)
    at expandMappings (/usr/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:55:9)
    at expand (/usr/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:36:3)
    at RMLGenerator.convert (/usr/lib/node_modules/@rmlio/yarrrml-parser/lib/abstract-generator.js:60:30)
    at Object.<anonymous> (/usr/lib/node_modules/@rmlio/yarrrml-parser/bin/parser.js:106:23)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
  code: 'INVALID_YARRRML'
}

Steps

  1. Copy/paste the Yaml snippet below in a file called rules.yml.
  2. Run the command yarrrml-parser -i rules.yml -o rules.rml.ttl
  3. Observe the above shared error message.
prefixes:
  ex: http://www.example.com/

mappings:
  people:
    sources:
      - ['people.csv~csv']
    s: ex:$(id)
    graphs: ex:Characters
    po:
      - [a, ex:Person]

Environment

Ubuntu LTS + Java 11

bjdmeest commented 2 years ago

Woops, that's a bug in the parser alright! it should support both single values as arrays for (amongst others) graphs, but it seems only single values are currently supported. The snippet below does work (note the array notation for graphs). We'll follow-up with a bugfix! (Feel free to create a PR yourself ;) but already a huge thanks for the detailed bug report! )

prefixes:
  ex: http://www.example.com/

mappings:
  people:
    sources:
      - ['people.csv~csv']
    s: ex:$(id)
    graphs:
      - ex:Characters
    po:
      - [a, ex:Person]
wouterbeek commented 2 years ago

Thanks @bjdmeest !

Feel free to create a PR yourself

I'm not a programmer, so it is better for all parties involved if I leave this to others ;-) I can of course help in testing.

namedgraph commented 1 year ago

Related to #188

bjdmeest commented 8 months ago

This got fixed in v1.5.0, see #188