Guest User

Untitled

a guest
Dec 5th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.05 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Daniel Drucker
  3. from random import random,choice
  4. import twitter
  5.  
  6.  
  7. # transitions:
  8. #
  9. # prefixes_is -> ada_is [ -> "and" ada_is ]* ["at the same time"]
  10. # prefixes_has -> ada_has [ -> "and" ada_has ]*
  11. # prefixes_is -> actions [->]
  12. # "look at you, being" -> ada_is
  13.  
  14. def speak():
  15.     ''' produce an ada-mew utterance '''
  16.    
  17.     say = {}
  18.     say[('is','prefix')] = ["who's",
  19.                    "she's",
  20.                    "ada mew's",
  21.                    "are you",
  22.     ]
  23.     say[('is','suffix')] = ["a kitty",
  24.               "a mew",
  25.               "a girl",
  26.               "a pretty girl",
  27.               "an ada mew",
  28.               "a cat",
  29.               "a muffin mew",
  30.               "a pumpkin mew",
  31.               "on the bed",
  32.     ]
  33.     say[('has','suffix')] = ["a tail",
  34.                "a face",
  35.                "a nose",
  36.                "ears",
  37.                "fur",
  38.                "a belly",
  39.                "whiskers",
  40.                "a chin",
  41.     ]
  42.     say[('has','prefix')] = ["who has",
  43.                     "who's got",
  44.                     "she has",
  45.                     "she's got",
  46.                     "ada mew has",
  47.                     "ada mew's got",
  48.     ]
  49.    
  50.     say['action'] = ["looking",
  51.                "sitting",
  52.                "loafing",
  53.                "leeking",
  54.     ]
  55.     catted = False
  56.     ishas = choice(('is','has'))
  57.     startwith = choice(say[(ishas,'prefix')])
  58.    
  59.     endwith = choice(say[(ishas,'suffix')])
  60.     say[(ishas,'suffix')].remove(endwith)
  61.  
  62.     while random() < .45:
  63.         catted = True
  64.         nextwith = choice(say[(ishas,'suffix')])
  65.         say[(ishas,'suffix')].remove(nextwith)
  66.         endwith += " and " + nextwith
  67.    
  68.     if random() < .30 and catted:
  69.         endwith += " at the same time"
  70.    
  71.     return startwith + " " + endwith
  72.  
  73. if __name__ == "__main__":
  74.     adatwit = ""
  75.     while len(adatwit) == 0 or len(adatwit) > 140:
  76.         adatwit = speak()
  77.     api = twitter.Api(username='adamewsakitty',password='n2sxxx')
  78.     status = api.PostUpdate(adatwit)
Add Comment
Please, Sign In to add comment