Feb 5, 2009

For the curious…

Here are some interesting snippets from the code behind Auto-Meme. (It’s all Python.)

# random element from list/tuple/string
randel = lambda x: x[randint(0, len(x)-1)]
patterns = [
    ( 'im in ur {1}, {2} ur {3}', ('noun','noun1'), 'verb4', 'noun1' ),
    ( 'how do i {1} {2}?', 'verb2', ('noun', '~web', 'name') ),
    ( '{1} {2} {3}', 'name', ('~kills', 'verb1'), ('name', '~Dumbledore') ),
    ( 'All your {1} are belong to {2}', 'noun1', ('~us', 'noun', 'name') ),
    ( '{1a} is {2} too', ('noun', 'noun', ['name', no_article]), ('~fine', 'adj') ),
    ( "{1} don't know about my {2}", ('~bitches', 'noun1'), ('noun', 'noun1') ),
    . . .
]
spengbab = lambda: randel(\
        ['Spange','Speng','Sporg','Splorg',
        'Spernd','Splort','Spunk','Scram','Spange','Speeng',
        'Splen','Spengj','Spinge']\
        ) + randel(\
        ['bob','bob','bob','bab','bab','beb','blat','berp','bharb',
        'blar','borg'])
sqarpents = lambda: randel(\
        ['Sqar','Skur','Sven','Squat','Spleen','Snare','Sklabh',
        'Squere','Dildo']\
        ) + randel(\
        ['pents','ponce','porks','peeps','pops','pans','pints',
        'ponts'])
About
The official Auto-Meme blog. Subscribe via RSS.