Exemple #1
0
    elif month == 'JUN':
        return 6
    elif month == 'JUL':
        return 7
    elif month == 'AUG':
        return 8
    elif month == 'SEP':
        return 9
    elif month == 'OCT':
        return 10
    elif month == 'NOV':
        return 11
    elif month == 'DEC':
        return 12

gdb = google_db()

for airline in bob:
    for date_obj in bob[airline]:
        try:
            year = int(date_obj[-4:])
            month = int(convert_month_to_num(date_obj[3:6]))
            day = int(date_obj[0:2])
        except Exception:
            continue
        print(year, month, day)
        timestamp = datetime(year, month, day)

        new_data = bob[airline][date_obj]
        new_data['timestamp'] = timestamp
        gdb.store_data(new_data, date_obj, airline + '_delay_data')
 def __init__(self):
     setup_credentials()
     self.g_db = google_db()
     self.g_sa = g_sentiment_analysis()
     self.count = 0
        if count == 0:
            print("UNDEFINED BEHAVIOR!!!!")
            print("No data for day ", start, ". Will put zero...")
            output.append(0)
        else:
            avg_sentiment_for_day = sentiment_sum / count
            output.append(avg_sentiment_for_day)

        start += day

    return output


if __name__ == '__main__':
    gdb = gdatabase.google_db()

    jetblue_sentiment_each_day = extract_sources_label_per_day(gdb, JETBLUE_SENTIMENT_LABELS, START_DAY, END_DAY, 'sentiment')

    #other_airline_sentiment_each_day = extract_sources_sentiment_per_day(gdb, OTHER_AIRLINE_SENTIMENT_LABELS, START_DAY, END_DAY, 'sentiment')
 
    normalized_jetblue_sentiment_per_day = []

    for i in range(len(jetblue_sentiment_each_day)):
        # Positive sentiment for jetblue and all other airlines:
        jetblue_sentiment_positive = jetblue_sentiment_each_day[i] + 1
        #all_other_sentiment_positive = other_airline_sentiment_each_day[i] + 1

        # Normalize jetblue sentiment relative to feedback for all other airlines:
        #jetblue_sentiment_normalized = jetblue_sentiment_positive / all_other_sentiment_positive
        jetblue_sentiment_normalized = jetblue_sentiment_positive / 1