added support for testing from static file

This commit is contained in:
Tom Meagher
2013-10-28 16:59:55 -04:00
parent 25dc2ceead
commit 8595210cba
2 changed files with 19 additions and 12 deletions

View File

@@ -39,17 +39,23 @@ if __name__=="__main__":
guess = 0
if guess == 0:
user=SOURCE_ACCOUNT
source_tweets = []
api=connect()
max_id=None
for x in range(17)[1:]:
source_tweets_iter, max_id = grab_tweets(api,max_id)
source_tweets += source_tweets_iter
print "{0} tweets found".format(len(source_tweets))
if len(source_tweets) == 0:
print "Error fetching tweets from Twitter. Aborting."
sys.exit()
if DEBUG==True:
file = TEST_SOURCE
string_list = open(file).readlines()
for item in string_list:
source_tweets = item.split(",")
else:
user=SOURCE_ACCOUNT
source_tweets = []
api=connect()
max_id=None
for x in range(17)[1:]:
source_tweets_iter, max_id = grab_tweets(api,max_id)
source_tweets += source_tweets_iter
print "{0} tweets found".format(len(source_tweets))
if len(source_tweets) == 0:
print "Error fetching tweets from Twitter. Aborting."
sys.exit()
mine = markov.MarkovChainer(order)
for tweet in source_tweets:
if re.search('([\.\!\?\"\']$)', tweet):