Compare commits

...

15 Commits

12 changed files with 200106 additions and 4 deletions

11
TaskA01/task1.py Normal file
View File

@ -0,0 +1,11 @@
with open("shakespeare.in", encoding="utf8") as f:
lines = f.readlines()
for line in lines:
line = line.strip()
line = line.split()
for word in line:
if word[:6] == "Hamlet":
result = " ".join(line)
print(result)
break

5
TaskA02/task2.py Normal file
View File

@ -0,0 +1,5 @@
with open("polish_wiki_excerpt.in", encoding="utf8") as f:
lines = f.readlines()
for line in lines:
if "Pies " in line or " pies " in line or "pies\n" in line:
print(line.strip("\n"))

File diff suppressed because one or more lines are too long

23
TaskA03/task3.py Normal file
View File

@ -0,0 +1,23 @@
with open("polish_wiki_excerpt.in", encoding="utf-8") as f:
lines = f.readlines()
result = []
for line in lines:
line = line.replace('\xa0', '[NBA]').strip() # eliminujemy problem z 'non breaking space'
line = line.split()
flag1 = False
for word in line:
if flag1:
if word[:2] == 'r.':
goodLine = ' '.join(line)
result.append(goodLine)
print(goodLine)
break
else:
flag1 = False
if word[-4:-2] == '19':
if word[-2] in '0123456789' and word[-1] in '0123456789':
flag1 = True

File diff suppressed because one or more lines are too long

27
TaskA04/task4.py Normal file
View File

@ -0,0 +1,27 @@
with open('polish_wiki_excerpt.in', encoding='utf8') as f:
lines = f.readlines()
results = []
i = 0
for line in lines:
line = line.strip()
subdigits = []
pom = ''
for char in line:
if char in '0123456789':
pom += char
elif pom != '':
subdigits.append(pom)
pom = ''
else:
pass
if pom.isdigit():
subdigits.append(pom)
if len(subdigits) > 0:
finalLine = ' '.join(subdigits)
print(finalLine)

10
TaskB01/task1.py Normal file
View File

@ -0,0 +1,10 @@
import regex as re
with open('shakespeare.in', encoding='utf8') as file:
lines = file.readlines()
pattern = re.compile(r'Hamlet')
for line in lines:
line = line.strip()
x = re.search(pattern, line)
if x:
print(line)

10
TaskB02/task2.py Normal file
View File

@ -0,0 +1,10 @@
import regex as re
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'( |[Pp])ies(( \w+)|(\.$))'
for line in lines:
line = line.strip()
x = re.search(pattern, line)
if x:
print(line)

File diff suppressed because one or more lines are too long

10
TaskB03/task3.py Normal file
View File

@ -0,0 +1,10 @@
import re
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'19\d\d r\.'
for line in lines:
line = line.strip()
x = re.search(pattern, line)
if x:
print(line)

File diff suppressed because one or more lines are too long

10
TaskB04/task4.py Normal file
View File

@ -0,0 +1,10 @@
import re
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'\d+'
for line in lines:
line = line.strip()
x = re.findall(pattern, line)
if x:
print(' '.join(x))