forked from miczar1/djfz-24_25
D1 doesnt work properly
This commit is contained in:
parent
2045b4eb99
commit
3da2b5d83d
@ -1,6 +1,8 @@
|
||||
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()
|
||||
@ -15,14 +17,30 @@ with open('polish_wiki_excerpt.in', encoding='utf8') as file:
|
||||
for words in x:
|
||||
if words[0] != '':
|
||||
to_replace = words[0]
|
||||
new_word = to_replace.swapcase()
|
||||
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 = to_replace.swapcase()
|
||||
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')
|
||||
file.write(line + '\n')
|
||||
|
||||
### odpowiedź nie do końca pokrywa się z plikiem .exp w wyniku obecności znaków z niemieckiego alfabetu
|
@ -1,7 +1,7 @@
|
||||
with open("./TaskD05/polish_wiki_excerpt.out", 'r', encoding='utf8') as f:
|
||||
with open("./TaskD01/polish_wiki_excerpt.out", 'r', encoding='utf8') as f:
|
||||
lines1 = f.readlines()
|
||||
|
||||
with open("./TaskD05/polish_wiki_excerpt.exp", 'r', encoding='utf8') as f:
|
||||
with open("./TaskD01/polish_wiki_excerpt.exp", 'r', encoding='utf8') as f:
|
||||
lines2 = f.readlines()
|
||||
|
||||
i = 1
|
||||
|
Loading…
Reference in New Issue
Block a user