示例#1
0
 def testTwitterMarkovModel(self, *_):
     tm = TwitterMarkov('example_screen_name',
                        self.corpus,
                        config=self.configfile,
                        dry_run=True,
                        learn=False)
     assert isinstance(tm.models['tweets.txt'], markovify.text.Text)
示例#2
0
 def testTwitterMarkovListCorpus(self):
     tm = TwitterMarkov('example_screen_name', [self.corpus],
                        config=self.configfile,
                        dry_run=True,
                        learn=False)
     assert isinstance(tm, TwitterMarkov)
     del tm
示例#3
0
 def testTwitterMarkovConfigCorpus(self):
     tm = TwitterMarkov('example_screen_name',
                        config=self.configfile,
                        dry_run=True,
                        learn=False)
     tm.log.setLevel(100)
     del tm
    def setUp(self, _):
        self.corpus = path.join(path.dirname(__file__), 'data', 'tweets.txt')
        self.configfile = path.join(path.dirname(__file__), '..', 'bots.yaml')

        self.tm = TwitterMarkov('example_screen_name', [self.corpus], config=self.configfile,
                                dry_run=True, learn=False)

        self.tm.log.setLevel(100)
示例#5
0
 def testCheck(self):
     tm = TwitterMarkov('example_screen_name', [self.corpus],
                        config=self.configfile,
                        dry_run=True,
                        learn=False)
     self.assertFalse(tm.check_tweet('😀' * 141))
     self.assertFalse(tm.check_tweet(''))
     self.assertFalse(tm.check_tweet('contains the blacklisted word t**s'))
示例#6
0
    def testTwitterMarkovAttribs(self):
        tm = TwitterMarkov('example_screen_name',
                           self.corpus,
                           config=self.configfile,
                           dry_run=True,
                           learn=False)
        tm.log.setLevel(100)

        assert isinstance(tm, TwitterMarkov)

        assert hasattr(tm, 'screen_name')
        assert hasattr(tm, 'api')
        assert hasattr(tm, 'config')
        assert hasattr(tm, 'wordfilter')
        del tm
示例#7
0
            state_sz = max(2, state_sz - 3)
        else:
            if (probability > 0.7):
                state_sz = max(2, state_sz - 2)
            else:
                if (probability > 0.6):
                    state_sz = max(2, state_sz - 1)
    print 'state_sz is ' + str(state_sz)
    return state_sz


#--

random.seed()
tm = TwitterMarkov(
    'example_screen_name',
    '/home/celesteh/Dropbox/debbie/gifs/twitter_markov/corpus.txt',
    config_file='/home/celesteh/Dropbox/debbie/gifs/twitter_markov/bots.yaml')

dict = enchant.DictWithPWL("en_US",
                           tm.config.get('dictionary_words'))  #load dictionary

gifs = tm.config.get('gifs')
files = glob.glob((str(gifs) + '/out*.gif'))
if len(files) < 15:
    if len(files) == 1:
        title = 'Last Gif'
        remain = 'This is the last tweet you can send.'
    else:
        title = 'Low Gifs'
        remain = 'There are only ' + str(len(files)) + ' gifs remianing.'