Skip to content

Instantly share code, notes, and snippets.

@Irene-123
Created December 23, 2020 13:16
Show Gist options
  • Save Irene-123/e99eafe6b41dc11928b4b042e3f93a9f to your computer and use it in GitHub Desktop.
Save Irene-123/e99eafe6b41dc11928b4b042e3f93a9f to your computer and use it in GitHub Desktop.
ATBS2
#!usr/bin/python3
import re
file=open('mad.txt')
text=file.read()
file.close()
regex=re.compile(r'(NOUN) | (ADJECTIVE) | (VERB)')
for i in regex.findall(text):
for j in i:
if j!='':
reg=re.compile(r'{}'.format(j))
inp=input('Enter the substitute for %s: ' %j)
text=reg.sub(inp,text,1)
print(text)
file=open('mad.txt','w')
file.write(text)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment