def get_test_data(keyword="", start_time=None, end_time=None):
    '''Retrieve data from database for training and test as list of tweet object.'''

    db = db_conn()
    tweets = []

    query = "SELECT * FROM " + db.test_table
    where = " WHERE `tweet_text` LIKE '%" + keyword + "%' AND `dev_tweet` != 1"
    if start_time != None:
        where += " AND `created_at` >= '" + start_time.__str__() + "'"
    if end_time != None:
        where += " AND `created_at` <= '" + end_time.__str__() + "'"

    order = " ORDER BY `created_at` ASC"

    retval = db.read(query + where)

    for row in retval:
        id = row[0]
        time = row[2]
        text = row[1]
        sentiment = row[3]
        negation = row[4]
        tweets.append(tweet_model(id, time, text, sentiment, negation))

    return tweets
def get_test_data(keyword = "", start_time = None, end_time = None):
	'''Retrieve data from database for training and test as list of tweet object.'''

	db = db_conn()
	tweets = []

	query = "SELECT * FROM " + db.test_table
	where = " WHERE `tweet_text` LIKE '%" + keyword + "%' AND `dev_tweet` != 1"
	if start_time != None:
		where += " AND `created_at` >= '" + start_time.__str__() + "'"
	if end_time != None:
		where += " AND `created_at` <= '" + end_time.__str__() + "'"
	
	order = " ORDER BY `created_at` ASC"
	
	retval = db.read(query + where)

	for row in retval:
		id = row[0]
		time = row[2]
		text = row[1]
		sentiment = row[3]
		negation = row[4]
		tweets.append(tweet_model(id, time, text, sentiment, negation))

	return tweets
def get_dev_data():
	'''Retrieve data from database for training and test as list of tweet object.'''

	db = db_conn()
	tweets = []

	query = "SELECT * FROM " + db.test_table + " WHERE `dev_tweet` = 1"
	retval = db.read(query)

	for row in retval:
		id = row[0]
		time = row[2]
		text = row[1]
		sentiment = row[3]
		negation = row[4]
		tweets.append(tweet_model(id, time, text, sentiment, negation))

	return tweets
def get_dev_data():
    '''Retrieve data from database for training and test as list of tweet object.'''

    db = db_conn()
    tweets = []

    query = "SELECT * FROM " + db.test_table + " WHERE `dev_tweet` = 1"
    retval = db.read(query)

    for row in retval:
        id = row[0]
        time = row[2]
        text = row[1]
        sentiment = row[3]
        negation = row[4]
        tweets.append(tweet_model(id, time, text, sentiment, negation))

    return tweets
def move_data():
	book = xlrd.open_workbook('data_training_TA_Ismail Sunni.xls')
	sheet = book.sheet_by_name('tweets')

	tweets = []
	k = 0
	for row in range(sheet.nrows):
		if sheet.row_values(row)[6] == 3:
			tweets.append(sheet.row_values(row))

	conn = db_conn()

	i = 0
	for tweet in tweets:
		query = "INSERT INTO " + conn.dev_table + "( `tweet_id`, `tweet_text`, `created_at`, `sentiment`) VALUES (" + str(tweet[1]) + ", '" + tweet[4] + "', '" + tweet[3] + "', '" + str(int(tweet[5])) +"')"
		# print query
		if conn.insert(query) == True:
			i += 1
	print i
def ultimate_function():
	book = xlrd.open_workbook('data_training_TA_Ismail Sunni.xls')
	sheet = book.sheet_by_name('tweets')	

	tweets = []
	for row in range(sheet.nrows):
		if sheet.row_values(row)[6] == 3:
			tweets.append(sheet.row_values(row))

	conn = db_conn()

	i = 0
	j = 0
	for tweet in tweets:
		query = "UPDATE " + conn.test_table + " SET `sentiment`=" + str(int(tweet[5])) + ", `dev_tweet`= 1 WHERE `tweet_id`="+str(tweet[1])
		if conn.update(query) == True:
			i += 1
		else:
			j += 1
	print i
	print j
Exemple #7
0
def move_data():
    book = xlrd.open_workbook('data_training_TA_Ismail Sunni.xls')
    sheet = book.sheet_by_name('tweets')

    tweets = []
    k = 0
    for row in range(sheet.nrows):
        if sheet.row_values(row)[6] == 3:
            tweets.append(sheet.row_values(row))

    conn = db_conn()

    i = 0
    for tweet in tweets:
        query = "INSERT INTO " + conn.dev_table + "( `tweet_id`, `tweet_text`, `created_at`, `sentiment`) VALUES (" + str(
            tweet[1]) + ", '" + tweet[4] + "', '" + tweet[3] + "', '" + str(
                int(tweet[5])) + "')"
        # print query
        if conn.insert(query) == True:
            i += 1
    print i
Exemple #8
0
def ultimate_function():
    book = xlrd.open_workbook('data_training_TA_Ismail Sunni.xls')
    sheet = book.sheet_by_name('tweets')

    tweets = []
    for row in range(sheet.nrows):
        if sheet.row_values(row)[6] == 3:
            tweets.append(sheet.row_values(row))

    conn = db_conn()

    i = 0
    j = 0
    for tweet in tweets:
        query = "UPDATE " + conn.test_table + " SET `sentiment`=" + str(
            int(tweet[5])) + ", `dev_tweet`= 1 WHERE `tweet_id`=" + str(
                tweet[1])
        if conn.update(query) == True:
            i += 1
        else:
            j += 1
    print i
    print j
def reset_data():
	conn = db_conn()
	query = "UPDATE " + conn.test_table + " SET `dev_tweet` = 0"
	return conn.update(query)
Exemple #10
0
def reset_data():
    conn = db_conn()
    query = "UPDATE " + conn.test_table + " SET `dev_tweet` = 0"
    return conn.update(query)