Trouble getting Jinja "if" statements to work
something like "valueUrl": "{{gender|lower}}" works
while "valueUrl": "pato:{% if gender == 'F' %}0000383{% else %}0000384{% endif %}" does not
Reference from the docs: https://github.com/CLARIAH/COW/wiki/12.-example:-if-statement-converting-sex-variable-and-values-appropriately
When using the online cattle.datalegend.net tool, I get the expected result, but using the command line with the exact same json metadata files, the algorithm seems to skip the triples or includes incomplete URIs I don't think there is a way to increase the logging level and get a better idea of where things go awry?
I can post a complete example if this is not an obvious error/misunderstanding on my end and a test case would help.
Hi @dirkdevriendt , yes could you maybe post a few lines of the data and the relevant block of the metadata file?
Thanks @rijpma ! Love what the tool does, BTW
A simple example would be the following csv:
id_subject,family_member,relation,gender
1,2,"F","M"
2,2,"P","M"
with the following metadata:
{
"@context": [
"https://raw.githubusercontent.com/CLARIAH/COW/master/csvw.json",
{"@language": "en", "@base": "https://example.com/id/"},
{
...
"fhho": "http://www.owl-ontologies.com/Ontology1172270693.owl#",
"pato": "http://purl.obolibrary.org/obo/pato#",
"ro": "http://purl.obolibrary.org/obo/ro#",
"obi": "http://purl.obolibrary.org/obo/obi#"
}
],
"tableSchema": {
"aboutUrl": "ExampleData/subject_{id_subject}",
"primaryKey": "id_subject",
"columns": [
{
"name": "id_subject",
"titles": [ "id_subject", "study subject ID" ],
"datatype": "integer",
"@id": "https://example.com/id/test.csv/column/id_subject",
"propertyUrl": "rdf:type",
"valueUrl": "fhho:Person"
},
{
"name": "relation",
"titles": [ "relation", "relation to the main study subject" ],
"dc:description": "The family relation of the subject to the main study subject",
"datatype": "string",
"@id": "CheckSuccesfulDataset_SUBJECTUNIQUE.csv/column/relation",
"aboutUrl": "ExampleData/subject_{family_member}",
"propertyUrl": "{% if relation == 'M' %}fhho:has_natural_mother{% elif relation == 'F' %}fhho:has_natural_father{% else %}owl:sameAs{% endif %}",
"valueUrl": "ExampleData/subject_{id_subject}"
},
{
"name": "gender",
"titles": [ "gender", "lowercase gender code of the study subject" ],
"datatype": "string",
"@id": "https://example.com/id/test.csv/column/gender",
"propertyUrl": "gender",
"valueUrl": "{{gender|lower}}"
},
{
"name": "gender_PATO",
"titles": [ "gender_PATO", "PATO gender of the study subject" ],
"virtual": true,
"datatype": "string",
"@id": "https://example.com/id/test.csv/column/gender_PATO",
"propertyUrl": "ro:0000086",
"valueUrl": "pato:{% if gender == 'F' %}0000383{% else %}0000384{% endif %}"
}
]
},
...
"@id": "https://example.com/id/test.csv"
}
Which in cattle.datalegend.net yields, as expected:
(let's ignore the unprompted iisg.amsterdam references and the subject_1 fhho:has_natural_father subject_1. I don't know if that is as designed)
...
<https://example.com/id/ExampleData/subject_1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.owl-ontologies.com/Ontology1172270693.owl#Person> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
<https://example.com/id/ExampleData/subject_1> <http://purl.obolibrary.org/obo/ro#0000086> <http://purl.obolibrary.org/obo/pato#0000384> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
<https://example.com/id/ExampleData/subject_2> <https://example.com/id/gender> <https://example.com/id/m> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
<https://example.com/id/ExampleData/subject_1> <https://example.com/id/fhho:has_natural_father> <https://example.com/id/ExampleData/subject_1> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
<https://example.com/id/ExampleData/subject_2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.owl-ontologies.com/Ontology1172270693.owl#Person> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
<https://example.com/id/ExampleData/subject_2> <http://purl.obolibrary.org/obo/ro#0000086> <http://purl.obolibrary.org/obo/pato#0000384> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
<https://example.com/id/ExampleData/subject_2> <https://example.com/id/owl:sameAs> <https://example.com/id/ExampleData/subject_2> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
<https://example.com/id/ExampleData/subject_1> <https://example.com/id/gender> <https://example.com/id/m> <https://iisg.amsterdam/test/assertion/fa1ddd59/2022-11-21T13:24> .
...
While the cow_tool --processes 1 convert test.csv command yields:
(note: cow_tool --version returns 1.21)
cow_tool handles, AFAICT, the fhho:has_natural_father subject inversion correctly, but does not fill in the predicate and drops the gender_PATO rule entirely
<https://example.com/id/ExampleData/subject_1> <https://example.com/id/gender> <https://example.com/id/m> <https://example.com/id/test/assertion/aefe5ca2/2022-11-21T13:23> .
<https://example.com/id/ExampleData/subject_1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.owl-ontologies.com/Ontology1172270693.owl#Person> <https://example.com/id/test/assertion/aefe5ca2/2022-11-21T13:23> .
<https://example.com/id/ExampleData/subject_2> <https://example.com/id/> <https://example.com/id/ExampleData/subject_1> <https://example.com/id/test/assertion/aefe5ca2/2022-11-21T13:23> .
<https://example.com/id/ExampleData/subject_2> <https://example.com/id/gender> <https://example.com/id/m> <https://example.com/id/test/assertion/aefe5ca2/2022-11-21T13:23> .
<https://example.com/id/ExampleData/subject_2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.owl-ontologies.com/Ontology1172270693.owl#Person> <https://example.com/id/test/assertion/aefe5ca2/2022-11-21T13:23> .
<https://example.com/id/ExampleData/subject_2> <https://example.com/id/> <https://example.com/id/ExampleData/subject_2> <https://example.com/id/test/assertion/aefe5ca2/2022-11-21T13:23> .
...