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

UnboundLocalError: local variable 'triples_map' referenced before assignment #115

Closed samuan2022 closed 3 months ago

samuan2022 commented 3 months ago

Describe the bug I'm trying to map from CSV to RDF. When launching the Rdfizer Software I get the following error: UnboundLocalError: local variable 'triples_map' referenced before assignment

To Reproduce

RML mapping document:

@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 transit: http://vocab.org/transit/terms/. @prefix xsd: http://www.w3.org/2001/XMLSchema#. @prefix wgs84_pos: http://www.w3.org/2003/01/geo/wgs84_pos#. @base http://example.com/ns.

<#TriplesMap> a rr:TriplesMap;

rml:logicalSource [ rml:source "datosbase.csv" ; rml:referenceFormulation ql:CSV ];

rr:subjectMap [ rr:template "http://airport.example.com/{id}"; rr:class transit:Stop ];

rr:predicateObjectMap [ rr:predicate transit:route; rr:objectMap [ rml:reference "stop"; rr:datatype xsd:int ] ];

rr:predicateObjectMap [ rr:predicate wgs84_pos:lat; rr:objectMap [ rml:reference "latitude" ] ];

rr:predicateObjectMap [ rr:predicate wgs84_pos:long; rr:objectMap [ rml:reference "longitude" ] ].

CSV Document:

id,stop,latitude,longitude 6523,25,50.901389,4.484444

Configuration.ini:

[default] main_directory: ./dataset

[datasets] number_of_datasets: 1 output_folder: ./graph all_in_one_file: no remove_duplicate: yes enrichment: no name: datosbase ordered: no output_format: turtle

[dataset1] name: salida mapping: ./reglas/reglas.ttl

Expected behavior

Data in RML format

Desktop (please complete the following information):

eiglesias34 commented 3 months ago

Hello @samuan2022,

Thank you for using SDM-RDFizer. I ran the mapping you gave me and had to fix the prefixes since they were not in the correct format for RDF. These are the corrected prefixes:

@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 transit: <http://vocab.org/transit/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@base <http://example.com/ns> .

Afterward, I was able to find and fix the problem. Here is the result after the fix:

<http://airport.example.com/6523> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vocab.org/transit/terms/Stop>.
<http://airport.example.com/6523> <http://vocab.org/transit/terms/route> "25"^^<http://www.w3.org/2001/XMLSchema#int>.
<http://airport.example.com/6523> <http://www.w3.org/2003/01/geo/wgs84_pos#lat> "50.901389".
<http://airport.example.com/6523> <http://www.w3.org/2003/01/geo/wgs84_pos#long> "4.484444".

Please test it out to ensure the problem was fixed on your side.

Sincerely, Enrique Igleisas

samuan2022 commented 3 months ago

Hello Enrique

I fixed the prefixes and I update the software to version v4.7.4.5, but the problem continues.

This is the responde in the console:

python3 -m rdfizer -c ./configuracion.ini

Semantifying salida... Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/antonio/.local/lib/python3.8/site-packages/rdfizer/main.py", line 49, in main() File "/home/antonio/.local/lib/python3.8/site-packages/rdfizer/main.py", line 45, in main semantify(config_path) File "/home/antonio/.local/lib/python3.8/site-packages/rdfizer/init.py", line 8786, in semantify if "NonAssertedTriplesMap" not in sorted_sources[source_type][source][triples_map].mappings_type: UnboundLocalError: local variable 'triples_map' referenced before assignment

eiglesias34 commented 3 months ago

Hello again,

I was able to find the problem and fix it. I made sure to test out all possible combinations in the configuration file, and everything worked. Please test it out.

SIncerely, Enrique Iglesias

samuan2022 commented 3 months ago

Hello

Now it works

Thank you very much

eiglesias34 commented 3 months ago

Great, I'll close the issue.