Skip to content

Commit

Permalink
Fixed issue with constants in object map
Browse files Browse the repository at this point in the history
  • Loading branch information
eiglesias34 committed Sep 10, 2024
1 parent 647af2a commit d8dff7a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ You can easily customize your own configurations from the set of features that S

## Version
```
4.7.4.9
4.7.4.10
```

## RML-Test Cases
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.7.4.9
4.7.4.10
11 changes: 6 additions & 5 deletions rdfizer/rdfizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,7 @@ def mapping_parser(mapping_file):
result_predicate_object_map.datatype_value, "None")
predicate_object_maps_list += [
tm.PredicateObjectMap(join_predicate[jp]["predicate"], object_map, predicate_object_graph)]
predicate_object_maps_list = remove_duplicate_po(predicate_object_maps_list)
if result_triples_map.url_source is not None:
if result_triples_map.delimiter is not None:
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)
Expand Down Expand Up @@ -2608,7 +2609,7 @@ def semantify_xml(triples_map, triples_map_list, output_file_descriptor):
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -3597,7 +3598,7 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -4801,7 +4802,7 @@ def semantify_file(triples_map, triples_map_list, delimiter, output_file_descrip
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -6411,7 +6412,7 @@ def semantify_mysql(row, row_headers, triples_map, triples_map_list, output_file
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -7301,7 +7302,7 @@ def semantify_postgres(row, row_headers, triples_map, triples_map_list, output_f
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down
15 changes: 14 additions & 1 deletion rdfizer/rdfizer/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1903,4 +1903,17 @@ def condition_separetor(string):
condition_field = string.split("[")
field = condition_field[1][:len(condition_field[1])-1].split("=")[0]
value = condition_field[1][:len(condition_field[1])-1].split("=")[1]
return field, value
return field, value

def remove_duplicate_po(po_list):
unique_list = []
for po in po_list:
if unique_list == []:
unique_list.append(po)
else:
for po_unique in unique_list:
if po.predicate_map.value == po_unique.predicate_map.value and po.object_map.value == po_unique.object_map.value:
break
else:
unique_list.append(po)
return unique_list
11 changes: 6 additions & 5 deletions rdfizer/rdfizer/semantify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,7 @@ def mapping_parser(mapping_file):
result_predicate_object_map.datatype_value, "None")
predicate_object_maps_list += [
tm.PredicateObjectMap(join_predicate[jp]["predicate"], object_map, predicate_object_graph)]
predicate_object_maps_list = remove_duplicate_po(predicate_object_maps_list)
if result_triples_map.url_source is not None:
if result_triples_map.delimiter is not None:
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)
Expand Down Expand Up @@ -2608,7 +2609,7 @@ def semantify_xml(triples_map, triples_map_list, output_file_descriptor):
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -3597,7 +3598,7 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -4801,7 +4802,7 @@ def semantify_file(triples_map, triples_map_list, delimiter, output_file_descrip
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -6411,7 +6412,7 @@ def semantify_mysql(row, row_headers, triples_map, triples_map_list, output_file
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down Expand Up @@ -7301,7 +7302,7 @@ def semantify_postgres(row, row_headers, triples_map, triples_map_list, output_f
predicate = None

if predicate_object_map.object_map.mapping_type == "constant" or predicate_object_map.object_map.mapping_type == "constant shortcut":
if "/" in predicate_object_map.object_map.value:
if "http" in predicate_object_map.object_map.value:
object = "<" + predicate_object_map.object_map.value + ">"
else:
object = "\"" + predicate_object_map.object_map.value + "\""
Expand Down

0 comments on commit d8dff7a

Please sign in to comment.