This commit is contained in:
Adam 2020-12-06 15:18:14 +01:00
parent 7e2f648575
commit f7e178e42a
3 changed files with 27 additions and 4 deletions

View File

@ -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')

View File

@ -1,3 +1,3 @@
ala mA KOTa
lallaa
żUK
żUK

View File

@ -1,4 +1,3 @@
ala Ma kotA
Żuk
lallaa
Żuk