d01
This commit is contained in:
parent
7e2f648575
commit
f7e178e42a
@ -10,5 +10,29 @@ def repl(char):
|
||||
output_str += c
|
||||
return output_str
|
||||
|
||||
|
||||
pattern = re.compile(r"\b[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻ]+\b|\b[A-ZĄĆĘŁŃÓŚŹŻ]+[a-ząćęłńóśźż]+\b")
|
||||
# f = open("polish_wiki_excerpt.in", "r")
|
||||
|
||||
|
||||
def change_line(word_list, curr_line):
|
||||
for word in word_list:
|
||||
curr_line = curr_line.replace(word, word.swapcase())
|
||||
|
||||
return curr_line
|
||||
|
||||
|
||||
# for line in open("./polish_wiki_excerpt.in", "r"):
|
||||
for line in sys.stdin:
|
||||
print(re.sub(r'\b[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻ]+\b|\b[A-ZĄĆĘŁŃÓŚŹŻ]+[a-ząćęłńóśźż]+\b', repl, line).rstrip('\n'))
|
||||
found_words = re.findall(pattern, line)
|
||||
out = change_line(found_words, line)
|
||||
print(out).rstrip('\n')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
ala mA KOTa
|
||||
lallaa
|
||||
żUK
|
||||
żUK
|
@ -1,4 +1,3 @@
|
||||
ala Ma kotA
|
||||
Żuk
|
||||
lallaa
|
||||
|
||||
Żuk
|
Loading…
Reference in New Issue
Block a user