kg-construct / rml-questions

The place for your RML questions and examples
2 stars 0 forks source link

Relative URLs of templates #23

Closed bblfish closed 2 years ago

bblfish commented 2 years ago

I have the following template

@base <http://example.org/> .  ## see issue https://github.com/RMLio/rmlmapper-java/issues/178
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix sosa: <http://www.w3.org/ns/sosa/> .
<#allDataMap>
    rml:logicalSource [
      rml:referenceFormulation ql:CSV ;
      rml:source  "data/all_data.csv"
    ] .

# not sure why I can't use a relative url here with rmlmapper
<#allDataMap> a rr:TriplesMap;
    rr:subjectMap [
        rdfs:seeAlso <https://github.com/RMLio/rmlmapper-java/issues/179>;
        rr:template "all#m_{ }";
        rr:class sosa:Observation;
    ] .

For data such as

 ,timestamp,data_source,index,modality,count,locationrange,speed,measurement_type,refRoadSegment
480,2021-09-05 22:00:00+00:00,cropland,schoolstraat,,3553.3899,"POLYGON ((4.472119613057031 51.02073678178503, 4.479745501704901 51.02015981281664, 4.481188984378538 51.01915526700179, 4.481395603399528 51.01491440180675, 4.482127375233162 51.0126494593307, 4.478332541440828 51.00987874451822, 4.471306586318185 51.00931972134209, 4.469785136941451 51.01107192511326, 4.461581573935097 51.01126112376583, 4.460354540525603 51.01217411043578, 4.46032051949892 51.01700860830363, 4.468571374013287 51.01807235138044, 4.472119613057031 51.02073678178503))",,,
481,2021-09-05 22:15:00+00:00,cropland,schoolstraat,,2760.2395,"POLYGON ((4.472119613057031 51.02073678178503, 4.479745501704901 51.02015981281664, 4.481188984378538 51.01915526700179, 4.481395603399528 51.01491440180675, 4.482127375233162 51.0126494593307, 4.478332541440828 51.00987874451822, 4.471306586318185 51.00931972134209, 4.469785136941451 51.01107192511326, 4.461581573935097 51.01126112376583, 4.460354540525603 51.01217411043578, 4.46032051949892 51.01700860830363, 4.468571374013287 51.01807235138044, 4.472119613057031 51.02073678178503))",,,

The need for a @base is a bug in https://github.com/RMLio/rmlmapper-java/issues/178 I believe. More tricky is the behavior of rr:template.

Currently rmlmapper-java transforms that to full urls using the base of the mapping document in which it appears. But that is rarely going to be what one wants: one does not want to place the potentially huge instance data in the file in which the mapped data goes: especially when mapping data from many different files.

So there needs to be a way to spacify the base for the template in the RDF document, or if not set, it should be left as a relative URL in the generated document.

For the moment the output is

$ rmlmapper -b http://example.org/ -m all_data.csv-rml.ttl -s turtle | head -n 40
@prefix crop: <https://data.imec.be/cityflows/cro#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix sosa: <http://www.w3.org/ns/sosa/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/all#m_0> a sosa:Observation .

<http://example.org/all#m_1> a sosa:Observation .

<http://example.org/all#m_10> a sosa:Observation .

<http://example.org/all#m_100> a sosa:Observation .
dachafra commented 2 years ago

We are working on this and we will solve it in the following iterations: https://github.com/kg-construct/rml-fno-spec/issues/30 In any case, there are other engines (such as R2RML-f) that take as input the base IRI as a parameter in the execution. I don't see any issue here, and this repo is not though for issues but for discussions/questions.

bblfish commented 2 years ago

We are working on this and we will solve it in the following iterations: kg-construct/rml-fno-spec#30

great. thanks for the pointer.

In any case, there are other engines (such as R2RML-f) that take as input the base IRI as a parameter in the execution.

Actually rmlmapper-java does too. That is what the -b flag is for. The problem it seems is that it also requires. Mhhh. I see the -b flag is for the base URL of the template URLS....

rmlmapper -b http://dodo.org/ -m all_data.csv-rml.ttl -s turtle | head -n 40
[...]

<http://dodo.org/all#m_0> a sosa:Observation .

<http://dodo.org/all#m_1> a sosa:Observation .

<http://dodo.org/all#m_10> a sosa:Observation .

Ok, that was not clear to me. I'll check their documentation. I guess it's a bit new to me to have two different relative URLs to deal with. Perhaps they should call -b, --template-url instead...

I don't see any issue here, and this repo is not though for issues but for discussions/questions.

Btw. I found it difficult to find the right place to report questions on the spec itself.

I suggest that the spec itself ( https://rml.io/specs/rml/ ) point to the github repo where it is being developed, and that in the front README of that repository, the various entry points for discussion are linked to.

dachafra commented 2 years ago

Ok, that was not clear to me. I'll check their documentation. I guess it's a bit new to me to have two different relative URLs to deal with. Perhaps they should call -b, --template-url instead...

This is an implementation-related issue, so nothing to do here ;-)

Btw. I found it difficult to find the right place to report questions on the spec itself.

I suggest that the spec itself ( https://rml.io/specs/rml/ ) point to the github repo where it is being developed, and that in the front README of that repository, the various entry points for discussion are linked to.

Please move this suggestion to the discussions section. Although it's something that we are currently doing, see for example the RML-star spec: https://w3id.org/kg-construct/rml-star and https://github.com/kg-construct/rml-star-spec