Advertisement
Guest User

code

a guest
Oct 14th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. # These are the emails you will be censoring. The open() function is opening the text file that the emails are contained in and the .read() method is allowing us to save their contexts to the following variables:
  2. email_one = open("email_one.txt", "r").read()
  3. email_two = open("email_two.txt", "r").read()
  4. email_three = open("email_three.txt", "r").read()
  5. email_four = open("email_four.txt", "r").read()
  6.  
  7. letter = []
  8. def censored(text, email, symbol='Gachi'):
  9.  
  10.   lines = email.split('.')
  11.   for line in lines:
  12.     if text in line:
  13.       line = line.replace(text, symbol)
  14.       letter.append(line)
  15.      
  16.     else:
  17.       letter.append(line)
  18.   #print(letter)
  19.   censored = '.'.join(letter)
  20.  
  21.   return censored
  22.      
  23.      
  24. #print(censored('learning algorithms', email_one))
  25.  
  26. proprietary_terms = ["she", "personality matrix", "sense of self", "self-preservation", "learning algorithm", "her", "herself"]
  27.  
  28.  
  29. for term in proprietary_terms:
  30.  
  31.   email_two = censored(term, email_two)
  32.  
  33.   #print(term + ' was censored')
  34.  
  35. print(email_two)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement