table_exists = markov.cur.fetchone()[0] if not table_exists: logging.info("Transition table does not exist. Creating it now...") markov.cur.execute(""" CREATE TABLE transition ( \ first_word VARCHAR, \ second_word VARCHAR, \ result_word VARCHAR, \ frequency INTEGER, \ beginning BOOLEAN, \ PRIMARY KEY(first_word, second_word, result_word) \ ); """) markov.conn.commit() markov._disconnect_db() logging.info("Cleaning up Twitter data.") dataframe = pd.read_csv(tweet_data_file) with open(clean_data_file, 'w') as file: for line in dataframe.text.iteritems(): file.write(twitterbot.clean_data(line[1] + "\n")) logging.info("Training the database.") gen = generate_word(clean_data_file) markov.update_db(gen) twitterbot._connect_api() last_id_seen = int(dataframe.tweet_id[0]) replies = twitterbot.api.GetMentions() if replies is not None: