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

Lookup function doesn't use correct datatype #220

Closed MathiasVDA closed 9 months ago

MathiasVDA commented 9 months ago

Hello,

I have this csv file: https://gitlab.com/mathias.vanden.auweele/infrabel-opendata-to-rdf/-/blob/main/src/operational-points/map-opType.csv?ref_type=heads

And this rml file: https://gitlab.com/mathias.vanden.auweele/infrabel-opendata-to-rdf/-/blob/main/src/operational-points/map.rml.ttl?ref_type=heads

Running with this json file: https://gitlab.com/mathias.vanden.auweele/infrabel-opendata-to-rdf/-/blob/main/src/operational-points/operationele-punten-van-het-netwerk.json?ref_type=heads

A partial result is :

<https://data.infrabel.be/data/OperationalPoint/2000> a era:OperationalPoint;
  era:opName "FOREST-M"@fr, "VORST-M"@nl;
  era:opType "http://data.europa.eu/949/concepts/op-types/rinf/10"^^rr:IRI;
  era:tafTAPCode "BE02000";
  gsp:hasGeometry <https://data.infrabel.be/data/Geometry/OperationalPoint/2000>;
  owl:sameAs era:BE_FOVM;
  prov:wasGeneratedBy <https://data.infrabel.be/mapping/opendata/operationele-punten-van-het-netwerk/1> .

I expected to see era:opType <http://data.europa.eu/949/concepts/op-types/rinf/10>;

I tried multiple version where I don't define a datatype or put <...> in the csv file. But it all translates to string type.

DylanVanAssche commented 9 months ago

Hi,

rr:dataType is for indicating the type of data of an RDF Literal such as XSD integer, XSD date, etc. You're looking for rr:termType which indicates if the term is an IRI, Literal or Blanknode. So, this should work:

rr:predicateObjectMap [
      rr:predicate era:opType;
      rr:objectMap [
        fnml:functionValue [
          rr:predicateObjectMap [
            rr:predicate fno:executes;
            rr:objectMap [ rr:constant idlab-fn:lookup ]
          ];
          rr:predicateObjectMap [
            rr:predicate idlab-fn:str;
            rr:objectMap [ rml:reference "class_en"]
          ];
          rr:predicateObjectMap [
            rr:predicate idlab-fn:inputFile;
            rr:objectMap [ rr:constant "map-opType.csv"]
          ];
          rr:predicateObjectMap [
            rr:predicate idlab-fn:fromColumn;
            rr:objectMap [ rr:constant 0; rr:datatype xsd:integer]
          ];
          rr:predicateObjectMap [
            rr:predicate idlab-fn:toColumn;
            rr:objectMap [ rr:constant 1; rr:datatype xsd:integer]
          ]
        ]; rr:termType rr:IRI
      ]].
MathiasVDA commented 9 months ago

You are right...

I've spent far to much time looking for a workarround (writing a script to convert the string into URI) and far to less looking at my own mistakes... Feeling a bit stupid now

Thanks!

DylanVanAssche commented 9 months ago

No worries :) Happy to help!