forked from miczar1/djfz-24_25
D5 works for simple
This commit is contained in:
parent
639d5f9356
commit
077f7fa966
25
TaskD05/taskD5.py
Normal file
25
TaskD05/taskD5.py
Normal file
@ -0,0 +1,25 @@
|
||||
import re
|
||||
|
||||
final = []
|
||||
|
||||
with open('simple.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 f"{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')
|
Loading…
Reference in New Issue
Block a user