From 58241aa624b6271c41282a268a8376946fa71804 Mon Sep 17 00:00:00 2001 From: Varun Ratnakar Date: Fri, 26 Jul 2024 18:34:13 +0530 Subject: [PATCH] Bugfix for values not in vocab --- pylipd/utils/legacy_utils.py | 3 ++- pylipd/utils/lipd_to_rdf.py | 1 - pylipd/utils/rdf_to_lipd.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pylipd/utils/legacy_utils.py b/pylipd/utils/legacy_utils.py index 393f84c..93e3ee4 100644 --- a/pylipd/utils/legacy_utils.py +++ b/pylipd/utils/legacy_utils.py @@ -46,7 +46,8 @@ def extract(self, d, whichtables="meas", mode="paleo", time="age"): _pc = "chronData" _root["mode"] = _pc _root["time_id"] = time - _root["archiveType"] = d["archiveType"] + if "archiveType" in d: + _root["archiveType"] = d["archiveType"] try: # Build the root level data. # This will serve as the template for which column data will be added onto later. diff --git a/pylipd/utils/lipd_to_rdf.py b/pylipd/utils/lipd_to_rdf.py index 08c7b1c..70fa828 100644 --- a/pylipd/utils/lipd_to_rdf.py +++ b/pylipd/utils/lipd_to_rdf.py @@ -373,7 +373,6 @@ def _add_interpretation_rank(self, obj, objhash): if "rank" not in obj or type(obj["rank"]) != int: rank = obj["@index"] - 1 obj["rank"] = rank - print(obj["@id"], obj["rank"]) return [obj, objhash, []] def _wrap_uncertainty(self, obj, objhash) : diff --git a/pylipd/utils/rdf_to_lipd.py b/pylipd/utils/rdf_to_lipd.py index f822bbe..1179b4f 100644 --- a/pylipd/utils/rdf_to_lipd.py +++ b/pylipd/utils/rdf_to_lipd.py @@ -507,6 +507,8 @@ def _set_archive_type_label(self, ds, parent = None) : id = ds["hasArchiveType"]["@id"] if id in RSYNONYMS: ds["archiveType"] = RSYNONYMS[id] + else: + ds["archiveType"] = ds["hasArchiveType"]["label"] del ds["hasArchiveType"] return ds @@ -517,6 +519,8 @@ def _set_variable_name_from_standard_variable_label(self, var, parent = None) : id = var["hasStandardVariable"]["@id"] if id in RSYNONYMS: var["variableName"] = RSYNONYMS[id] + else: + var["variableName"] = var["hasStandardVariable"]["label"] del var["hasStandardVariable"] return var @@ -527,6 +531,8 @@ def _set_units_label(self, var, parent = None) : id = var["hasUnits"]["@id"] if id in RSYNONYMS: var["units"] = RSYNONYMS[id] + else: + var["units"] = var["hasUnits"]["label"] del var["hasUnits"] return var @@ -537,6 +543,8 @@ def _set_proxy_label(self, var, parent = None) : id = var["hasProxy"]["@id"] if id in RSYNONYMS: var["proxy"] = RSYNONYMS[id] + else: + var["proxy"] = var["hasProxy"]["label"] del var["hasProxy"] return var @@ -547,6 +555,8 @@ def _set_proxy_general_label(self, var, parent = None) : id = var["hasProxyGeneral"]["@id"] if id in RSYNONYMS: var["proxyGeneral"] = RSYNONYMS[id] + else: + var["proxyGeneral"] = var["hasProxyGeneral"]["label"] del var["hasProxyGeneral"] return var @@ -564,6 +574,8 @@ def _set_seasonality_labels(self, interp, parent = None) : nid = convs[pid] if id in RSYNONYMS: interp[nid] = RSYNONYMS[id] + else: + interp[nid] = interp[pid]["label"] del interp[pid] return interp