예제 #1
0
def download_tweet_labels_file():
    lines = stats_generator.generate_text_with_report_by_tweets(
        mmu.get_df_with_all().sort_values('insert_time'))
    with open('labels.txt', 'w') as the_file:
        for line in lines:
            the_file.write(line + '\n')
    return send_from_directory(directory='', filename="labels.txt")
예제 #2
0
def get_stats_heatmap():
    flights = mmu.get_df_with_all()
    flights = pd.pivot_table(flights,
                             values='tweet_id',
                             index=['label'],
                             columns=['username'],
                             aggfunc=len)
    fig, ax = plt.subplots(figsize=(12, 3))
    sns.heatmap(flights, annot=True, fmt=".0f")
    fig.savefig('output.png')
    return send_file("output.png", mimetype='image/gif', cache_timeout=0)
예제 #3
0
def get_labelled_tweets():
    tweets = mmu.get_df_with_all()
    tweets = tweets[tweets.label != ''].sort_values(by=['update_time'],
                                                    ascending=False)
    list_to_return = []
    for index, row in tweets.iterrows():
        d = row.to_dict()
        d['update_time'] = d['update_time'].isoformat()
        d['note'] = ''
        d['tweet'] = d['tweet_content']
        d.pop('_id', None)
        d.pop('tweet_content', None)
        list_to_return.append(d)
    return jsonify({'tweets': list_to_return})
예제 #4
0
def get_stats_detailed():
    tweets = mmu.get_df_with_all()
    return jsonify(group_by_counts(tweets))
예제 #5
0
def download():
    mmu.get_df_with_all().to_json('results.json')
    return send_from_directory(directory='', filename="results.json")