TaskAO2 was ended

This commit is contained in:
IgnBys 2023-10-20 17:24:11 +02:00
parent 92361f3372
commit 3612707923
2 changed files with 49 additions and 1 deletions

View File

@ -14,7 +14,7 @@ def openFile(fileName,hamletArray = ['H','a', 'm', 'l', 'e', 't']):
counter = 0
repCounter+=1 #if in one row more than one Hamlet it will write the row only once
if repCounter == 1:
print(row.strip())
print(row.strip()) #use function strip() only for readability
else:
checkWord = ''
counter = 0

48
TaskA02/Task2.py Normal file
View File

@ -0,0 +1,48 @@
# piesArray = [r'[Pp ]', 'i', 'e', 's', r'[ \t\n.,;!?]']
# pies = ['p', 'i', 'e', 's', '.']
# if pies == piesArray:
# print('true')
def openFile(fileName,piesArray = ['[Pp ]', 'i', 'e', 's', '[ \t\n.,;!?]'], patterns = [r'[Pp ]', 'i', 'e', 's', r'[ \t\n.,;!?]']):
with open(fileName, "r", encoding="utf-8") as file:
for row in file:
repCounter = 0
counter = 0
checkWord =[]
for i in row:
if i in piesArray[counter]:
if i != ' ' or counter != 0:
# print(piesArray[4])
checkWord+=i
# print(checkWord)
counter+=1
if len(checkWord) >= 5:
sum = 0
for z in checkWord:
if z in piesArray[sum]:
sum +=1
if sum ==4:
checkWord = []
counter = 0
repCounter += 1 # if in one row more than one Hamlet it will write the row only once
if repCounter == 1:
print(row.strip())
# checkWord = []
# counter = 0
# repCounter+=1 #if in one row more than one Hamlet it will write the row only once
# if repCounter == 1:
# print(row.strip())
else:
checkWord = []
counter = 0
print('---------------------SHAKESPEARE.EXP--------------------------------------')
openFile('polish_wiki_excerpt.exp')
print('----------------------SHAKESPEARE.EXP-----------------------------------')
openFile('polish_wiki_excerpt.in')
print('------------------------SIMPLE.IN------------------------------------')
openFile('simple.in')
print('-----------------------SIMPLE.EXP--------------------------------------')
openFile('simple.exp')