SDM-TIB / SDM-RDFizer

An Efficient RML-Compliant Engine for Knowledge Graph Construction
https://doi.org/10.5281/zenodo.3872103
Apache License 2.0
107 stars 25 forks source link

SDM-RDFizer can't support Array of Array Test-case in json #110

Closed bilalbenma closed 7 months ago

bilalbenma commented 7 months ago

Describe the bug I can't share the real use case, but I found the same one with only different data. Suppose that we have the following json file data:

{
    "status": 0,
    "body": {
        "updatetime": 1528904042,
        "timezone": "Europe\/Rome",
        "measuregrps": [{
                "grpid": 1154218424,
                "attrib": 2,
                "date": 1528902698,
                "category": 1,
                "brand": 1,
                "modified": 1528902700,
                "deviceid": null,
                "measures": [{
                    "value": 7000,
                    "type": 11,
                    "unit": -2,
                    "algo": 0,
                    "fw": 0,
                    "fm": 131
                }]
            },
            {
                "grpid": 1154218987,
                "attrib": 2,
                "date": 1528902745,
                "category": 1,
                "brand": 1,
                "modified": 1528902747,
                "deviceid": null,
                "measures": [{
                    "value": 7200,
                    "type": 11,
                    "unit": -2,
                    "algo": 0,
                    "fw": 0,
                    "fm": 131
                }]
            }
        ]
    }
}

I'm trying to map this JSON file to RDF using SDM-RDFizer, but I can't get the values ​​that are inside the measures array. Therefore, I decided to use another engine to see if the problem in my mapping file (RocketRML), but my mapping file works well with RocketRML. Please to test in your own, you can use this example

To Reproduce

Please to reproduce the same behavior, you can follow this link

Desktop (please complete the following information):

eiglesias34 commented 7 months ago

Hello @bilalbenma,

First of all, thank you for using SDM-RDFizer. I checked the example you sent and there a couple errors with the JSONPaths. Here is the corrected version:

@base <http://example.org> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix fo: <http://purl.org/ifo/#> .

<#FitbitRestingHeartRate>
    a rr:TriplesMap;
    rml:logicalSource [
        rml:source "./test.json";
        rml:referenceFormulation ql:JSONPath;
        rml:iterator "$.body.measuregrps[*]";
    ];

    rr:subjectMap [
        rr:template "http://ifo.com/{grpid}";
        rr:class fo:HeartRate;
    ];

    rr:predicateObjectMap [
        rr:predicate fo:hasTemporalRelationshipToPhysicalActivity;
        rr:objectMap [
            rr:constant fo:AtRest;
        ];
    ];

    rr:predicateObjectMap [
        rr:predicate fo:hasMeasure;
        rr:objectMap [ 
            rr:parentTriplesMap <#MeasureHeartRate>;
        ];
    ].

<#MeasureHeartRate>
    a rr:TriplesMap;
    rml:logicalSource [
        rml:source "./test.json";
        rml:referenceFormulation ql:JSONPath;
        rml:iterator "$.body.measuregrps[*]";
    ];

    rr:subjectMap [
        rr:template "http://ifo.com/{grpid}/{date}/{measures[*].type}"; 
        rr:class fo:Measure;
    ];

    rr:predicateObjectMap [
        rr:predicate fo:hasNumericalValue;
        rr:objectMap [
            rml:reference "measures[*].value";
            rr:datatype xsd:float;
        ];
    ];

    rr:predicateObjectMap [
        rr:predicate fo:hasDescriptiveStatistic;
        rr:objectMap [
            rr:constant fo:average;
        ];
    ];

    rr:predicateObjectMap [
        rr:predicate fo:hasUnit;
        rr:objectMap [
            rr:constant fo:bpm;
        ];
    ].

You can use this tool to check your JSONPath https://jsonpath.com/.

As is, SDM-RDFizer is capable of semantifying the <#FitbitRestingHeartRate> but not <#MeasureHeartRate>. I'm currently trying fix that problem.

Sincerely, Enrique Iglesias

bilalbenma commented 7 months ago

Thank you @eiglesias34 Sorry for providing a wrong content, but this is just an example. The real file that I am working on contains the right data and structure, I only provide this because it really explains what I want to achieve. Sincerely Bilalox

eiglesias34 commented 7 months ago

No problem. I'll try to have the problem fixed. If not by today, tomorrow should be done.

eiglesias34 commented 7 months ago

Hello @bilalbenma

I could fix the problem and replicate the behavior as in your example. Please test it out and tell me everything is good on your side.

Sincerely, Enrique

bilalbenma commented 7 months ago

Hello @eiglesias34, Thank you, I'll test it then let you know if the issue is solved . Sincerely, Bilal

eiglesias34 commented 7 months ago

Hello,

Since there hasn't been activity in over a week, I will assume that the issue has been solved and close it. In case the issue still persists please reopen the issue.

Sincerely, Enrique