RMLio / yarrrml-parser

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

Parser error on predicate with function #178

Open lpmeyer opened 1 year ago

lpmeyer commented 1 year ago

Issue type: :bug: Bug

Description

When defining a predicate mapping with a function, yarrrml produces the following parsing error:

TypeError: Cannot read property 'length' of undefined
    at /app/lib/rml-generator.js:89:47
    at Array.forEach (<anonymous>)
    at /app/lib/rml-generator.js:87:27
    at Array.forEach (<anonymous>)
    at /app/lib/rml-generator.js:80:34
    at Array.forEach (<anonymous>)
    at RMLGenerator.convertExpandedJSON (/app/lib/rml-generator.js:57:35)
    at RMLGenerator.convert (/app/lib/abstract-generator.js:81:17)
    at Object.<anonymous> (/app/bin/parser.js:106:23)
    at Module._compile (internal/modules/cjs/loader.js:999:30)

Steps

example yarrrml with a function in the predicate mapping:

---
prefixes:
  ex: http://example.com/
  grel: http://example.com/grel/

mappings:
  application:
    sources:
      - ['Application.csv~csv']
    po:
      - o: ex:numberOfApplications
        p:
          - function: grel:trim
            parameters:
              - [grel:valueParameter, $(Number of applications)]
            datatype: xsd:int

This mapping is an adapted version of test/datatype-on-function/mapping.yarrrml, just added a source definition and switched predicate and object. This adapted mapping probably would not be usefull or correct, but I found it as a minimal test case for reproducing the error I get with a more complex mapping.

Environment

using yarrrml version 1.3.6 from container image docker.io/rmlio/yarrrml-parser