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

Interpret function output as an iri #140

Open
florent-andre opened this issue Oct 8, 2021 · 10 comments
Open

Interpret function output as an iri #140

florent-andre opened this issue Oct 8, 2021 · 10 comments

Comments

@florent-andre
Copy link

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
Copy link
Collaborator

pheyvaer commented Oct 8, 2021

Hi @florent-andre

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

@florent-andre
Copy link
Author

  • Not really sure where and how create a test for it.
  • So please find here a patch for a test/function-emit-iri folder (.yaml & .data files)
  • Can be apply with patch-package
    file: patches/@rmlio+yarrrml-parser+1.3.2.patch
diff --git a/node_modules/@rmlio/yarrrml-parser/test/function-emit-iri/data.txt b/node_modules/@rmlio/yarrrml-parser/test/function-emit-iri/data.txt
new file mode 100644
index 0000000..567d50e
--- /dev/null
+++ b/node_modules/@rmlio/yarrrml-parser/test/function-emit-iri/data.txt
@@ -0,0 +1,2 @@
+id;name
+SKOS:PREFLABEL;john
diff --git a/node_modules/@rmlio/yarrrml-parser/test/function-emit-iri/mapping.yaml b/node_modules/@rmlio/yarrrml-parser/test/function-emit-iri/mapping.yaml
new file mode 100644
index 0000000..bc473e2
--- /dev/null
+++ b/node_modules/@rmlio/yarrrml-parser/test/function-emit-iri/mapping.yaml
@@ -0,0 +1,18 @@
+prefixes:
+  ex: "http://example.com/"
+  grel: http://users.ugent.be/~bjdmeest/function/grel.ttl#
+
+mappings:
+  person:
+    sources:
+      - access: data.txt
+        referenceFormulation: csv
+        delimiter: ';'
+    s: http://example.com/$(id)
+    po:
+      -  p: schema:name
+         o:
+          - function: grel:toLowerCase(grel:valueParameter = $(id))
+            # @TODO: add a parameter to bind function output to `iri`
+            # type: iri
+            # datatype: iri

@florent-andre
Copy link
Author

I just get a little more on that :

  • if the function return a full url string this ok (example: http://www.w3.org/2004/02/skos/core#prefLabel)
  • if the function return a namespaced string this bug (example skos:prefLabel) whereas "static string rule" works:
- [schema:name, skos:prefLabel~iri]

@pheyvaer
Copy link
Collaborator

pheyvaer commented Oct 13, 2021

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
Copy link

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

@pheyvaer
Copy link
Collaborator

pheyvaer commented Nov 8, 2022

@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
Copy link

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
Copy link
Collaborator

@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
Copy link

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

@pheyvaer
Copy link
Collaborator

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

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

No branches or pull requests

3 participants