Blank Nodes in YARRRML trigger TypeError: argument of type 'NoneType' is not iterable
Stiksels opened this issue · comments
Describe the bug
Following the YARRRML subjects spec, I use blank nodes with s: null
. This is not supported by yatter
To Reproduce
Steps to reproduce the behavior (and resources):
with the files below, run the yatter library python3 -m yatter -i yarrrml/yatter-test.yml -o rml/yatter-test_rml.ttl
yatter-test.yml
# Define namespace prefixes for commonly used ontologies
prefixes:
exp: "http://example.org/participant/"
ex: "http://example.org/#"
rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
rdfs: "http://www.w3.org/2000/01/rdf-schema#"
xsd: "http://www.w3.org/2001/XMLSchema#"
dcterms: "http://purl.org/dc/terms/"
locn: "http://www.w3.org/ns/locn#"
grel: "http://users.ugent.be/~bjdmeest/function/grel.ttl#"
skos: "http://www.w3.org/2004/02/skos/core#"
wegwijs: "https://data.vlaanderen.be/id/organisatie/"
adms: "http://www.w3.org/ns/adms#"
# Define the mapping rules
mappings:
# Mapping for 'participants' data
participants:
# Define sources to extract data from JSON
sources:
- ['yatter-test.csv~csv']
# Define subject mapping
s: exp:$(participantUuid)
# Define predicate-object mappings
po:
- [a, ex:Participant]
- [dcterms:created, $(created), xsd:dateTime]
- [dcterms:modified, $(modified), xsd:dateTime]
- p: adms:identifier
o:
type: blank
mapping: identificator
condition:
function: equal
parameters:
- [str1, $(participantUuid), s]
- [str2, $(participantUuid), o]
# Mapping for 'identificator' data
identificator:
sources:
- ['yatter-test.csv~csv']
# Define subject as null, indicating a blank node will be generated
s: null
# Define predicate-object mappings
po:
- [a, adms:Identifier]
- [skos:notation, exp:$(participantUuid), xsd:anyURI]
- [dcterms:creator, wegwijs:OVO026559~iri]
yatter-test.csv
participantUuid,created,modified,birthYear,placeHolderStatSect
493b78b8-efa7-45b8-af5f-ca08ec90179e,2023-06-06T15:17:32.954+0000,2023-06-06T15:19:14.358+0000,1964,Wilrijk
ea9ba26f-e283-42a2-b57a-55ea3f5571ff,2022-12-28T14:46:03.682+0000,2022-12-28T14:48:23.17+0000,1957,Marcinelle
e0f5d6b0-984d-4192-b00f-8a07d2189712,2023-06-06T17:36:44.39+0000,2023-06-06T17:36:44.396+0000,1963,Zingem
20a15803-ca0e-42f9-9abe-93dc5d593a31,2022-12-16T11:39:39.481+0000,2022-12-16T11:43:58.073+0000,1951,Gent
Current behavior
TypeError
stacktrace
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/yatter/__main__.py", line 68, in <module>
mapping_content = translate(mapping_data, mapping_format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/yatter/__init__.py", line 15, in translate
list_initial_sources = get_initial_sources(yarrrml_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/yatter/source.py", line 9, in get_initial_sources
if YARRRML_SOURCES in data:
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
Expected behavior
an RML file is produced like the one by YARRRML's matey:
output.rml.ttl.txt
output turtle
output (1).txt
Hi @Stiksels,
As there is no consensus in the W3C CG about supporting BN without data references, I would not consider implementing this feature for now. However, I can provide support for BN with data reference on the subject. As there is no example in the spec, I will do it similarly as it's indicated for ObjectMaps, as both (OM and SM) are term maps.
It will be something like:
identificator:
sources:
- ['yatter-test.csv~csv']
# Define subject as null, indicating a blank node will be generated
s:
value: $(participantUuid) # could be template, reference or constant
type: blank
# Define predicate-object mappings
po:
- [a, adms:Identifier]
- [skos:notation, exp:$(participantUuid), xsd:anyURI]
- [dcterms:creator, wegwijs:OVO026559~iri]
BN are now supported in subject and object, please see the test case as an example https://github.com/oeg-upm/yatter/blob/main/test/r2rml/YARRRMLTC-r2rml-0016/mapping.yml