First commit
This commit is contained in:
parent
b48d6239ad
commit
5c739e9cf7
28
TaskA01/Task1.py
Normal file
28
TaskA01/Task1.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
def openFile(fileName,hamletArray = ['H','a', 'm', 'l', 'e', 't']):
|
||||||
|
with open(fileName, "r", encoding="utf-8") as file:
|
||||||
|
for row in file:
|
||||||
|
repCounter = 0
|
||||||
|
counter = 0
|
||||||
|
checkWord =''
|
||||||
|
for i in row:
|
||||||
|
if i == hamletArray[counter]:
|
||||||
|
checkWord+=i
|
||||||
|
counter+=1
|
||||||
|
if checkWord == 'Hamlet':
|
||||||
|
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('shakespeare.exp')
|
||||||
|
print('----------------------SHAKESPEARE.EXP-----------------------------------')
|
||||||
|
openFile('shakespeare.in')
|
||||||
|
print('------------------------SIMPLE.IN------------------------------------')
|
||||||
|
openFile('simple.in')
|
||||||
|
print('-----------------------SIMPLE.EXP--------------------------------------')
|
||||||
|
openFile('simple.exp')
|
31
TaskA02/TaskAO2.py
Normal file
31
TaskA02/TaskAO2.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def openFile(fileName,piesArray1 = [' ', 'P', 'p', '('],
|
||||||
|
piesArray2 = ['i', 'e', 's'],
|
||||||
|
piesArray3 = ['\t', '\n', '.', ',', ';', '!', '?', ')']):
|
||||||
|
with open(fileName, "r", encoding="utf-8") as file:
|
||||||
|
file_contents = file.read()
|
||||||
|
for row in file:
|
||||||
|
piesArrayCounter = 0
|
||||||
|
repCounter = 0
|
||||||
|
counter = 0
|
||||||
|
checkWord = ''
|
||||||
|
for character in row:
|
||||||
|
if character == ' ':
|
||||||
|
checkWord+=character
|
||||||
|
if counter == 0 and checkWord == ' ':
|
||||||
|
if (character == 'P' or character == 'p'):
|
||||||
|
counter +=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print('---------------------SHAKESPEARE.EXP--------------------------------------')
|
||||||
|
openFile('shakespeare.exp')
|
||||||
|
print('----------------------SHAKESPEARE.EXP-----------------------------------')
|
||||||
|
openFile('shakespeare.in')
|
||||||
|
print('------------------------SIMPLE.IN------------------------------------')
|
||||||
|
openFile('simple.in')
|
||||||
|
print('-----------------------SIMPLE.EXP--------------------------------------')
|
||||||
|
openFile('simple.exp')
|
@ -1,3 +1,3 @@
|
|||||||
Pies ma Alę
|
Pies ma Alę
|
||||||
Kot i pies to zwierzęta
|
Kot i pies to zwierzęta
|
||||||
pies
|
(pies)
|
||||||
|
2
TaskA02/test.py
Normal file
2
TaskA02/test.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
str = r'[Pp ]ies '
|
||||||
|
print(len(str))
|
@ -1,22 +1,45 @@
|
|||||||
def openFile(fileName, ageArray = ['1', '9', '[0123456789]', '[0123456789]', ' ', 'r', '.']):
|
|
||||||
|
|
||||||
|
def checkNumber(i):
|
||||||
|
if (i == '0'
|
||||||
|
or i == '1'
|
||||||
|
or i == '2'
|
||||||
|
or i == '3'
|
||||||
|
or i == '4'
|
||||||
|
or i == '5'
|
||||||
|
or i == '6'
|
||||||
|
or i == '7'
|
||||||
|
or i == '8'
|
||||||
|
or i == '9'):
|
||||||
|
return i
|
||||||
|
def openFile(fileName, ageArray = ['1', '9', None, None, ' ', 'r', '.']):
|
||||||
with open(fileName, "r", encoding="utf-8") as file:
|
with open(fileName, "r", encoding="utf-8") as file:
|
||||||
for row in file:
|
for row in file:
|
||||||
repCounter = 0
|
repCounter = 0
|
||||||
counter = 0
|
counter = 0
|
||||||
checkWord =[]
|
checkWord =[]
|
||||||
for i in row:
|
for i in row:
|
||||||
if i in ageArray[counter]:
|
if counter != 2 and counter !=3:
|
||||||
checkWord+=i
|
if i == ageArray[counter]:
|
||||||
counter +=1
|
checkWord+=i
|
||||||
if counter == 7:
|
counter +=1
|
||||||
repCounter+=1
|
else:
|
||||||
checkWord = []
|
checkWord = []
|
||||||
counter = 0
|
counter = 0
|
||||||
if repCounter == 1:
|
if counter == 7:
|
||||||
print(row.strip())
|
repCounter+=1
|
||||||
|
checkWord = []
|
||||||
|
counter = 0
|
||||||
|
if repCounter == 1:
|
||||||
|
print(row.strip())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
checkWord = []
|
if i==checkNumber(i):
|
||||||
counter = 0
|
checkWord+=i
|
||||||
|
counter+=1
|
||||||
|
else:
|
||||||
|
checkWord = []
|
||||||
|
counter = 0
|
||||||
|
|
||||||
print('---------------------SHAKESPEARE.EXP--------------------------------------')
|
print('---------------------SHAKESPEARE.EXP--------------------------------------')
|
||||||
openFile('polish_wiki_excerpt.exp')
|
openFile('polish_wiki_excerpt.exp')
|
||||||
|
Loading…
Reference in New Issue
Block a user