Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import string
- import random
- galt = open('galt.txt', 'r').readlines()
- output = open('output.txt', 'w')
- words = ["epsilon", "eps", "si", "sil", "lon", "silon", "epsil", "ep", "lo", "on", "plus", "plu", "pl", "us"]
- punctuation = re.compile(r"\W+")
- for line in galt:
- line = re.split(r'(\W+)', line) # this seems to fail if the parens are removed but, idk
- if line != ['', '\n', '']:
- line.pop()
- line[-1] = line[-1][0:len(line[-1]) - 2]
- temp_output = ""
- for word in line:
- if word == '':
- pass
- elif re.match(punctuation, word):
- temp_output += word
- elif word == "John" or word == "Galt":
- temp_output += word
- else:
- if word.islower():
- temp_output += random.choice(words)
- else:
- temp_output += random.choice(words).capitalize()
- if temp_output[-1] != '.':
- temp_output += '.'
- if temp_output[0] == '“':
- temp_output += '“'
- temp_output += '\n\n'
- output.write(temp_output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement