Skip to content

Commit

Permalink
Reconcile move_date_values with dict-wrapped subjects youtube
Browse files Browse the repository at this point in the history
The subject list must be filled with dicts in the format:
{"name": "this is the subject"} to be transformed into
a list of strings in the solr doc. The move_date_values
encrichment wasn't processing dicts, so the two were
out of step with each other."
  • Loading branch information
lthurston committed Oct 24, 2023
1 parent a307a76 commit d1735bd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions metadata_mapper/mappers/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def to_UCLDC(self) -> dict[str, Any]:
# Mapped value may be a function or lambda
self.mapped_data = {k: v() if isinstance(v, Callable) else v for (k, v)
in mapped_data.items()}

return self.mapped_data

def UCLDC_map(self) -> dict:
Expand Down Expand Up @@ -494,10 +493,15 @@ def move_date_values(self, prop, dest="temporal"):

remove = []
for value in src_values:
if not isinstance(value, str):
if isinstance(value, dict):
if "name" not in value:
continue
value = value.get("name")
elif not isinstance(value, str):
continue
cleaned_value = re.sub(r"[\(\)\.\?]", "", value)
cleaned_value = cleaned_value.strip()

for pattern in constants.move_date_value_reg_search:
matches = re.compile(pattern, re.I).findall(cleaned_value)
if (len(matches) == 1 and
Expand Down

0 comments on commit d1735bd

Please sign in to comment.