diff --git a/.main.py.kate-swp b/.main.py.kate-swp deleted file mode 100644 index 89bc9e9..0000000 Binary files a/.main.py.kate-swp and /dev/null differ diff --git a/main.py b/main.py index 8d00e8b..3924fd0 100644 --- a/main.py +++ b/main.py @@ -25,3 +25,5 @@ listOfCountries = ['nicaragua'] wikidataPEP = WikidataPEP(config) wikidataPEP.importMembersOfParliamentDict(listOfCountries) + +wikidataPEP.checkForEntityIds(listOfCountries) diff --git a/q5.txt b/q5.txt new file mode 100644 index 0000000..dacbb16 --- /dev/null +++ b/q5.txt @@ -0,0 +1,33 @@ +started to parse data of members of nicaragua .. +Q107326760 +--------- +Ángela Espinoza Tórrez +is a human +Q475730 +--------- +Carlos Humberto Ruíz +is a human +Q107316535 +--------- +Iris Marina Montenegro Blandón +is a human +Q107332750 +--------- +Iris Marina Montenegro Blandón +is a human +Q107320919 +--------- +Iris Marina Montenegro Blandón +is a human +Q63794924 +--------- +Loria Raquel Dixon Brautigam +is a human +Q107406987 +--------- +María Haydee Osuna Ruíz +is a human +Q106514750 +--------- +Shaira Natasha Downs Morgan +is a human diff --git a/wikidata/.wdPEP.py.kate-swp b/wikidata/.wdPEP.py.kate-swp new file mode 100644 index 0000000..a625c46 Binary files /dev/null and b/wikidata/.wdPEP.py.kate-swp differ diff --git a/wikidata/__pycache__/wdPEP.cpython-310.pyc b/wikidata/__pycache__/wdPEP.cpython-310.pyc index 75dc185..f17702d 100644 Binary files a/wikidata/__pycache__/wdPEP.cpython-310.pyc and b/wikidata/__pycache__/wdPEP.cpython-310.pyc differ diff --git a/wikidata/wdPEP.py b/wikidata/wdPEP.py index 0dc39b9..675aa3a 100644 --- a/wikidata/wdPEP.py +++ b/wikidata/wdPEP.py @@ -24,14 +24,47 @@ class WikidataPEP(object): for country in listOfCountries: - print('started to parse data of member of ' + country + ' ..') + print('started to parse data of members of ' + country + ' ..') f = open('crawlers/output/' + country +'MemberList.txt') text = f.read() self.fullDictionaryMemberLists[country] = eval(text) - print(self.fullDictionaryMemberLists) + #print(self.fullDictionaryMemberLists) + def checkForEntityIds(self, listOfCountries): + from wikibaseintegrator import WikibaseIntegrator + from wikibaseintegrator import wbi_helpers + + fullDictionaryMemberLists = self.fullDictionaryMemberLists + + for country in listOfCountries: + + for memberId in fullDictionaryMemberLists[country].keys(): + + name = fullDictionaryMemberLists[country][memberId]['name'] + + results = wbi_helpers.search_entities(search_string=name) + + + for entityId in results: + + wbi = WikibaseIntegrator() + wikidata_item = wbi.item.get(entity_id=entityId) + + for claimkey in wikidata_item.get_json()['claims'].keys(): + + if claimkey == 'P31': + + if wikidata_item.get_json()['claims'][claimkey][0]['mainsnak']['datavalue']['value']['id'] == 'Q5': + + print(entityId) + print('---------') + print(name) + print('is a human') + + +