Skip to content

Commit

Permalink
feat: conditional name processing (zotero creator names)
Browse files Browse the repository at this point in the history
see internal issue 40
  • Loading branch information
babslgam authored and koeaw committed Apr 3, 2024
1 parent 11f54ad commit 560e499
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apis_ontology/scripts/import_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import inspect
import os
import sys
import re

from apis_core.apis_relations.models import TempTriple, Property
from apis_ontology.models import (
Expand Down Expand Up @@ -195,6 +196,7 @@ def create_person(person_data: dict, source: DataSource):
full_name = person_data.get("name", person_data.get("full_name", None))
first_name = person_data.get("first_name", person_data.get("firstName", None))
last_name = person_data.get("last_name", person_data.get("lastName", None))
fallback_name = ""

if full_name and full_name == "":
full_name = None
Expand All @@ -208,6 +210,9 @@ def create_person(person_data: dict, source: DataSource):
full_name = f"{first_name} {last_name}"
elif last_name:
full_name = last_name
if re.match("[a-zA-Z]+\.", last_name):
fallback_name = last_name
last_name = ""
elif first_name:
full_name = first_name
else:
Expand All @@ -224,7 +229,7 @@ def create_person(person_data: dict, source: DataSource):
first_name = " ".join(name_parts[:-1])

person, created = Person.objects.get_or_create(
# name=full_name,
fallback_name=fallback_name,
forename=first_name,
surname=last_name,
defaults={"data_source": source},
Expand Down

0 comments on commit 560e499

Please sign in to comment.