Skip to content

Commit ac5ae6f

Browse files
committed
Support the use of expanded paths (e.g., "https://openminds.om-i.org/props/description" rather than just "description"`)
1 parent 776dec3 commit ac5ae6f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pipeline/src/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,18 @@ def from_jsonld(cls, data):
125125
if issubclass(cls, LinkedMetadata):
126126
deserialized_data["id"] = data_copy.pop("@id", None)
127127
for property in cls.properties:
128-
if property.path in data_copy: # todo: use context to resolve uris
128+
found = False
129+
if property.path in data_copy:
129130
value = data_copy.pop(property.path)
131+
found = True
132+
else:
133+
# todo: implement or import a function that does a full JSON-LD expansion
134+
# not just this special case
135+
expanded_path = f"{cls.context['@vocab']}{property.path}"
136+
if expanded_path in data_copy:
137+
value = data_copy.pop(expanded_path)
138+
found = True
139+
if found:
130140
if value:
131141
deserialized_data[property.name] = property.deserialize(value)
132142
else:

0 commit comments

Comments
 (0)