This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrakCzesciMowy.py
63 lines (52 loc) · 2.11 KB
/
brakCzesciMowy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python
# -*- coding: utf-8 -*-
from tqdm import tqdm
import pywikibot
from pywikibot import pagegenerators
import re
from pywikibot import xmlreader
import collections
from klasa import *
def brakCzesciMowy(data):
data_slownie = data[6] + data[7] + '.' + data[4] + data[5] + '.' + data[0] + data[1] + data[2] + data[3]
lista_stron = getListFromXML(data)
wikt = pywikibot.Site('pl', 'wiktionary')
outputPage = pywikibot.Page(wikt, 'Wikipedysta:AlkamidBot/listy/części_mowy')
tempLangs = []
notFound = []
text = 'Do poniższych haseł nie wpisano, jakimi są częściami mowy - jeśli potrafisz, zrób to. Ostatnia aktualizacja wg zrzutu bazy danych z %s.\n' % (data_slownie)
notFoundList = collections.defaultdict(list)
LangsMediaWiki = getAllLanguages()
with open('output/missing_pos.txt', encoding='utf-8', mode='w') as f:
for i, a in enumerate(tqdm(lista_stron)):
if i < 722349:
continue
try: word = Haslo(a)
except notFromMainNamespace:
pass
except sectionsNotFound:
pass
except WrongHeader:
pass
except IndexError:
print(a.text)
raise IndexError
else:
if word.type == 3:
for lang in word.listLangs:
if lang.type != 2 and lang.type != 7:
lang.pola()
if lang.type == 5:
notFoundList['%s' % lang.lang].append(lang.title)
#print(lang.title)
f.write(lang.title + '\n')
for a in LangsMediaWiki:
if notFoundList['%s' % a.shortName]:
text += '== %s ==' % (a.longName)
for b in notFoundList['%s' % a.shortName]:
text += '\n*[[%s]]' % (b)
text += '\n'
#with open('output/missing_pos.txt', encoding='utf-8', mode='w') as f:
# f.write(text)
outputPage.text = text
outputPage.save(comment="Aktualizacja listy", botflag=False)