RMLio / rmlmapper-java

The RMLMapper executes RML rules to generate high quality Linked Data from multiple originally (semi-)structured data sources
http://rml.io
MIT License
147 stars 61 forks source link

concat base IRI with substring of id property #105

Closed smierz closed 3 years ago

smierz commented 3 years ago

Hello, it's only my first time using yarrrml and I'm trying to build the IRI of a subject which should consist of the base+part of the id property, but unfortunately I can't seem to get the hang of functions really.

So for example the id property could be something like: "id": "https://orcid.org/0000-0001-9924-9153" and I would like to extract only the last part consisting of all the numbers.

So far what I came up with is:

    s: 
      function: grel:array_join
      parameters:
        - [grel:p_array_a, base]
        - parameter: grel:p_array_a
          value:
            function: grel:string_find
            parameters:
              - [grel:valueParam, $(id)]
              - [grel:param_regex, "\d{4}-\d{4}-\d{4}-\d{4}"]

but Matey is not happy and gives me no output :(

pheyvaer commented 3 years ago

Hi @smierz,

Could you provide an sample of the input data and the rest of your YARRRML? That way we can easier determine where it's going wrong.

smierz commented 3 years ago

json input:

{
    "person": {
      "name": "Test User",
      "id": "https://orcid.org/0000-0005-3029-1234"
    }
}

the yarrml is supposed to take the number combination of the id-URl and use base+number combination as new URI for the subject:

base: http://example.com/
prefixes:
  foaf: http://xmlns.com/foaf/0.1/
  grel: http://users.ugent.be/~bjdmeest/function/grel.ttl#

mappings:

  person:
    sources:
      - ['data.json~jsonpath', '$.person']
    s: 
      function: grel:array_join
      parameters:
        - [grel:p_array_a, base]
        - parameter: grel:p_array_a
          value:
            function: grel:string_find
            parameters:
              - [grel:valueParam, $(id)]
              - [grel:param_regex, "\d{4}-\d{4}-\d{4}-\d{4}"]
    po:
      - [a, foaf:Person]
pheyvaer commented 3 years ago

Hi @smierz ,

I see that you use the function grel:string_find, but that one is not yet implemented in the RMLMapper, which is used under the hood by Matey. You can have a look this page, which contains all currently available functions. Maybe you can use any of these to achieve what you want?

no-response[bot] commented 3 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.