Skip to content

Instantly share code, notes, and snippets.

@marsimaria
Created May 15, 2015 16:58
Show Gist options
  • Save marsimaria/99bfe81b24e80bede810 to your computer and use it in GitHub Desktop.
Save marsimaria/99bfe81b24e80bede810 to your computer and use it in GitHub Desktop.
On "How to be a Lady" By Britney Spears
from textblob import TextBlob
import random
import re
# Lady02 Text1
lady = list()
# Lady01 Text1
search = r'\b(?:[Ww]ell-bred|[Ii]ll-bred|lady-like|unlady-like|lady)\b [A-Za-z ]+'
# search = r'\b(?:[Ii]f you|[Ii]f they|[Ii]f it)\b [A-Za-z ]+'
for sentence in open('LadiesEtiquette.txt'):
lines = sentence.split('.')
for line in lines:
ladyr = re.findall(search, line)
if len(ladyr) > 0:
lady.append(ladyr)
# print ladyr
britney = list()
# search = r'\b(?:[Yy]ou)\b [A-Za-z ]+'
for sentence in open('britney.txt'):
lines = sentence.split('.')
for line in lines:
# britr = re.findall(search, line)
if len(lines) > 0:
britney.append(lines)
# print lines
ladytext = list()
for j in lady:
str1 = ''.join(j)
# str1.split(' ') puts str back in list so each word is an item to be checked, or else it checks by alphabet
if len(str1.split(' ')) > 5:
ladytext.append(str1)
# print ladytext
britneytext = list()
for j in britney:
str2 = ''.join(j)
str2 = str2.replace('I ', 'they ')
str2 = str2.replace("I\'m", "they\'re")
# str2 = str2.replace("i ", 'they ')
str2 = str2.replace("I\'ve", "you\'ve")
str2 = str2.replace(' we ', ' you ')
str2 = str2.replace(' me', ' them ')
str2 = str2.replace(' my ', ' their ')
if len(str2.split(' ')) > 4:
britneytext.append(str2)
# print britneytext
# connect = ['and ', 'so ']
for i in range(1, 11):
first = random.choice(ladytext)
second = random.choice(britneytext).lower()
# bridge = random.choice(connect)
if 'lady-like to' in first:
print 'Advice ' + str(i) + ". " + 'It is ' + first + ', ' + second
elif 'unlady-like to' in first:
print 'Advice ' + str(i) + ". " + 'It is ' + first + ', ' + second
elif 'unlady-like' in first:
print "Advice " + str(i) + ". " + 'An ' + first + ', ' + second
elif 'ill-bred to' in first:
print "Advice " + str(i) + ". " + 'It is ' + first + ', ' + second
elif 'ill-bred' in first:
print "Advice " + str(i) + ". " + 'An ' + first + ', ' + second
else:
print "Advice " + str(i) + ". " + 'A ' + first + ', ' + second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment