Skip to content

Commit

Permalink
Exclude digit-only lifespans (#35)
Browse files Browse the repository at this point in the history
Ignore single dates without delimiter, such as YYYY, in life span field.

The life span field is supposed to contain a range,
so a year without an indication of whether it's the
birth o death year is ambiguous.

Task: https://phabricator.wikimedia.org/T205373
  • Loading branch information
Vesihiisi committed Sep 26, 2018
1 parent 01abfba commit 5c54c61
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions importer/Person.py
Expand Up @@ -130,21 +130,24 @@ def set_lifespan(self):
bio_section = self.raw_data[1]
if not bio_section.get("lifeSpan"):
return
life = bio_section["lifeSpan"].replace("–", "-").split("-")
born_raw = life[0]
dead_raw = life[1]
if len(born_raw) == 4:
born_dict = utils.date_to_dict(born_raw, "%Y")
if not bio_section["lifeSpan"].isdigit():
# Exclude lifespans that are digits only, no
# delimiter
life = bio_section["lifeSpan"].replace("–", "-").split("-")
born_raw = life[0]
dead_raw = life[1]
if len(born_raw) == 4:
born_dict = utils.date_to_dict(born_raw, "%Y")
if len(dead_raw) == 4:
dead_dict = utils.date_to_dict(dead_raw, "%Y")

if "birthDate" in bio_section.keys():
born_long_raw = bio_section["birthDate"]
if len(born_long_raw) == 8:
born_dict = utils.date_to_dict(born_long_raw, "%Y%m%d")
if born_dict:
born_pwb = self.make_pywikibot_item({"date_value": born_dict})
self.add_statement("born", born_pwb, ref=self.source)

if len(dead_raw) == 4:
dead_dict = utils.date_to_dict(dead_raw, "%Y")
if "deathDate" in bio_section.keys():
dead_long_raw = bio_section["deathDate"]
if len(dead_long_raw) == 8:
Expand Down

0 comments on commit 5c54c61

Please sign in to comment.