RMLio / yarrrml-parser

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

Interpret function output as an iri #140

Open florent-andre opened 2 years ago

florent-andre commented 2 years ago

Hy there, Thanks for the good parser here and documentation !

Seeing this rdf:Property~iri. I would like to interpret a function output as a well formed iri string (ex: hrdf:IdentifierType). I don't catch the good syntax.

Here is my example function and "commented tries" :

          - function: rb:replace
            parameters:
              - parameter: rb:scriptName
                value: replace
              - parameter: rb:scriptParameters
                value: -s '$(@type)' -p 'hropen:' -r 'hrdf:'
            # type: iri
            # datatype: iri
pheyvaer commented 2 years ago

Hi @florent-andre

Thanks for the issue! Do you have a full example?

florent-andre commented 2 years ago
florent-andre commented 2 years ago

I just get a little more on that :

pheyvaer commented 2 years ago

I see what you want to achieve. However, this is not possible out of the box, because replacing the prefixes happens during the conversion from YARRRML to RML and at that point is the value of toLowerCase function is not known yet. But it's possible to define custom function that replicates this behavior. Would this work for you?

MadsHolten commented 1 year ago

Any news on this? Would be great if you could specify type: iri for function outputs!

pheyvaer commented 1 year ago

@MadsHolten We didn't get a response from @florent-andre to my last message. Would the solution I propose with a custom function work for you?

MadsHolten commented 1 year ago

How would this work exactly? a custom function that turns a string into a URI and can be nested with the function that generates the string? For now, I do a post-processing that detects objects that are IRIs and convert from key: "iri" to key: {"@id": "iri"}, but this is also quite annoying since there might be cases where the object is an IRI that should not be converted.

pheyvaer commented 1 year ago

@MadsHolten Is your issue with the result of the function that has to be seen as an IRI or is is with the expansion of prefixes?

MadsHolten commented 1 year ago

I would like to be able to return an IRI from my function

pheyvaer commented 1 year ago

Ok, in that case can you create a separate issue with an minimum example so that we can have a look? Thanks!