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
146 stars 61 forks source link

Issue with grel:string_substring #151

Closed christinaspachiou closed 2 years ago

christinaspachiou commented 2 years ago

I'm iterating a csv and I'm trying to get the 3 first letters of each country , turn them into lowerCase and apply the output in a URI template. So far I have succeded getting the 3 letters but I cannot apply the result in a template, instead I get the 3 letters code. This is what I've tried

rr:predicateObjectMap [
    rr:predicate example:country;
    rr:objectMap [
        fnml:functionValue [
            rr:predicateObjectMap [
               rr:predicate fno:executes ;
               rr:objectMap [ rr:constant grel:string_substring ]
               ] ;

            rr:predicateObjectMap [
             rr:predicate grel:valueParameter ;
             rr:objectMap [ rml:reference "Country of origin" ]
             ] ;

            rr:predicateObjectMap [
             rr:predicate grel:param_int_i_from ;
             rr:objectMap [ rr:constant "0" ]
             ] ;

            rr:predicateObjectMap [
             rr:predicate grel:param_int_i_opt_to ;
             rr:objectMap [ rr:constant "3" ]
             ] ;

            rr:predicateObjectMap [
             rr:predicate grel:stringOut ;
             rr:objectMap [
             rr:template "https://example.com/origin#{Country of origin}"
             ]
          ];
        ]
     ]
];

Is it possible to get this triple

<http://example.com/1> <http://example.com/country> <http://example.com/origin#fra>

instead of

<http://example.com/1> <http://example.com/country> "Fra";

bjdmeest commented 2 years ago

Templates don't work out of the box with functions, you'll need to 'recreate' the template functionality by nesting this result into a grel:array_join function (see here for an example on nesting). Then, you'll probably need to add add rr:termType rr:IRI to the objectmap to make sure the array_join result is actually outputted as an IRI and not a a string :). Let us know if this doesn't work!

no-response[bot] commented 2 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.