import sys import re import random import operator lines = list() words = dict() words2 = set() wordsTemp = list() wordsNull = set() whole_text = "" lesswords = set() # if __name__ == "__main__": # f = open("dict.txt",'a') for line in open("useablewords2_ATF.txt"): line = line.strip() line = line.lower() line_words = line.split(" ") for word in line_words: if len(word) > 4: if word in words: words[word] += 1 else: words[word] = 1 for word in words: if words[word] > 50: lesswords.add(word) for word in lesswords: words2.add(word) for word in words2: if "-" in word or "_" in word or ".." in word or "'" in word or "<" in word or ":" in word or "." in word or "=" in word or ">" in word or "/" in word or "~" in word or "&" in word or "=" in word or "#" in word or "@" in word or "*" in word or ";" in word or "+" in word or len(word) > 30 or len(word) < 4: wordsNull.add(word) for word in wordsNull: words2.remove(word) for word in words2: wordsTemp.append(word) listwords = list(wordsTemp) print random.choice(listwords) + " on " + random.choice(listwords) + " and " + random.choice(listwords) + " on " + random.choice(listwords) print "bright copper " + random.choice(listwords) + " and warm woolen " + random.choice(listwords) print "Brown paper " + random.choice(listwords) + " tied up with strings" print "These are a few of ITP's favorite things" print "" print "Cream colored " + random.choice(listwords) + " and crisp " +random.choice(listwords) + " streudels" print random.choice(listwords) + " " + random.choice(listwords) + " and " + random.choice(listwords) + " with noodles" print "Wild geese that fly with " + random.choice(listwords) + " on their wings" print "These are a few of ITP's favorite things" print "" print random.choice(listwords) + " in white " + random.choice(listwords) + " with blue " + random.choice(listwords) + " sashes" print random.choice(listwords) + " that stay on my " + random.choice(listwords) + " and eyelashes" print "Silver white " + random.choice(listwords) + " that melt into springs" print "These are a few of ITP's favorite things" print "" print "When the " + random.choice(listwords) + " bites" print "When the " + random.choice(listwords) + " stings" print "When I'm feeling sad" print "I simply remember ITP's favorite things" print "And then I don't feel so bad" print "" print "" print "" print random.choice(listwords) + " on " + random.choice(listwords) + " and " + random.choice(listwords) + " on " + random.choice(listwords) print "bright copper " + random.choice(listwords) + " and warm woolen " + random.choice(listwords) print "Brown paper " + random.choice(listwords) + " tied up with strings" print "These are a few of ITP's favorite things" print "" print "Cream colored " + random.choice(listwords) + " and crisp " +random.choice(listwords) + " streudels" print random.choice(listwords) + " " + random.choice(listwords) + " and " + random.choice(listwords) + " with noodles" print "Wild geese that fly with " + random.choice(listwords) + " on their wings" print "These are a few of ITP's favorite things" print "" print random.choice(listwords) + " in white " + random.choice(listwords) + " with blue " + random.choice(listwords) + " sashes" print random.choice(listwords) + " that stay on my " + random.choice(listwords) + " and eyelashes" print "Silver white " + random.choice(listwords) + " that melt into springs" print "These are a few of ITP's favorite things" print "" print "When the " + random.choice(listwords) + " bites" print "When the " + random.choice(listwords) + " stings" print "When I'm feeling sad" print "I simply remember ITP's favorite things" print "And then I don't feel so bad" print "" print "" print "" print random.choice(listwords) + " on " + random.choice(listwords) + " and " + random.choice(listwords) + " on " + random.choice(listwords) print "bright copper " + random.choice(listwords) + " and warm woolen " + random.choice(listwords) print "Brown paper " + random.choice(listwords) + " tied up with strings" print "These are a few of ITP's favorite things" print "" print "Cream colored " + random.choice(listwords) + " and crisp " +random.choice(listwords) + " streudels" print random.choice(listwords) + " " + random.choice(listwords) + " and " + random.choice(listwords) + " with noodles" print "Wild geese that fly with " + random.choice(listwords) + " on their wings" print "These are a few of ITP's favorite things" print "" print random.choice(listwords) + " in white " + random.choice(listwords) + " with blue " + random.choice(listwords) + " sashes" print random.choice(listwords) + " that stay on my " + random.choice(listwords) + " and eyelashes" print "Silver white " + random.choice(listwords) + " that melt into springs" print "These are a few of ITP's favorite things" print "" print "When the " + random.choice(listwords) + " bites" print "When the " + random.choice(listwords) + " stings" print "When I'm feeling sad" print "I simply remember ITP's favorite things" print "And then I don't feel so bad" print "" print "" print "" print random.choice(listwords) + " on " + random.choice(listwords) + " and " + random.choice(listwords) + " on " + random.choice(listwords) print "bright copper " + random.choice(listwords) + " and warm woolen " + random.choice(listwords) print "Brown paper " + random.choice(listwords) + " tied up with strings" print "These are a few of ITP's favorite things" print "" print "Cream colored " + random.choice(listwords) + " and crisp " +random.choice(listwords) + " streudels" print random.choice(listwords) + " " + random.choice(listwords) + " and " + random.choice(listwords) + " with noodles" print "Wild geese that fly with " + random.choice(listwords) + " on their wings" print "These are a few of ITP's favorite things" print "" print random.choice(listwords) + " in white " + random.choice(listwords) + " with blue " + random.choice(listwords) + " sashes" print random.choice(listwords) + " that stay on my " + random.choice(listwords) + " and eyelashes" print "Silver white " + random.choice(listwords) + " that melt into springs" print "These are a few of ITP's favorite things" print "" print "When the " + random.choice(listwords) + " bites" print "When the " + random.choice(listwords) + " stings" print "When I'm feeling sad" print "I simply remember ITP's favorite things" print "And then I don't feel so bad" print "" print "" print ""