I'm trying to turn all N parts (...) into uppercase. I thought REGEX would be the most appropriate. But it is very difficult, nor capture the part N (...) to later convert it in capital letters I can:
My file:
muffled, muffled.A + H_PRE + pol = no + N_aps: fs muffled, muffled. A + H_PRE + pol = no + N_apple: fp muffled, .A + H_PRE + pol = no + N_abafado: ms muffled, muffled. A + H_PRE + pol = no + N_apple: mp damper, .A + H_PRE + pol = no: + N_afafante: 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)
Output:
Traceback (most recent call last):
File "test_lemme.py", line 14, in
upper_word = pattern.group (1)
AttributeError: 'list' object has no attribute 'group'
Desired output:
stuffy stuffy stuffy stuffy abafante
Then I thought of just making this list uppercase (using the (upper) method and then replacing it with the replace method.) So I would have:
muffled, muffled. A + H_PRE + pol = no + N_ABAFADO: fs
What do you guys think?