53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
|
|
import sys
|
|
|
|
def checkNumber(letter):
|
|
if (letter == '0'
|
|
or letter == '1'
|
|
or letter == '2'
|
|
or letter == '3'
|
|
or letter == '4'
|
|
or letter == '5'
|
|
or letter == '6'
|
|
or letter == '7'
|
|
or letter == '8'
|
|
or letter == '9'):
|
|
return letter
|
|
else:
|
|
return None
|
|
def openFile(fileName):
|
|
with open(fileName, "r", encoding="utf-8") as file:
|
|
for row in file:
|
|
lastCharacter = ''
|
|
checkWord =''
|
|
allLine = ''
|
|
|
|
for letter in row:
|
|
if checkWord != '':
|
|
if letter == checkNumber(letter):
|
|
checkWord += letter
|
|
else:
|
|
allLine += checkWord
|
|
allLine += ' '
|
|
checkWord = ''
|
|
else:
|
|
if letter == checkNumber(letter):
|
|
checkWord += letter
|
|
|
|
if letter == '\n':
|
|
if allLine != '':
|
|
print(allLine)
|
|
allLine = ''
|
|
|
|
|
|
|
|
|
|
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')
|