import re
file1 = open('/Users/sevi/Desktop/change.txt')
a = file1.readlines()
s = str(a)
s = re.sub(' so ', '. So, ', s)
print(s)
This code reads an all lowercase .txt file and changes every ' so ' with ' . So, '
However, I want this based on the nature of the word that comes next. In other words, I want this re.sub function not be applied when the ' so ' comes before a list of adjectives I have as a .rtf file.
For example, "so I changed my mind" will be "So, I changed my mind" But, "it was so fun" will be left untouched because fun is included in the list of words.
How can I make this possible?
Thanks!