1
0
forked from miczar1/djfz-24_25

D3 chyba działa

This commit is contained in:
LuminoX 2025-01-28 22:48:32 +01:00
parent 7dacb80485
commit 81740936e6

35
TaskD03/taskD3.py Normal file
View File

@ -0,0 +1,35 @@
import re
final = []
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r"\b([A-ZĄĆĘŁŃÓŚŹŻ]+\w*)\b|\b([\s'.(\"-]*[a-ząćęłńóśźż]+\w*)\b"
for line in lines:
#line = line.strip()
line = line.replace('\n', '')
x = re.findall(pattern, line)
if "Dokumenty określają Open Source" in line:
pass
a = 0
b = 0
if x:
for words in x:
if words[0] != '':
matching = words[0]
b += 1
elif words[1] != '':
matching = words[1]
a += 1
print(a, b)
final.append([a, b])
with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
for line in final:
for number in line:
file.write(str(number) + ' ')
file.write('\n')