Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

29 changed files with 10 additions and 500424 deletions

View File

@ -1,11 +0,0 @@
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

View File

@ -1,5 +0,0 @@
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

View File

@ -1,23 +0,0 @@
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

View File

@ -1,27 +0,0 @@
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)

View File

@ -1,10 +0,0 @@
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)

View File

@ -1,10 +0,0 @@
import regex as re
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'(P|( p))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

View File

@ -1,10 +0,0 @@
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

View File

@ -1,10 +0,0 @@
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))

View File

@ -1,25 +0,0 @@
import re
pattern = re.compile(r'^\d{2}-\d{3}$')
def check(given_text):
result = re.search(pattern, given_text)
if result:
return given_text[:2]
else:
return '<NONE>'
### test
# with open('test.in', 'r', encoding='utf-8') as f:
# lines = f.readlines()
# for line in lines:
# line = line.strip()
# print(check(line))
while True:
text = input('Please provide your text: ')
if text == 'END':
break
print(check(text))
print('To end type END')

View File

@ -1,27 +0,0 @@
import re
pattern = re.compile(r'^[1248]0*$')
def check(given_text):
result = re.search(pattern, given_text)
if result:
return 'yes'
else:
return 'no'
### test
# with open('test.in', 'r', encoding='utf-8') as f:
# lines = f.readlines()
# for line in lines:
# line = line.strip()
# print(check(line))
while True:
text = input('Please provide your text: ')
if text == 'END':
break
print(check(text))
print('To end type END')

View File

@ -1,25 +0,0 @@
import re
pattern = re.compile(r'^N((I[E]{6,})|([O]{6,}))[!]{3,}$')
def check(given_text):
result = re.search(pattern, given_text)
if result:
return 'yes'
else:
return 'no'
### test
# with open('test.in', 'r', encoding='utf-8') as f:
# lines = f.readlines()
# for line in lines:
# line = line.strip()
# print(check(line))
while True:
text = input('Please provide your text: ')
if text == 'END':
break
print(check(text))
print('To end type END')

View File

@ -1,25 +0,0 @@
import re
pattern = re.compile(r'#[a-zA-Z]\w*')
def check(given_text):
result = re.findall(pattern, given_text)
if result:
return ';'.join(result)
else:
return '<NONE>'
### test
# with open('test.in', 'r', encoding='utf-8') as f:
# lines = f.readlines()
# for line in lines:
# line = line.strip()
# print(check(line))
while True:
text = input('Please provide your text: ')
if text == 'END':
break
print(check(text))
print('To end type END')

File diff suppressed because one or more lines are too long

View File

@ -1,37 +0,0 @@
import re
dictionary = {
'0': 'a',
'1': 'b',
'2': 'c',
'3': 'd',
'4': 'e',
'5': 'f',
'6': 'g',
'7': 'h',
'8': 'i',
'9': 'j',
}
final = []
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'\d{4}'
for line in lines:
line = line.strip()
x = re.findall(pattern, line)
if x:
for words in x:
decoded_word = ''
for char in words:
decoded_word += dictionary[char]
line = line.replace(words, decoded_word, 1)
print(line)
final.append(line)
with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
for line in final:
file.write(line + '\n')

File diff suppressed because one or more lines are too long

View File

@ -1,46 +0,0 @@
import re
final = []
polish_big = 'AĄBCĆDEĘFGQHIJKLŁMNŃOÓPRSŚTUWXVYZŹŻ'
polish_small = 'aąbcćdeęfgqhijklłmnńoóprsśtuwxvyzźż'
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'(\w*[A-ZĄĆĘŁŃÓŚŹŻ]+[a-ząćęłńóśźż]+\w*)|(\w*[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻ]+\w*)'
for line in lines:
line = line.strip()
x = re.findall(pattern, line)
if x:
for words in x:
if words[0] != '':
to_replace = words[0]
new_word = ''
for char in to_replace:
if char in polish_big:
new_word += char.lower()
elif char in polish_small:
new_word += char.upper()
else:
new_word += char
elif words[1] != '':
to_replace = words[1]
new_word = ''
for char in to_replace:
if char in polish_small:
new_word += char.upper()
elif char in polish_big:
new_word += char.lower()
else:
new_word += char
line = line.replace(to_replace, new_word, 1)
print(line)
final.append(line)
with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
for line in final:
file.write(line + '\n')
### odpowiedź nie do końca pokrywa się z plikiem .exp w wyniku obecności znaków z niemieckiego alfabetu

File diff suppressed because one or more lines are too long

View File

@ -1,42 +0,0 @@
import re
final = []
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'([a-ząćęłńóśźż]+)|([A-ZĄĆĘŁŃÓŚŹŻ]+)|(\d+)'
for line in lines:
#line = line.strip()
line = line.replace('\n', '')
x = re.findall(pattern, line)
if "Nikołaj Judenicz" in line:
pass
a = 0
b = 0
c = 0
d = 0
if x:
for words in x:
if words[0] != '':
matching = words[0]
a += len(matching)
elif words[1] != '':
matching = words[1]
b += len(matching)
elif words[2] != '':
matching = words[2]
c += len(matching)
d = len(line) - a - b - c
print(a, b, c, d)
final.append([a, b, c, d])
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')

File diff suppressed because one or more lines are too long

View File

@ -1,32 +0,0 @@
import re
final = []
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r"\b([A-ZĄĆĘŁŃÓŚŹŻ]+\w*)\b|\b([a-ząćęłńóśźż]+\w*)\b"
for line in lines:
#line = line.strip()
line = line.replace('\n', '')
x = re.findall(pattern, line)
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')

File diff suppressed because one or more lines are too long

View File

@ -1,18 +0,0 @@
import re
final = []
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r'(\D*\d+\D+?)\d+(.*)'
for line in lines:
line = line.strip()
line = re.sub(pattern, r'\1\2', line, count=1)
print(line)
final.append(line)
with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
for line in final:
file.write(line + '\n')

File diff suppressed because one or more lines are too long

View File

@ -1,25 +0,0 @@
import re
final = []
with open('polish_wiki_excerpt.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r"(\W*[\wąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+\W+[\wąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+\W)[\wąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+"
for line in lines:
line = line.strip()
def replace_third_word(match):
prefix = match.group(1)
word_to_replace = match.group(0)[len(prefix):len(match.group(0))]
replacement = 'x' * len(word_to_replace)
return prefix + replacement
line = re.sub(pattern, replace_third_word, line)
print(line)
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')

View File

@ -1,16 +0,0 @@
with open("./TaskD01/polish_wiki_excerpt.out", 'r', encoding='utf8') as f:
lines1 = f.readlines()
with open("./TaskD01/polish_wiki_excerpt.exp", 'r', encoding='utf8') as f:
lines2 = f.readlines()
i = 1
for line1, line2 in zip(lines1, lines2):
if line1.strip() == line2.strip():
pass
# print('hurray')
else:
print(f'{i}: bad: \n{line1}{line2}')
i += 1