From 14635c98ecce7223514681f38046ab452e6f7d57 Mon Sep 17 00:00:00 2001 From: Varun Ratnakar Date: Wed, 15 May 2024 13:23:23 +0530 Subject: [PATCH] Fix non-standardization option --- pylipd/lipd.py | 4 ++-- pylipd/utils/lipd_to_rdf.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pylipd/lipd.py b/pylipd/lipd.py index b72e338..cb044ab 100644 --- a/pylipd/lipd.py +++ b/pylipd/lipd.py @@ -57,7 +57,7 @@ def __init__(self, graph=None): super().__init__(graph) - def load_from_dir(self, dir_path, parallel=False, cutoff=None): + def load_from_dir(self, dir_path, parallel=False, cutoff=None, standardize=True, add_labels=True): '''Load LiPD files from a directory Parameters @@ -96,7 +96,7 @@ def load_from_dir(self, dir_path, parallel=False, cutoff=None): lipdfiles.append(file_path) if cutoff: lipdfiles = lipdfiles[0:cutoff] - self.load(lipdfiles, parallel) + self.load(lipdfiles, parallel, standardize, add_labels) # Allows loading http locations diff --git a/pylipd/utils/lipd_to_rdf.py b/pylipd/utils/lipd_to_rdf.py index 0954878..b4147e7 100644 --- a/pylipd/utils/lipd_to_rdf.py +++ b/pylipd/utils/lipd_to_rdf.py @@ -890,14 +890,19 @@ def _create_individual_full(self, obj) : # Set property value if dtype == "Individual": - if self.standardize and type(value) is str and value.lower() in synonyms: + if type(value) is str and value.lower() in synonyms: # Only standardize if set to standardize propDI[1] = "EnumeratedIndividual" # Rename property type to be an enumeration synid = synonyms[value.lower()]["id"] + if not self.standardize: + synid += "." + uniqid() self._set_property_value(objid, propDI, synid) # Only add object label in the current graph if set if self.add_labels: - label = synonyms[value.lower()]["label"] + if self.standardize: + label = synonyms[value.lower()]["label"] + else: + label = value self._set_object_label(synid, label) else: self._set_property_value(objid, propDI, value)