Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
b718541d69 | |||
a7892ad185 | |||
834f781e2c | |||
53e7341220 | |||
956123d97e | |||
348556373e | |||
ed65fd5535 | |||
bcc3d7344f | |||
37f63d6317 | |||
f6dd2eef8c | |||
0beb5c2db5 | |||
c8de88b936 | |||
bf20d2f3a0 | |||
d9c12d5d2f | |||
35dfc38168 |
11
TaskA01/task1.py
Normal file
11
TaskA01/task1.py
Normal 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
5
TaskA02/task2.py
Normal 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
23
TaskA03/task3.py
Normal 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
27
TaskA04/task4.py
Normal 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
10
TaskB01/task1.py
Normal 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
10
TaskB02/task2.py
Normal 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
10
TaskB03/task3.py
Normal 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
10
TaskB04/task4.py
Normal 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))
|
Loading…
Reference in New Issue
Block a user