From 5c54c61bff61ca0540b40d9c595f30fcbb69c093 Mon Sep 17 00:00:00 2001 From: Alicia Fagerving Date: Wed, 26 Sep 2018 09:56:01 +0200 Subject: [PATCH] Exclude digit-only lifespans (#35) 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 --- importer/Person.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/importer/Person.py b/importer/Person.py index 3afe38a..e5f4d78 100644 --- a/importer/Person.py +++ b/importer/Person.py @@ -130,11 +130,17 @@ 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: @@ -142,9 +148,6 @@ def set_lifespan(self): 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: