This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

jibbajabba.py 1.0

By: WayGroovy on Jun 3rd, 2012  |  syntax: Python  |  size: 1.50 KB  |  views: 49  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #/usr/bin/env python
  2.  
  3. import random
  4. import sys
  5. import markovgen
  6. import string
  7. import os
  8. from time import sleep
  9.  
  10. vowels = ['a', 'e', 'i', 'o', 'u']
  11. consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']
  12.  
  13. def _vowel():
  14.     return random.choice(vowels)
  15.  
  16. def _consonant():
  17.     return random.choice(consonants)
  18.  
  19. def _cv():
  20.     return _consonant() + _vowel()
  21.  
  22. def _cvc():
  23.     return _cv() + _consonant()
  24.  
  25. def _syllable():
  26.     return random.choice([_vowel, _cv, _cvc])()
  27.  
  28. def create_fake_word():
  29.     syllables = []
  30.     for x in range(random.randint(2,3)):
  31.         syllables.append(_syllable())
  32.     return ''.join(syllables)
  33.  
  34. def is_punct_char(char):
  35.     return char in string.punctuation
  36.  
  37. def is_not_punct_char(char):
  38.     return not is_punct_char(char)
  39.  
  40. sleep(random.randint(10,60))
  41.  
  42. n = 20
  43.  
  44. counter = 1
  45.  
  46. while counter <= n :
  47.   file_ = open('/home/minecraft/McMyAdmin2/Exec/jeeves.txt')
  48. # from http://agiliq.com/blog/2009/06/generating-pseudo-random-text-with-markov-chains-u/
  49.   markov = markovgen.Markov(file_)
  50.   sentence = markov.generate_markov_text().capitalize().replace("\"","\\\'")
  51.   senlen = len(sentence)
  52.   if is_not_punct_char(sentence[senlen - 1]) :
  53.     sentence += '.'
  54.   command_sayrandom = "screen -S McMyAdmin -p 0 -X stuff \"$(printf \"say "
  55.   command_sayrandom += sentence
  56.   command_sayrandom += " \\r\\n\")\""
  57.   os.system(command_sayrandom)
  58.   counter += 1
  59.   sleep (random.randint(10,120))
  60.  
  61. print "done"
clone this paste RAW Paste Data