Skip to content

Instantly share code, notes, and snippets.

@joemarchese
Created September 22, 2015 16:01
Show Gist options
  • Select an option

  • Save joemarchese/324e1be8e25891f6cb84 to your computer and use it in GitHub Desktop.

Select an option

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.
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