Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mardi_importer/mardi_importer/zbmath/ZBMathPublication.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(
title,
doi,
authors,
author_name_strings,
journal,
language,
time,
Expand All @@ -113,6 +114,7 @@ def __init__(
if self.doi:
self.doi = self.doi.upper()
self.authors = authors
self.author_name_strings = author_name_strings
self.journal = journal
self.time = time
self.creation_date = creation_date
Expand Down Expand Up @@ -168,6 +170,11 @@ def insert_claims(self):
claim = self.api.get_claim("wdt:P50", author)
author_claims.append(claim)
self.item.add_claims(author_claims)
author_string_claims = []
for author_string in self.author_name_strings:
claim = self.api.get_claim("P43", author_string)
author_string_claims.append(claim)
self.item.add_claims(author_string_claims)
if self.journal:
self.item.add_claim("wdt:P1433", self.journal)
if self.creation_date:
Expand Down
76 changes: 35 additions & 41 deletions mardi_importer/mardi_importer/zbmath/ZBMathSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,49 +520,42 @@ def push(self):
else:
zbl_id = None

if (
not self.conflict_string in info_dict["author_ids"]
and "None" not in info_dict["author_ids"]
):
author_ids = info_dict["author_ids"].split(";")
if (
self.conflict_string in info_dict["author"]
or "None" in info_dict["author"]
):
author_strings = [None] * len(author_ids)
author_ids = [None if x.strip() == "None" or self.conflict_string in x else x.strip()
for x in info_dict["author_ids"].split(";")]
author_strings = [None if x.strip() == "None" or self.conflict_string in x else x.strip()
for x in info_dict["author"].split(";")]
authors = []
author_name_strings = []
for a, a_id in zip(author_strings, author_ids):
if not a and not a_id:
continue
if a and not a_id:
name_parts = a.split(",")
a_name = ((" ").join(name_parts[1:]) + " " + name_parts[0]).strip()
author_name_strings.append(a_name)
continue
if a_id in self.existing_authors:
authors.append(self.existing_authors[a_id])
print(f"Author with name {a} was already created this run.")
else:
author_strings = info_dict["author"].split(";")
authors = []
for a, a_id in zip(author_strings, author_ids):
if not a and not a_id:
continue
if a:
a = a.strip()
a_id = a_id.strip()
if a_id in self.existing_authors:
authors.append(self.existing_authors[a_id])
print(f"Author with name {a} was already created this run.")
else:
for attempt in range(5):
try:
author = ZBMathAuthor(
name=a,
zbmath_author_id=a_id,
label_id_dict=self.label_id_dict,
)
local_author_id = author.create()
except Exception as e:
print(f"Exception: {e}, sleeping")
print(traceback.format_exc())
time.sleep(120)
else:
break
for attempt in range(5):
try:
author = ZBMathAuthor(
name=a,
zbmath_author_id=a_id,
label_id_dict=self.label_id_dict,
)
local_author_id = author.create()
except Exception as e:
print(f"Exception: {e}, sleeping")
print(traceback.format_exc())
time.sleep(120)
else:
sys.exit("Uploading author did not work after retries!")
authors.append(local_author_id)
self.existing_authors[a_id] = local_author_id
else:
authors = []
break
else:
sys.exit("Uploading author did not work after retries!")
authors.append(local_author_id)
self.existing_authors[a_id] = local_author_id

if (
self.conflict_string in info_dict["serial"]
Expand Down Expand Up @@ -737,6 +730,7 @@ def push(self):
title=document_title,
doi=doi,
authors=authors,
author_name_strings=author_name_strings,
journal=journal,
language=language,
time=time_string,
Expand Down
Loading