Пример #1
0
 def test_chantal_nijkerken_de_haan(self):
     wikidata_id = 'Q19830701'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
     self.assertEqual(forename, 'Chantal')
     self.assertEqual(surname, 'Nijkerken-de Haan')
Пример #2
0
def get_or_create_person(wikidata_id,
                         fullname='',
                         wikidata_item=None,
                         add_initials=False):
    persons = Person.objects.filter(wikidata_id=wikidata_id)
    if not wikidata_item:
        wikidata_item = wikidata.WikidataItem(wikidata_id)
    if persons.exists():
        person = persons[0]
    else:
        if not fullname:
            fullname = wikidata_item.get_label(language='nl')
        forename, surname, surname_prefix = Person.get_name_parts(
            fullname, wikidata_item)
        person = Person.objects.create(forename=forename,
                                       surname=surname,
                                       surname_prefix=surname_prefix,
                                       wikidata_id=wikidata_id)
        person.update_info(language='nl', wikidata_item=wikidata_item)
        person.save()
        if add_initials and person.parlement_and_politiek_id:
            person.initials = scraper.persons.get_initials(
                person.parlement_and_politiek_id)
            person.save()
        assert person.wikidata_id == wikidata_id
    party_members = PartyMember.objects.filter(person=person)
    if not party_members.exists():
        create_party_members_for_person(person)
    return person
Пример #3
0
 def test_chantal_nijkerken_de_haan(self):
     wikidata_id = 'Q19830701'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Chantal')
     self.assertEqual(surname, 'Nijkerken-de Haan')
Пример #4
0
 def test_leendert_de_lange(self):
     wikidata_id = 'Q19839084'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
     self.assertEqual(forename, 'Leendert')
     self.assertEqual(surname_prefix, 'de')
     self.assertEqual(surname, 'Lange')
Пример #5
0
 def test_sjoerd_sjoerdsma(self):
     wikidata_id = 'Q516335'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
     self.assertEqual(forename, 'Sjoerd')
     self.assertEqual(surname, 'Sjoerdsma')
     self.assertEqual(surname_prefix, '')
Пример #6
0
 def test_sybrand_van_haersma_buma(self):
     wikidata_id = 'Q377266'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
     self.assertEqual(forename, 'Sybrand')
     self.assertEqual(surname, 'Haersma Buma')
     self.assertEqual(surname_prefix, 'van')
Пример #7
0
 def test_jan_kees_de_jager(self):
     wikidata_id = 'Q1666631'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
     self.assertEqual(forename, 'Jan Kees')
     self.assertEqual(surname, 'Jager')
     self.assertEqual(surname_prefix, 'de')
Пример #8
0
 def test_jan_peter_balkenende(self):
     wikidata_id = 'Q133386'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
     self.assertEqual(forename, 'Jan Peter')
     self.assertEqual(surname, 'Balkenende')
     self.assertEqual(surname_prefix, '')
Пример #9
0
 def test_fatma_koser_kaya(self):
     wikidata_id = 'Q467610'  # Fatma Koşer Kaya
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
     self.assertEqual(forename, 'Fatma')
     self.assertEqual(surname, 'Koşer Kaya')
     self.assertEqual(surname_prefix, '')
Пример #10
0
 def test_sjoerd_sjoerdsma(self):
     wikidata_id = 'Q516335'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Sjoerd')
     self.assertEqual(surname, 'Sjoerdsma')
     self.assertEqual(surname_prefix, '')
Пример #11
0
 def test_jan_kees_de_jager(self):
     wikidata_id = 'Q1666631'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Jan Kees')
     self.assertEqual(surname, 'Jager')
     self.assertEqual(surname_prefix, 'de')
Пример #12
0
 def test_jan_peter_balkenende(self):
     wikidata_id = 'Q133386'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Jan Peter')
     self.assertEqual(surname, 'Balkenende')
     self.assertEqual(surname_prefix, '')
Пример #13
0
 def test_fatma_koser_kaya(self):
     wikidata_id = 'Q467610'  # Fatma Koşer Kaya
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Fatma')
     self.assertEqual(surname, 'Koşer Kaya')
     self.assertEqual(surname_prefix, '')
Пример #14
0
 def test_sybrand_van_haersma_buma(self):
     wikidata_id = 'Q377266'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Sybrand')
     self.assertEqual(surname, 'Haersma Buma')
     self.assertEqual(surname_prefix, 'van')
Пример #15
0
 def test_leendert_de_lange(self):
     wikidata_id = 'Q19839084'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Leendert')
     self.assertEqual(surname_prefix, 'de')
     self.assertEqual(surname, 'Lange')
Пример #16
0
 def test_melanie_schultz_van_hagen(self):
     wikidata_id = 'Q435886'
     wikidata_item = wikidata.WikidataItem(wikidata_id)
     fullname = wikidata_item.get_label()
     forename, surname, surname_prefix = Person.get_name_parts(
         fullname, wikidata_item)
     self.assertEqual(forename, 'Melanie')
     self.assertEqual(surname_prefix, '')
     self.assertEqual(surname, 'Schultz van Haegen')
Пример #17
0
def create_person(wikidata_id, fullname, wikidata_item, add_initials):
    if not fullname:
        fullname = wikidata_item.get_label(language='nl')
    forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item)
    person = Person.objects.create(
        forename=forename,
        surname=surname,
        surname_prefix=surname_prefix,
        wikidata_id=wikidata_id
    )
    person.update_info(language='nl', wikidata_item=wikidata_item)
    person.save()
    if add_initials and person.parlement_and_politiek_id:
        person.initials = scraper.persons.get_initials(person.parlement_and_politiek_id)
        person.save()
    assert person.wikidata_id == wikidata_id
    return person
Пример #18
0
def create_person(wikidata_id, fullname, wikidata_item, add_initials):
    if not fullname:
        fullname = wikidata_item.get_label(language='nl')
    forename, surname, surname_prefix = Person.get_name_parts(
        fullname, wikidata_item)
    person = Person.objects.create(forename=forename,
                                   surname=surname,
                                   surname_prefix=surname_prefix,
                                   wikidata_id=wikidata_id)
    person.update_info(language='nl', wikidata_item=wikidata_item)
    person.save()
    if add_initials and person.parlement_and_politiek_id:
        person.initials = scraper.persons.get_initials(
            person.parlement_and_politiek_id)
        person.save()
    add_tk_person_id(person)
    assert person.wikidata_id == wikidata_id
    return person