1
I am trying to turn all parts N_(...) into uppercase. I thought REGEX would be the most appropriate. It’s just too hard to even capture the N_(...) part and then turn it into capital letters I can do it myself:
My file:
stuffy, stuffy. A+H_PRE+pol=no+N_stuffy:Fs stuffy, stuffy. A+H_PRE+pol=no+N_stuffy:Fp stuffy,. A+H_PRE+pol=no+N_stuffy:ms muffled, muffled. A+H_PRE+pol=no+N_muffled:mp abafante,. A+H_PRE+pol=no:+N_abafante:ms
Script:
import re
with open("word_upper.txt", "r") as f:
text = f.read()
pattern = re.findall(r'N_(\w+)', text)
upper_word = pattern.group(1)
print(upper_word)
Exit:
Traceback (Most recent call last):
File "teste_lemme.py", line 14, in
upper_word = Pattern.group(1)
Attributeerror: 'list' Object has no attribute 'group'
Desired exit:
stuffy stuffy stuffy stuffy abaphant
Then I thought about just turning this list into uppercase (using the (upper) method and then replacing with the replace method. So I would have:
muffled, muffled. A+H_PRE+pol=no+N_ABAFADO:Fs
What do you think?