zad 3 dziala, naprawienie wyjatkow z NBSP
This commit is contained in:
parent
f6dd2eef8c
commit
37f63d6317
@ -1,27 +1,23 @@
|
|||||||
with open("polish_wiki_excerpt.in", encoding="utf-8") as f:
|
with open("polish_wiki_excerpt.in", encoding="utf-8") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
result = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = line.strip()
|
line = line.replace('\xa0', '[NBA]').strip() # eliminujemy problem z 'non breaking space'
|
||||||
line = line.split()
|
line = line.split()
|
||||||
|
|
||||||
flag1 = False # sprawdzam czy slowo jest liczba miedzy 1900 a 1999
|
flag1 = False
|
||||||
flag2 = False # sprawdzam czy za liczba jest 'r.'
|
|
||||||
|
|
||||||
for word in line:
|
for word in line:
|
||||||
if word == 'Terespola':
|
|
||||||
pass
|
|
||||||
if flag1:
|
if flag1:
|
||||||
if word[:2] == 'r.':
|
if word[:2] == 'r.':
|
||||||
flag2 = True
|
goodLine = ' '.join(line)
|
||||||
|
result.append(goodLine)
|
||||||
|
print(goodLine)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
flag1 = False
|
flag1 = False
|
||||||
|
if word[-4:-2] == '19':
|
||||||
if word[len(word)-4 : len(word)-2] == '19':
|
if word[-2] in '0123456789' and word[-1] in '0123456789':
|
||||||
if word[2] in '0123456789' and word[3] in '0123456789':
|
|
||||||
flag1 = True
|
flag1 = True
|
||||||
|
|
||||||
|
|
||||||
if flag1 is True and flag2 is True:
|
|
||||||
goodLine = ' '.join(line)
|
|
||||||
print(goodLine)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user