Skip to content

Commit

Permalink
Handle case IEEEDocument where number of affliations does not match…
Browse files Browse the repository at this point in the history
… number of authors
  • Loading branch information
stijnh committed Aug 15, 2023
1 parent c723c42 commit 849fece
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions litstudy/sources/ieee.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ..types import Document, Author, DocumentSet, DocumentIdentifier, Affiliation
from ..common import robust_open
import csv
import logging


class IEEEDocument(Document):
Expand All @@ -19,7 +20,20 @@ def title(self) -> str:
def authors(self):
authors = self.entry.get("Authors", "").split("; ")
affs = self.entry.get("Author Affiliations", "").split("; ")
assert len(authors) == len(affs)

# Bug fix #55:
# In some cases, the number of affiliations does not match the number of authors
# given by the CSV file. Since there is no way of knowing which affiliations belong
# to which authors, we just ignore all affiliations in this case.
if len(authors) != len(affs):
affs = [None] * len(authors)
logging.warn(
(
f"affiliations for entry '{self.title}' are invalid: the number of authors "
f"({len(authors)}) does not match the number of author affilications ({len(affs)})"
)
)

return [IEEEAuthor(a, b) for a, b in zip(authors, affs)]

@property
Expand Down Expand Up @@ -85,8 +99,8 @@ def name(self):

@property
def affiliations(self):
# Special case where affiliation is NA (not applicable)
if self._affiliation == "NA":
# Handle special case where affiliation is NA (not applicable)
if not self._affiliation or self._affiliation == "NA":
return None

return [IEEEAffiliation(self._affiliation)]
Expand Down

0 comments on commit 849fece

Please sign in to comment.