Skip to content

Commit

Permalink
Fix non-standardization option
Browse files Browse the repository at this point in the history
  • Loading branch information
IKCAP committed May 15, 2024
1 parent 63ee972 commit 14635c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pylipd/lipd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions pylipd/utils/lipd_to_rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 14635c9

Please sign in to comment.