Skip to content

Commit

Permalink
Further work on the join issue for JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
eiglesias34 committed Dec 7, 2022
1 parent 2d0e15a commit 9d62626
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 12 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.6.4.3
4.6.4.4
```

## 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.6.4.3
4.6.4.4
29 changes: 24 additions & 5 deletions rdfizer/rdfizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,22 @@ def join_iterator(data, iterator, parent, child):
new_iterator += tp + "."
if "$" != tp and "" != tp:
if "[*][*]" in tp:
row = row[tp.split("[*][*]")[0]]
if tp.split("[*][*]")[0] in row:
row = row[tp.split("[*][*]")[0]]
else:
row = []
elif "[*]" in tp:
row = row[tp.split("[*]")[0]]
if tp.split("[*]")[0] in row:
row = row[tp.split("[*]")[0]]
else:
row = []
elif "*" == tp:
pass
else:
row = row[tp]
if tp in row:
row = row[tp]
else:
row = []
elif tp == "":
if len(row.keys()) == 1:
while list(row.keys())[0] not in temp_keys:
Expand All @@ -168,6 +177,9 @@ def join_iterator(data, iterator, parent, child):
join_iterator(sub_row, iterator, parent, child)
executed = False
break
elif isinstance(row,str):
row = []
break
else:
join_iterator(row[list(row.keys())[0]], "", parent, child)
else:
Expand Down Expand Up @@ -1501,6 +1513,9 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
for sub_row in row:
i += semantify_json(triples_map, triples_map_list, delimiter, output_file_descriptor, sub_row, iterator.replace(new_iterator[:-1],""))
executed = False
break
if isinstance(row,str):
row = []
break
if "*" == new_iterator[-2]:
for sub_row in row:
Expand Down Expand Up @@ -1878,8 +1893,12 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
temp_keys = predicate_object_map.object_map.child[0].split(".")
temp_data = data
for temp in temp_keys:
temp_data = temp_data[temp]
if temp_data in join_table[triples_map_element.triples_map_id + "_" + predicate_object_map.object_map.child[0]]:
if temp in temp_data:
temp_data = temp_data[temp]
else:
temp_data = ""
break
if temp_data in join_table[triples_map_element.triples_map_id + "_" + predicate_object_map.object_map.child[0]] and temp_data != "":
object_list = join_table[triples_map_element.triples_map_id + "_" + predicate_object_map.object_map.child[0]][temp_data]
else:
object_list = []
Expand Down
29 changes: 24 additions & 5 deletions rdfizer/rdfizer/semantify.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,22 @@ def join_iterator(data, iterator, parent, child):
new_iterator += tp + "."
if "$" != tp and "" != tp:
if "[*][*]" in tp:
row = row[tp.split("[*][*]")[0]]
if tp.split("[*][*]")[0] in row:
row = row[tp.split("[*][*]")[0]]
else:
row = []
elif "[*]" in tp:
row = row[tp.split("[*]")[0]]
if tp.split("[*]")[0] in row:
row = row[tp.split("[*]")[0]]
else:
row = []
elif "*" == tp:
pass
else:
row = row[tp]
if tp in row:
row = row[tp]
else:
row = []
elif tp == "":
if len(row.keys()) == 1:
while list(row.keys())[0] not in temp_keys:
Expand All @@ -168,6 +177,9 @@ def join_iterator(data, iterator, parent, child):
join_iterator(sub_row, iterator, parent, child)
executed = False
break
elif isinstance(row,str):
row = []
break
else:
join_iterator(row[list(row.keys())[0]], "", parent, child)
else:
Expand Down Expand Up @@ -1501,6 +1513,9 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
for sub_row in row:
i += semantify_json(triples_map, triples_map_list, delimiter, output_file_descriptor, sub_row, iterator.replace(new_iterator[:-1],""))
executed = False
break
if isinstance(row,str):
row = []
break
if "*" == new_iterator[-2]:
for sub_row in row:
Expand Down Expand Up @@ -1878,8 +1893,12 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
temp_keys = predicate_object_map.object_map.child[0].split(".")
temp_data = data
for temp in temp_keys:
temp_data = temp_data[temp]
if temp_data in join_table[triples_map_element.triples_map_id + "_" + predicate_object_map.object_map.child[0]]:
if temp in temp_data:
temp_data = temp_data[temp]
else:
temp_data = ""
break
if temp_data in join_table[triples_map_element.triples_map_id + "_" + predicate_object_map.object_map.child[0]] and temp_data != "":
object_list = join_table[triples_map_element.triples_map_id + "_" + predicate_object_map.object_map.child[0]][temp_data]
else:
object_list = []
Expand Down

0 comments on commit 9d62626

Please sign in to comment.