Skip to content

Commit

Permalink
DataTypes should be URIRef (#714)
Browse files Browse the repository at this point in the history
We should always convert DataTypes from string format to URIRef.

Currently, we do it only in some cases, it should be done consistently.
  • Loading branch information
ccl-core authored Jul 18, 2024
1 parent 2cb765e commit f685231
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/mlcroissant/mlcroissant/_src/core/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def check_expected_type(issues: Issues, jsonld: Json, expected_type: str):
def data_types_from_jsonld(ctx: Context, data_types: Json):
"""Extracts DataType from its JSON-LD."""
if isinstance(data_types, dict):
return data_types.get("@id")
data_type = data_types.get("@id")
if isinstance(data_type, str):
data_type = term.URIRef(data_type)
return data_type
elif isinstance(data_types, (str, term.URIRef)):
return term.URIRef(data_types)
elif isinstance(data_types, list):
Expand Down

0 comments on commit f685231

Please sign in to comment.