RMLio / yarrrml-parser

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

Named graph example from the YARRRML spec fails to parse #188

Closed namedgraph closed 1 year ago

namedgraph commented 1 year ago

Issue type: :bug: Bug

Mapping with graphs fails to parse. The tutorial and the spec seem suspect re. the graphs (plural) key, because in other examples I'm seeing graph (singular)?

Description

I'm following the 9.8.1 All triples example in order to place my output triples into a named graph:

mappings:
  ParentSmth:
    sources: RelatedSmth
    graphs: smth:$(id)
    s: smth:$(id)#this
    po:
      - p: ont:isSmthOf
        o:
          - mapping: ChildSmth

Steps

% yarrrml-parser -i RelatedSmth.yml -o RelatedSmth.ttl
TypeError: mapping.graphs.forEach is not a function
    at expandTargetsInMapping (/opt/homebrew/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:235:20)
    at expandMappings (/opt/homebrew/lib/node_modules/@rmlio/yarrrml-parser/lib/expander.js:55: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:106:23)
    at Module._compile (node:internal/modules/cjs/loader:1246:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1300:10)
    at Module.load (node:internal/modules/cjs/loader:1103:32)
    at Module._load (node:internal/modules/cjs/loader:942:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'INVALID_YARRRML'
}

Environment

yarrrml-parser 1.4.0. openjdk 17.0.6 2023-01-17 OpenJDK Runtime Environment Homebrew (build 17.0.6+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.6+0, mixed mode, sharing)

namedgraph commented 1 year ago

graph key does what I need, so it looks like an error in the tutorial and the documentation?

namedgraph commented 1 year ago

@bjdmeest ping

bjdmeest commented 1 year ago

Ah yes, that's a small bug in the yarrrml-parser, yarrrml below works, but a fix is in the making

mappings:
  ParentSmth:
    sources: RelatedSmth
    graphs:
      - smth:$(id)
    s: smth:$(id)#this
    po:
      - p: ont:isSmthOf
        o:
          - mapping: ChildSmth
bjdmeest commented 1 year ago

this got fixed by v1.5.0: https://github.com/RMLio/yarrrml-parser/commit/a13aceb30b6334810d8703f944f0eaf25f2d4c9c