Skip to content

Commit 776eec8

Browse files
committed
Fixed issue JSON conversion
1 parent 87840cc commit 776eec8

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
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.4.13
87+
4.7.4.14
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.4.13
1+
4.7.4.14

rdfizer/rdfizer/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,7 +3686,8 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
36863686
i += 1
36873687
else:
36883688
if predicate_object_map.object_map.term is None:
3689-
object = "<" + object + ">"
3689+
if object is not None:
3690+
object = "<" + object.replace(" ","%20") + ">"
36903691
elif "IRI" in predicate_object_map.object_map.term:
36913692
object = "<" + object + ">"
36923693
elif "BlankNode" in predicate_object_map.object_map.term:
@@ -3738,7 +3739,7 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37383739
i = 0
37393740
while i < len(object_list):
37403741
if "\\" in object_list[i][1:-1]:
3741-
object = "\"" + object[i][1:-1].replace("\\", "\\\\") + "\""
3742+
object_list[i] = "\"" + object_list[i][1:-1].replace("\\", "\\\\") + "\""
37423743
if "'" in object_list[i][1:-1]:
37433744
object_list[i] = "\"" + object_list[i][1:-1].replace("'", "\\\\'") + "\""
37443745
if "\"" in object_list[i][1:-1]:
@@ -3752,9 +3753,9 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37523753
datatype_value = string_substitution_json(predicate_object_map.object_map.datatype_map, "{(.+?)}", data,
37533754
"object", ignore, iterator)
37543755
if "http" in datatype_value:
3755-
object[i] = "\"" + object[i][1:-1] + "\"" + "^^<{}>".format(datatype_value)
3756+
object_list[i] = "\"" + object_list[i][1:-1] + "\"" + "^^<{}>".format(datatype_value)
37563757
else:
3757-
object[i] = "\"" + object[i][1:-1] + "\"" + "^^<{}>".format("http://example.com/base/" + datatype_value)
3758+
object_list[i] = "\"" + object_list[i][1:-1] + "\"" + "^^<{}>".format("http://example.com/base/" + datatype_value)
37583759
elif predicate_object_map.object_map.language != None:
37593760
if "spanish" == predicate_object_map.object_map.language or "es" == predicate_object_map.object_map.language:
37603761
object_list[i] += "@es"
@@ -3776,10 +3777,12 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37763777
else:
37773778
object_list[i] = None
37783779
i += 1
3780+
37793781
if None in object_list:
37803782
temp = []
3781-
for obj in object_list:
3782-
temp.append(obj)
3783+
for object_element in object_list:
3784+
if object_element != None:
3785+
temp.append(object_element)
37833786
object_list = temp
37843787

37853788
else:
@@ -3792,6 +3795,7 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37923795
object = "\"" + object[1:-1].replace("\"", "\\\"") + "\""
37933796
if "\n" in object:
37943797
object = object.replace("\n", "\\n")
3798+
object = object.replace("\r", "")
37953799
if predicate_object_map.object_map.datatype != None:
37963800
object = "\"" + object[1:-1] + "\"" + "^^<{}>".format(
37973801
predicate_object_map.object_map.datatype)

rdfizer/rdfizer/semantify.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,7 +3686,8 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
36863686
i += 1
36873687
else:
36883688
if predicate_object_map.object_map.term is None:
3689-
object = "<" + object + ">"
3689+
if object is not None:
3690+
object = "<" + object.replace(" ","%20") + ">"
36903691
elif "IRI" in predicate_object_map.object_map.term:
36913692
object = "<" + object + ">"
36923693
elif "BlankNode" in predicate_object_map.object_map.term:
@@ -3738,7 +3739,7 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37383739
i = 0
37393740
while i < len(object_list):
37403741
if "\\" in object_list[i][1:-1]:
3741-
object = "\"" + object[i][1:-1].replace("\\", "\\\\") + "\""
3742+
object_list[i] = "\"" + object_list[i][1:-1].replace("\\", "\\\\") + "\""
37423743
if "'" in object_list[i][1:-1]:
37433744
object_list[i] = "\"" + object_list[i][1:-1].replace("'", "\\\\'") + "\""
37443745
if "\"" in object_list[i][1:-1]:
@@ -3752,9 +3753,9 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37523753
datatype_value = string_substitution_json(predicate_object_map.object_map.datatype_map, "{(.+?)}", data,
37533754
"object", ignore, iterator)
37543755
if "http" in datatype_value:
3755-
object[i] = "\"" + object[i][1:-1] + "\"" + "^^<{}>".format(datatype_value)
3756+
object_list[i] = "\"" + object_list[i][1:-1] + "\"" + "^^<{}>".format(datatype_value)
37563757
else:
3757-
object[i] = "\"" + object[i][1:-1] + "\"" + "^^<{}>".format("http://example.com/base/" + datatype_value)
3758+
object_list[i] = "\"" + object_list[i][1:-1] + "\"" + "^^<{}>".format("http://example.com/base/" + datatype_value)
37583759
elif predicate_object_map.object_map.language != None:
37593760
if "spanish" == predicate_object_map.object_map.language or "es" == predicate_object_map.object_map.language:
37603761
object_list[i] += "@es"
@@ -3776,10 +3777,12 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37763777
else:
37773778
object_list[i] = None
37783779
i += 1
3780+
37793781
if None in object_list:
37803782
temp = []
3781-
for obj in object_list:
3782-
temp.append(obj)
3783+
for object_element in object_list:
3784+
if object_element != None:
3785+
temp.append(object_element)
37833786
object_list = temp
37843787

37853788
else:
@@ -3792,6 +3795,7 @@ def semantify_json(triples_map, triples_map_list, delimiter, output_file_descrip
37923795
object = "\"" + object[1:-1].replace("\"", "\\\"") + "\""
37933796
if "\n" in object:
37943797
object = object.replace("\n", "\\n")
3798+
object = object.replace("\r", "")
37953799
if predicate_object_map.object_map.datatype != None:
37963800
object = "\"" + object[1:-1] + "\"" + "^^<{}>".format(
37973801
predicate_object_map.object_map.datatype)

0 commit comments

Comments
 (0)