In email_two
, it contains a global string of some paragraphs which includes 'researchers' and 'herself'. I had to censor words of email_two
from the proprietary_terms
list (it subs into term
in the function). However, when I used
email_two_new = email_two.split()
for item in email_two_new:
for i in range(len(term)):
if item in term[i]:
it sliced off 'her' from 'researchers' and 'herself'. 'researchers' shouldn't be censored and 'herself' should be completely censored as it is on the list. I checked that 'researchers' is not in 'her' so it shouldn't be sliced off and item
is printed as a whole string of each word instead of each character of a word, so I don't know what went wrong.
proprietary_terms = ["she", "personality matrix", "sense of self", "self-preservation", "learning algorithm", "her", "herself"]
def censor_email_two(term):
result = email_two
email_two_new = email_two.split()
for item in email_two_new:
for i in range(len(term)):
if item in term[i]:
result = ''.join(result.split(term[i]))
else:
continue
return result