Created
September 22, 2015 16:01
-
-
Save joemarchese/324e1be8e25891f6cb84 to your computer and use it in GitHub Desktop.
A small program for working a good amount of tasteless dirty language into a text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random as r | |
| dirty_words = [] | |
| with open('dirtywords.txt', encoding='utf-8') as dw: | |
| for phrase in dw: | |
| dirty_words.append(phrase.strip()) | |
| output = open('output.txt', 'w') | |
| with open('source.txt', 'r', encoding='utf-8') as f: | |
| for line in f: | |
| for word in line.split(): | |
| if line.index(word) % r.randint(1, 5) == 0: | |
| line = line.replace(word, r.choice(dirty_words)) | |
| output.write(line) | |
| output.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment