Skip to content

Commit 975dd18

Browse files
committed
Fixed minor issues
1 parent c557b7b commit 975dd18

File tree

6 files changed

+110
-110
lines changed

6 files changed

+110
-110
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ You can easily customize your own configurations from the set of features that S
8484

8585
## Version
8686
```
87-
4.7.5.12
87+
4.7.5.12.1
8888
```
8989

9090
## RML-Test Cases

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.7.5.12
1+
4.7.5.12.1

rdfizer/rdfizer/__init__.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ def mapping_parser(mapping_file):
20282028
OPTIONAL {
20292029
?_predicate_object_map rml:objectMap ?_object_map .
20302030
?_object_map rml:constant ?object_constant .
2031-
OPTIONAL {?language_map rml:logicalTarget ?obj_output .
2031+
OPTIONAL {?object_map rml:logicalTarget ?obj_output .
20322032
?obj_output rml:target ?obj_dump.
20332033
?obj_dump rml:path ?object_dump.
20342034
OPTIONAL {?obj_output rml:serialization ?object_serialization.}
@@ -2037,18 +2037,18 @@ def mapping_parser(mapping_file):
20372037
OPTIONAL {?_object_map rml:languageMap ?language_map.
20382038
OPTIONAL {?language_map rml:reference ?language_value.}
20392039
OPTIONAL {?language_map rml:constant ?language.}
2040-
OPTIONAL {?language_map rml:logicalTarget ?obj_output .
2041-
?obj_output rml:target ?lan_dump.
2040+
OPTIONAL {?language_map rml:logicalTarget ?lan_obj_output .
2041+
?lan_obj_output rml:target ?lan_dump.
20422042
?lan_dump rml:path ?language_dump.
20432043
OPTIONAL {?obj_output rml:serialization ?object_serialization.}
20442044
OPTIONAL {?obj_output rml:encoding ?object_encoding.} }
20452045
}
20462046
OPTIONAL {?_object_map rml:datatypeMap ?datatype_map.
20472047
OPTIONAL {?datatype_map rml:template ?datatype_value.}
20482048
OPTIONAL {?datatype_map rml:constant ?datatype.}
2049-
OPTIONAL {?datatype_map rml:logicalTarget ?obj_output .
2050-
?obj_output rml:target ?dump.
2051-
?dump rml:path ?datatype_dump.
2049+
OPTIONAL {?datatype_map rml:logicalTarget ?dan_obj_output .
2050+
?dan_obj_output rml:target ?data_dump.
2051+
?data_dump rml:path ?datatype_dump.
20522052
OPTIONAL {?obj_output rml:serialization ?object_serialization.}
20532053
OPTIONAL {?obj_output rml:encoding ?object_encoding.} }
20542054
}
@@ -2079,20 +2079,20 @@ def mapping_parser(mapping_file):
20792079
OPTIONAL {?_object_map rml:languageMap ?language_map.
20802080
OPTIONAL {?language_map rml:reference ?language_value.}
20812081
OPTIONAL {?language_map rml:constant ?language.}
2082-
OPTIONAL {?language_map rml:logicalTarget ?output .
2083-
?object_output rml:target ?dump.
2084-
?dump rml:path ?language_dump.
2085-
OPTIONAL {?object_output rml:serialization ?object_serialization.}
2086-
OPTIONAL {?object_output rml:encoding ?object_encoding.} }
2082+
OPTIONAL {?language_map rml:logicalTarget ?language_object_output .
2083+
?language_object_output rml:target ?lan_dump.
2084+
?lan_dump rml:path ?language_dump.
2085+
OPTIONAL {?language_object_output rml:serialization ?object_serialization.}
2086+
OPTIONAL {?language_object_output rml:encoding ?object_encoding.} }
20872087
}
20882088
OPTIONAL {?_object_map rml:datatypeMap ?datatype_map.
20892089
OPTIONAL {?datatype_map rml:template ?datatype_value.}
20902090
OPTIONAL {?datatype_map rml:constant ?object_datatype.}
2091-
OPTIONAL {?datatype_map rml:logicalTarget ?output .
2092-
?object_output rml:target ?dump.
2091+
OPTIONAL {?datatype_map rml:logicalTarget ?data_object_output .
2092+
?data_object_output rml:target ?dump.
20932093
?dump rml:path ?datatype_dump.
2094-
OPTIONAL {?object_output rml:serialization ?object_serialization.}
2095-
OPTIONAL {?object_output rml:encoding ?object_encoding.} }
2094+
OPTIONAL {?data_object_output rml:serialization ?object_serialization.}
2095+
OPTIONAL {?data_object_output rml:encoding ?object_encoding.} }
20962096
}
20972097
OPTIONAL {?_object_map rml:termType ?term .}
20982098
OPTIONAL {
@@ -2991,12 +2991,12 @@ def mapping_parser(mapping_file):
29912991

29922992
if new_formulation == "yes":
29932993
output_file = ""
2994-
if result_predicate_object_map.object_dump != None:
2995-
output_file = result_predicate_object_map.object_dump[7:] if result_predicate_object_map.object_dump[:7] == "file://" else result_predicate_object_map.object_dump
2994+
if result_predicate_object_map.datatype_dump != None:
2995+
output_file = result_predicate_object_map.datatype_dump[7:] if result_predicate_object_map.datatype_dump[:7] == "file://" else result_predicate_object_map.datatype_dump
29962996
if result_predicate_object_map.object_serialization != None:
29972997
if output_file not in dump_serialization:
29982998
if result_predicate_object_map.object_encoding != None:
2999-
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization) + "_" + str(result_predicate_object_map.object_encoding)
2999+
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization)+ "_" + str(result_predicate_object_map.object_encoding)
30003000
else:
30013001
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization)
30023002
elif result_predicate_object_map.language_dump != None:
@@ -3007,12 +3007,12 @@ def mapping_parser(mapping_file):
30073007
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization)+ "_" + str(result_predicate_object_map.object_encoding)
30083008
else:
30093009
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization)
3010-
elif result_predicate_object_map.datatype_dump != None:
3011-
output_file = result_predicate_object_map.datatype_dump[7:] if result_predicate_object_map.datatype_dump[:7] == "file://" else result_predicate_object_map.datatype_dump
3010+
elif result_predicate_object_map.object_dump != None:
3011+
output_file = result_predicate_object_map.object_dump[7:] if result_predicate_object_map.object_dump[:7] == "file://" else result_predicate_object_map.object_dump
30123012
if result_predicate_object_map.object_serialization != None:
30133013
if output_file not in dump_serialization:
30143014
if result_predicate_object_map.object_encoding != None:
3015-
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization)+ "_" + str(result_predicate_object_map.object_encoding)
3015+
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization) + "_" + str(result_predicate_object_map.object_encoding)
30163016
else:
30173017
dump_serialization[output_file] = str(result_predicate_object_map.object_serialization)
30183018
if output_file != "":
@@ -3024,9 +3024,9 @@ def mapping_parser(mapping_file):
30243024
logical_dump[str(result_triples_map.triples_map_id)] = {output_file: [object_map.value + "_" + result_predicate_object_map.language_value]}
30253025
elif result_predicate_object_map.datatype_dump != None:
30263026
if result_predicate_object_map.object_datatype != None:
3027-
logical_dump[str(result_triples_map.triples_map_id)] = {output_file:str(object_map.value + "_" + result_predicate_object_map.object_datatype)}
3027+
logical_dump[str(result_triples_map.triples_map_id)] = {output_file:[str(object_map.value + "_" + result_predicate_object_map.object_datatype)]}
30283028
elif result_predicate_object_map.datatype_value != None:
3029-
logical_dump[str(result_triples_map.triples_map_id)] = {output_file:str(object_map.value + "_" + result_predicate_object_map.datatype_value)}
3029+
logical_dump[str(result_triples_map.triples_map_id)] = {output_file:[str(object_map.value + "_" + result_predicate_object_map.datatype_value)]}
30303030
else:
30313031
logical_dump[str(result_triples_map.triples_map_id)] = {output_file:[object_map.value]}
30323032
else:
@@ -3107,7 +3107,6 @@ def mapping_parser(mapping_file):
31073107
predicate_object_maps_list += [
31083108
tm.PredicateObjectMap(join_predicate[jp]["predicate"], object_map, predicate_object_graph)]
31093109
predicate_object_maps_list = remove_duplicate_po(predicate_object_maps_list)
3110-
print(result_triples_map.url_source)
31113110
if result_triples_map.url_source is not None:
31123111
if result_triples_map.delimiter is not None:
31133112
url_source = str(result_triples_map.url_source)[7:] if str(result_triples_map.url_source)[:7] == "file://" else str(result_triples_map.url_source)
@@ -4854,7 +4853,7 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
48544853
if object_list:
48554854
i = 0
48564855
while i < len(object_list):
4857-
object_list[i] = "\"" + object_list[i] + "\""
4856+
object_list[i] = "\"" + str(object_list[i]) + "\""
48584857
if "\\" in object_list[i][1:-1]:
48594858
object_list[i] = "\"" + object_list[i][1:-1].replace("\\", "\\\\") + "\""
48604859
if "'" in object_list[i][1:-1]:
@@ -6006,7 +6005,7 @@ def semantify_file(triples_map, triples_map_list, delimiter, output_file_descrip
60066005
if predicate_object_map.object_map.datatype == None:
60076006
if predicate_object_map.object_map.value == "#" or "#" in predicate_object_map.object_map.value:
60086007
object = "\"" + object[1:-1] + "\"" + "^^<http://www.w3.org/2001/XMLSchema#integer>"
6009-
elif triples_map.reference_formulation != "RMLView":
6008+
elif "RMLView" not in triples_map.reference_formulation:
60106009
object = "\"" + object[1:-1] + "\""
60116010
elif is_convertible_to_int(object[1:-1]):
60126011
object = "\"" + object[1:-1] + "\"" + "^^<http://www.w3.org/2001/XMLSchema#integer>"

rdfizer/rdfizer/cc_functions.py

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -439,60 +439,61 @@ def gather_triples_generation(data, subject_predicate, base, gather_map, output_
439439
if graph != "":
440440
triple = triple[:-2] + graph + " .\n"
441441
output_file_descriptor.write(triple)
442-
i = 0
443-
for value in element_values:
444-
if len(element_values) == 1:
445-
if "_:" not in value and "http" not in value:
446-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + value + "\" .\n"
447-
else:
448-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + value + " .\n"
449-
if graph != "":
450-
triple = triple[:-2] + graph + " .\n"
451-
output_file_descriptor.write(triple)
452-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>.\n"
453-
if graph != "":
454-
triple = triple[:-2] + graph + " .\n"
455-
output_file_descriptor.write(triple)
456-
gather_blank += 1
457-
elif value == element_values[0] and i == 0:
458-
if "_:" not in value and "http" not in value:
459-
triple = object + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + value + "\" .\n"
460-
else:
461-
triple = object + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + value + " .\n"
462-
if graph != "":
463-
triple = triple[:-2] + graph + " .\n"
464-
output_file_descriptor.write(triple)
465-
triple = object + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> " + "_:" + blank_id + str(gather_blank) + " .\n"
466-
if graph != "":
467-
triple = triple[:-2] + graph + " .\n"
468-
output_file_descriptor.write(triple)
469-
elif value == element_values[len(element_values)-1] and i == len(element_values)-1:
470-
if "_:" not in value and "http" not in value:
471-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + value + "\" .\n"
472-
else:
473-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + value + " .\n"
474-
if graph != "":
475-
triple = triple[:-2] + graph + " .\n"
476-
output_file_descriptor.write(triple)
477-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>.\n"
478-
if graph != "":
479-
triple = triple[:-2] + graph + " .\n"
480-
output_file_descriptor.write(triple)
481-
gather_blank += 1
442+
if len(element_values) == 1:
443+
if "_:" not in element_values[0] and "http" not in element_values[0]:
444+
triple = "_:" + blank_id + str(gather_blank - 1) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + element_values[0] + "\" .\n"
482445
else:
483-
if "_:" not in value and "http" not in value:
484-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + value + "\" .\n"
446+
triple = "_:" + blank_id + str(gather_blank - 1) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + element_values[0] + " .\n"
447+
if graph != "":
448+
triple = triple[:-2] + graph + " .\n"
449+
output_file_descriptor.write(triple)
450+
triple = "_:" + blank_id + str(gather_blank - 1) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>.\n"
451+
if graph != "":
452+
triple = triple[:-2] + graph + " .\n"
453+
output_file_descriptor.write(triple)
454+
gather_blank += 1
455+
else:
456+
i = 0
457+
for value in element_values:
458+
if value == element_values[0] and i == 0:
459+
if "_:" not in value and "http" not in value:
460+
triple = object + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + value + "\" .\n"
461+
else:
462+
triple = object + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + value + " .\n"
463+
if graph != "":
464+
triple = triple[:-2] + graph + " .\n"
465+
output_file_descriptor.write(triple)
466+
triple = object + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> " + "_:" + blank_id + str(gather_blank) + " .\n"
467+
if graph != "":
468+
triple = triple[:-2] + graph + " .\n"
469+
output_file_descriptor.write(triple)
470+
elif value == element_values[len(element_values)-1] and i == len(element_values)-1:
471+
if "_:" not in value and "http" not in value:
472+
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + value + "\" .\n"
473+
else:
474+
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + value + " .\n"
475+
if graph != "":
476+
triple = triple[:-2] + graph + " .\n"
477+
output_file_descriptor.write(triple)
478+
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>.\n"
479+
if graph != "":
480+
triple = triple[:-2] + graph + " .\n"
481+
output_file_descriptor.write(triple)
482+
gather_blank += 1
485483
else:
486-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + value + " .\n"
487-
if graph != "":
488-
triple = triple[:-2] + graph + " .\n"
489-
output_file_descriptor.write(triple)
490-
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> " + "_:" + blank_id + str(gather_blank+1) + " .\n"
491-
if graph != "":
492-
triple = triple[:-2] + graph + " .\n"
493-
output_file_descriptor.write(triple)
494-
gather_blank += 1
495-
i += 1
484+
if "_:" not in value and "http" not in value:
485+
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> \"" + value + "\" .\n"
486+
else:
487+
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> " + value + " .\n"
488+
if graph != "":
489+
triple = triple[:-2] + graph + " .\n"
490+
output_file_descriptor.write(triple)
491+
triple = "_:" + blank_id + str(gather_blank) + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> " + "_:" + blank_id + str(gather_blank+1) + " .\n"
492+
if graph != "":
493+
triple = triple[:-2] + graph + " .\n"
494+
output_file_descriptor.write(triple)
495+
gather_blank += 1
496+
i += 1
496497
else:
497498
list_right = string_substitution_json(gather_map.gather_list[0]["value"],".+", data, "object", "yes", iterator)
498499
list_left = string_substitution_json(gather_map.gather_list[1]["value"],".+", data, "object", "yes", iterator)

rdfizer/rdfizer/functions.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,9 @@ def is_current_output_valid(triples_map_id,po_map,current_output,output_list):
124124
else:
125125
if triples_map_id in output_list:
126126
if current_output in output_list[triples_map_id]:
127+
#print(output_list[triples_map_id][current_output])
127128
if output_list[triples_map_id][current_output] == "subject":
128129
return True
129-
elif po_map.predicate_map.value in output_list[triples_map_id][current_output]:
130-
return True
131-
elif po_map.object_map.value in output_list[triples_map_id][current_output]:
132-
return True
133130
elif po_map.object_map.datatype != None:
134131
if po_map.object_map.value + "_" + po_map.object_map.datatype in output_list[triples_map_id][current_output]:
135132
return True
@@ -150,6 +147,10 @@ def is_current_output_valid(triples_map_id,po_map,current_output,output_list):
150147
return True
151148
else:
152149
return False
150+
elif po_map.predicate_map.value in output_list[triples_map_id][current_output]:
151+
return True
152+
elif po_map.object_map.value in output_list[triples_map_id][current_output]:
153+
return True
153154
else:
154155
return False
155156
else:

0 commit comments

Comments
 (0)