to being However,
However, plans or
abate. a Mixed Episode
every a Major Depressive Episode
mood to these guilt or are However,
during However, mild However, toxin or Moreover,
be one’s predict
predict these lowed
unless an irreversible dementia
often a Major Depressive Episode
wish of prior fully lowed are predict
review predict self predict being lowed predict
an other failure
failure aches high
return an irreversible dementia
often an increased appetite
this to areas sense high For failure
sales. failure When failure every high feature
or these objects
objects least to
sleep, a Mixed Episode
fully a Major Depressive Episode
they to there begin to and objects
plays, objects Less objects aches to defects
an there frustrated.
frustrated. guilt is
plans, an irreversible dementia
fully an increased appetite
also as child down is for frustrated.
think, frustrated. than frustrated. night is frustrated.
of chief pauses
pauses often has
better a week period
pains a general medical condition
less or Other deny, has the pauses
always pauses with pauses there has focuses
do often treated,
treated, bowel signs
sweets an irreversible dementia
sleep a Major Depressive Episode
from of which toxin signs the treated,
sales. treated, from treated, weeks signs depressed,
of worst grades
grades other and
unless a week thought
there an increased appetite
have by would twice and the grades
asleep grades than grades these and includes
be least easily
easily early in
better a Mixed Episode
worst an increased appetite
eat. of there these in and easily
having easily have easily would in Family
be manic concentration.
concentration. there to
sales. a week period
Those a Major Depressive Episode
than a myocardial infarction signs to the concentration.
memory concentration. used concentration. these to exertion.
at count sadness.
sadness. often not
before an irreversible dementia
plans an increased appetite
when a week thought these not for sadness.
rather sadness. away sadness. count not muteness.
by Those infarction,
infarction, Those abuse
dumps” a week period
signs a Major Depressive Episode
sick a week thought there abuse and infarction,
cases, infarction, that infarction, quite abuse definition,
or often interpersonal
interpersonal looks or
middle a week thought
toxin an increased appetite
they a week period bowel or and interpersonal
dearly interpersonal with interpersonal one’s or terminal
to least infarction,
infarction, night one
person a Mixed Episode
drawn a Major Depressive Episode
gain a myocardial infarction seeks one for infarction,
toward infarction, food infarction, looks one direction,
or “down negative
negative fully often
during an irreversible dementia
there a general medical condition
most a Mixed Episode quite often the negative
waking negative some negative often often subjective
be other pauses
pauses often be
person a week thought
loved a general medical condition
with a week period guilt be the pauses
sweets pauses face pauses night be excuses
no other pains
pains being week
nearly a Mixed Episode
worst a Major Depressive Episode
have an irreversible dementia areas week for pains
sales. pains mood pains skin, week gains
in sense Frequently
Frequently fully four
become a week thought
sense a Major Depressive Episode
Some a myocardial infarction often four the Frequently
return Frequently mild Frequently which four subsequently
an about symptoms
symptoms there eat.
unable a myocardial infarction
deny, an increased appetite
must a Mixed Episode angry eat. The symptoms
before symptoms they symptoms tasks eat. symptoms
Yes, Barney has taken a turn to the worst, now he’s using general expressions to express his depressions, there are three different dictionaries, one is general, the other is set to match the 3 last characters of the word for rhyming sake, the last, is a dictionary of sentences beginning with the letter a, to match the following diagram.
I love you
You love me
we’re a happy family
with a great big hug
and a kiss from me to you
won’t you say you love me too
3 Words, 1 You, 1 Love
3 Words, 1 You, 1 Love, 1 Me
4 Words, one We
5 Words, with a
6 Words, with a
7 Words, __ you ___, you love me too [rhymes with you]
w(z) w(any) w(x)
w(x) w(z) w(y)
w(any) w(a any*2)
with w(a any*3)
and w(a any*2) w(y) to w(x)
won’t w(x) w(any) w(x) w(z) w(y) too-([-3:] of w(y))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | import sys # builds dictionary from source text, and replaces words from a different text which start with the same letter import random import re # use regular expressions source_alpha = dict() # dictionary of all words in first text source_endings = dict() # dictionary of all words ending with same 3 letters source_a = dict() # dictionary of all strings beginning with the letter a source_file = sys.argv[1] # first argument passed on command line, sys.argv[0] will be the name of the script file ignoreList = ["),", ").", "Major", "major", "(", "AS).", "A3).", "A9).", "(e.g.,", "E).", "(i.e.,"] ignoreIndex = int() ignoreIndex = 0 # create a dictionary of words from the text # read each line from source file; split each line into words; store each # word in the source_alpha dictionary, according to which letter it starts with for line in open(source_file): # reading lines from major_dep.txt line = line.strip() words = line.split(" ") for word in words: # loops through each of the words if len(word) > 0: # check to make sure we have a large word lengthWord = len(word) # get first letter of word # if we've already seen this number, append to list if lengthWord in source_alpha: source_alpha[lengthWord].append(word) # append word to the value of that number else: # looks like {'3':['the','big']...} source_alpha[lengthWord] = [word] # specify that a new list is made for key in source_alpha: # go through each key in the dict if key > 0: for regect in ignoreList: # for each word in regects for item in source_alpha[key]: # itirate through members of list if regect == item: # if word in list is a regect # print regect + ' before ' + str(source_alpha[key]) source_alpha[key].pop(source_alpha[key].index(regect)) #pop it out of the list # print regect + ' after ' + str(source_alpha[key]) #print source_alpha # source_alpha will be a dictionary whose keys are strings and whose values # are lists. # uncomment this to see what the data structure created above looks like #print source_alpha # source_endings will have values of words that share the same 3 last charecters for line in open(source_file): # reading lines from major_dep.txt line = line.strip() words = line.split(" ") for word in words: # loops through each of the words if len(word) > 4: # check to make sure we have a large word if (word != "major"): ending = word[-3:] # get the last 3 letters # if we've already seen this number, append to list if ending in source_endings: if word in source_endings[ending]: ignore = "true" else: source_endings[ending].append(word) # append word to the value of that number else: # looks like {'ing':['thing','biging']...} source_endings[ending] = [word] # specify that a new list is made # print source_endings # source_a will have values of strings begining with the letter a for line in open(source_file): # reading lines from major_dep.txt line = line.strip() for match_obj in re.finditer(r"(\b[Aa]\b|\b[Aa]n\b) (.{2,})(\.)", line): a_something1 = match_obj.group(1) # loops through each of the words a_something2 = match_obj.group(2) # loops through each of the words words = a_something2.split(" ") num_words = len(words) # print a_something1 +" "+ a_something2 # print num_words if num_words > 1: # check to make sure we have a large word a_len = len(words) # get the last 3 letters # if we've already seen this number, append to list if a_len in source_a: if a_something2 in source_a[a_len]: ignore = "true" else: source_a[a_len].append(a_something1+" "+a_something2) # append word to the value of that number else: # looks like {'ing':['thing','biging']...} source_a[a_len] = [a_something1+" "+a_something2] # specify that a new list is made # print source_a # read each line from standard input; split line into words; for each word, # get a random word beginning with the same letter from source_alpha replace_1 = source_endings[random.choice( source_endings.keys())] # how do I delete keys with too little values? replace_you = random.choice(replace_1) replace_2 = source_alpha[random.randrange(2,6)] replace_me = random.choice(replace_2) replace_3 = source_alpha[random.randrange(4,8)] replace_love = random.choice(replace_3) # read each line from standard input; split line into words; for each word, # get a random word beginning with the same letter from source_alpha for line in sys.stdin: line = line.strip() line = re.sub(r"\b[Aa] h.{2,}", "xxx", line) line = re.sub(r"\b[Aa] kiss", "kiss", line) line = re.sub(r"\b[Aa] g.{2,}", "yyy", line) words = line.split(" ") output = "" for word in words: if len(word) > 0: lengthWord = len(word) if lengthWord in source_alpha: if lengthWord > 0: source_words = source_alpha[lengthWord+1] if re.search(r"[yY]ou", word): output += replace_you elif re.search(r"[mM]e", word): output += replace_me elif re.search(r"t\w\w\b", word): rhyme = random.choice(replace_1) # make sure it's different than replace_you output += rhyme elif re.search(r"xxx", word): source_words2 = source_a[2] output += random.choice(source_words2) elif re.search(r"kiss", word): source_words2 = source_a[2] output += random.choice(source_words2) elif re.search(r"yyy", word): source_words3 = source_a[3] output += random.choice(source_words3) else: output += random.choice(source_words) else: output += word output += " " print output |