def _verb(self,ztype='A'): ### Returns a random verb '''Returns a random verb.''' zlist = [] znoun = self._noun('Z') if ztype == 'A': zlist += ['ponders','fishes','blows bubbles','scratches','fiddles','spends money','annotates', 'applauds','sequences %s' % self._noun('Z'),'curates a gene for %s' % self._noun('C'), 'cultivates %s' % self._noun('C'),'procrastinates','programs','poops', 'consumes a %s' % self._noun('of'),'bathes in %s' % self._noun('C'), 'cultivates %s' % self._noun('C'),'ponders %s' % self._noun('C'), 'fiddles with %s' % self._noun('C')] if ztype == 'A': zlist += ['%s %s' % (rje.randomList(['marvels at','bitchslaps','tickles','worships','cultivates'])[0],znoun)] if ztype == 'B': zlist = ['to press flowers','to hop on one leg','to pee into the wind','to suck on a lollipop','to dream', 'to love','to procrastinate','to gesticulate','to Wii','to spout %s' % self._noun('C'), 'to shatter %s' % self._noun('C'),'to play jenga with blocks of %s' % self._noun('C'), 'to frolic through fields of %s' % self._noun('C'), 'to eat bananas','to program','to get your freak on','to high-five a %s' % self._noun(), 'to bathe in %s' % self._noun('C'),'to poke %s' % self._noun('Z'), 'to sequence a %s genome' % self._noun(), 'to sample the %s' % self._noun('of'), 'to drink from the %s' % self._noun('of'), 'to attend a conference about %s' % self._noun('C')] for i in range(3): zlist += ['to %s %s' % (rje.randomList(['smile at','shove','squeeze','punch','slap','stroke','tickle','shake','cuddle','worship','cultivate','nibble','defenestrate','curse'])[0],znoun)] if ztype == 'C': zlist += ['Doing','Eating','Slapping','Spanking','Loving','Loving','Poking','Stroking','Rejecting', 'Embellishing','Polishing','Assembling','Curating','Annotating','Drinking','Consuming'] return rje.randomList(zlist)[0]
def _zenA(self): ### Generates Zen of the type 'The WISE MAN X BUT THE WWW XXX Y' '''Generates Zen of the type "The WISE MAN X BUT THE WWW XXX Y"''' if random.random() > 0.2: zen = [rje.randomList(['A','A','A','The','The','The','The','The'])[0], rje.randomList([self._adjective(),self._adverb()])[0], self._noun(), self._verb('A')] else: zen = ['The wise', self._noun(), self._verb('A')] if random.random() < 0.3: zen = zen[:-1] + self._suffix() + zen[-1:] if random.random() > 0.3: zen += [self._linker('A'), rje.randomList(['A','The'])[0].lower(), rje.randomList([self._adjective(),self._adverb()])[0], self._noun(), self._verb('A')] return zen
def _noun(self,ztype='A'): ### Returns a random noun '''Returns a random noun.''' nlist = ['annotator','ant', 'atheist', 'athelete','armadillo','assassin', 'badger', 'beetle', 'Bishop', 'boy', 'bushbaby', 'butterfly','cheerleader','billionaire','bilby', 'bull', 'cat','cheese', 'chemist','child','child','child', 'cloud', 'communist', 'computer scientist','Creationist', 'cow','chatbot','curator','Donald', 'diplomat', 'doctor', 'dragon', 'duck','elf', 'firefly', 'fish', 'fool', 'freak','fruit','fruitfly', 'fungus', 'girl', 'ghost', 'heretic','hound', 'jellyfish', 'kangaroo', 'knight', 'lady', 'ladybird', 'ladyboy','lion','kitten','kingfisher','king','killer', 'journalist', 'marsupial', 'mind', 'monkey', 'monster', 'mosquito', 'misogynist', 'nazi', 'philosopher', 'pig','pirate','postgrad', 'President','Professor','priest', 'prince', 'princess', 'programmer','python', 'queen', 'rabbit', 'Republican','runner', 'samurai', 'scientist', 'shrew', 'slug', 'snail', 'snake', 'soldier', 'spider', 'student', 'syntax error','smuggler', 'teapot', 'teenager', 'termite', 'theologian','theoretical physicist', 'Thespian','tiger','tiger snake', 'toddler', 'wallaby', 'warrior', 'wren','yeast','zealot','zombie','zulu'] + ['man'] * 8 + ['woman'] * 5 if ztype == 'C': nlist = ['misery','happiness','poverty','wisdom','enlightenment','zen','dreams','passion','lunacy','plenty', 'alternative facts','truth','ultimate truth', 'death','disease','discovery','Chaos','religion','peril','philosophy','the Soul','debuggery','youth'] if ztype == 'Z': return string.join([rje.randomList(['A','The'])[0].lower(),rje.randomList([self._adjective('A'),self._adverb('A'),''])[0], self._noun('A')]) if ztype == 'of' or (ztype in ['A','B'] and random.random() < 0.2): nlist = nlist + ['shroom','pie','wine','gravy','egg','chocolate','cheese','banana','stool','horn','custard', 'tea','teacup','mug','motif', 'gene','genome', 'bucket','bucket','bucket','genome assembly', 'kebab','fruit','falafel','teapot','transcriptome','vase', 'coffee','river','cake','cookie','sponge','abundance','repository','collection','library'] * 2 nlist += ['cgi-bin'] return string.join([rje.randomList(nlist)[0],'of',self._noun('C')]) return rje.randomList(nlist)[0]
def _zenE( self ): ### Generates Zen of the type 'He is a X1. She is a X2. Together, they fight crime!' '''Generates Zen of the type "The WISE MAN X BUT THE WWW XXX Y"''' zen = [ 'He is a', rje.randomList([self._adjective(), self._adverb()])[0], '%s.' % self._noun() ] if random.random > 0.5: zen[-1] = zen[-1][:-1] zen += self._suffix() zen[-1] += '.' zen += [ 'She is a', rje.randomList([self._adjective(), self._adverb()])[0], '%s.' % self._noun() ] if random.random > 0.5: zen[-1] = zen[-1][:-1] zen += self._suffix() zen[-1] += '.' zen += ['Together, they fight crime!'] return zen
def _zenD(self): ### Generates Zen of the type 'One man's X is another man's Y' '''One man's X is another man's Y.''' zen = ['One',rje.randomList([self._adjective(),''])[0], self._noun()] zen[-1] = '%s\'s' % zen[-1] zen.append(self._noun(rje.randomList(['A','C','C','of','of'])[0])) if random.random() < 0.99: zen += ['is another',zen[2]] else: zen += ['is','%s\'s' % self._noun('Z')] zen.append(self._noun(rje.randomList(['A','C','C','of','of'])[0])) return zen
def _zenB(self): ### Generates Zen of the type 'It is better to X when Y' '''Generates Zen of the type "It is better X when Y"''' zen = ['It is', self._adjective('B'), self._verb('B')] if random.random() > 0.5: zen += [ self._linker('B'), rje.randomList(['A', 'The'])[0].lower(), rje.randomList([self._adjective(), self._adverb()])[0], self._noun(), self._verb('A') ] return zen
def wisdom(self,wtype=None): ### Generates and returns a random Zen wisdom '''Generates and returns a random Zen wisdom''' try:### ~ Call the appropriate Zen Method ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### if type in ['A','B','C','D','E']: mytype = wtype else: if random.random() < self.getNum('FightCrime'): mytype = 'E' else: mytype = rje.randomList(['A'] * 8 + ['B'] * 10 + ['C'] * 5 + ['D'] * 1)[0] if mytype == 'A': zen = self._zenA() # Type A = 'The WISE MAN X BUT THE WWW XXX Y' if mytype == 'B': zen = self._zenB() # Type B = 'It is better to X when Y' if mytype == 'C': zen = self._zenC() # Type C = 'Doing X leads to Y' if mytype == 'D': zen = self._zenD() # Type D = 'One X1's Y1 is an X2's Y2' if mytype == 'E': zen = self._zenE() # Type E = 'He is a X1. She is a X2. Together, they fight crime!' ### ~ Tidy, join and return Zen as string ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### while '' in zen: zen.remove('') ## Try to improve by removing repetition ## zen = string.join(zen) if mytype not in ['D']: wordlist = [] for word in string.split(zen): if len(word) < 5: continue if word[:5].lower() in wordlist: return self.wisdom() else: wordlist.append(word[:5].lower()) for vowel in 'aeiou': zen = string.replace(zen,' a %s' % vowel,' an %s' % vowel) if zen.find('A %s' % vowel) == 0: zen = 'An %s' % zen[2:] return string.join(string.split(zen)) except: self.log.errorLog('Bad vibes from Zen.wisdom()')
def _adjective(self, ztype='A'): ### Returns a random adjective '''Returns a random adjective.''' alist = [ 'altruistic', 'benchmarking', 'better', 'bold', 'brave', 'cheesy', 'cocky', 'cowardly', 'crazy', 'coding', 'deadly', 'deceitful', 'degenerate', 'delicate', 'disillusioned', 'dynamic', 'existential', 'extraordinary', 'foolhardy', 'foolish', 'frantic', 'freaky', 'greedy', 'honest', 'kind', 'monastic', 'old', 'ordinary', 'passionate', 'pointless', 'prudent', 'quirky', 'quintessential', 'random', 'religious', 'RESTful', 'risky', 'running', 'scary', 'shrill', 'slippery', 'smooth', 'spiritual', 'semantic', 'stochastic', 'story-telling', 'superfluous', 'tasteless', 'unusual', 'usual', 'weird', 'wise', 'wise', 'young', 'zealous' ] + ['zen'] * 3 if ztype == 'A': alist += [ 'aerodynamic', 'aromatic', 'black', 'blue', 'Belgian', 'blessed', 'cantankerous', 'cancerous', 'cursed', 'drug-addled', 'elongated', 'ghostly', 'Greek', 'Herculian', 'illiterate', 'killer', 'kindred', 'opaque', 'orange', 'pale', 'pink', 'polymorphic', 'quality', 'shell-like', 'short', 'strong', 'stringy', 'spongy', 'secular', 'talented', 'tall', 'tiny', 'toxic', 'venomous', 'white', 'yellow', 'youthful', 'zombie' ] if ztype == 'B': alist += ['folly', 'worse', 'nonsense', 'death', 'risky'] return rje.randomList(alist)[0]
def _zenC(self): ### Generates Zen of the type 'Doing X leads to Y' '''Generates Zen of the type "Doing X leads to Y"''' zen = [ self._verb('C'), rje.randomList(['nothing', 'anything', self._noun('Z')])[0], self._linker('C'), self._noun('C') ] return zen
def _adverb(self, ztype='A'): ### Returns a random adverb '''Returns a random linker.''' zlist = [ 'procrastinating', 'exhausted', 'praying', 'scratching', 'annotating' ] zlist += [ 'whistling', 'spanking', 'spinning', 'talking', 'buzzing', 'drugged', 'skiing', 'walking' ] * 2 zlist += ['running', 'thinking', 'talking'] * 3 return rje.randomList(zlist)[0]
def _linker(self,ztype='A'): ### Returns a random linker '''Returns a random linker.''' zlist = [] if ztype in ['A','B']: zlist += ['while','if','unless','when','because'] if ztype == 'A': zlist += ['but'] #x#if ztype == 'B': zlist if ztype == 'C': zlist += ['leads to','leads to','shows','enlightens','enlightens','enriches','enriches', 'compresses', 'invigorates','invites','rains on','shatters','tweaks','destroys','disturbs', 'promotes','chastens','mocks','rejects','surprises','tests','unlocks','unravels', 'juggles'] return rje.randomList(zlist)[0]
def _suffix(self): ### Returns a random suffix '''Returns a random suffix''' slist = ['with a','from the'] nlist = ['future','future','outback','slums','past'] + [self._noun('of')] * 10 return rje.randomList(slist)[:1] + rje.randomList(nlist)[:1]