Beispiel #1
0
def get_interval_topics(interval):
    """
    :param interval:
    :return: List of topics that were monitored during interval as JSON response.
    """
    topics = data.get_interval_topics(data.parse_interval_string(interval))
    return jsonify({"topics": topics})
Beispiel #2
0
def get_topic_interval_location_data(topic_id, interval, location_id):
    """
    :param topic_id:
    :param interval:
    :param location_id:
    :return: Local sentiment and popularity of topic in interval for specific region as CSV response.
    """
    summary = data.get_topic_interval_location_data(
        topic_id, data.parse_interval_string(interval), location_id)
    return jsonify({"data": summary.get_dict()})
Beispiel #3
0
def get_interval_topics_details(interval):
    """
    :param interval:
    :return: Popularity and overall sentiment of all topics in interval as a CSV response.
    """
    topics_details = data.get_interval_topics_details(
        data.parse_interval_string(interval))
    data_array = [("TOPIC", "TOPIC", "Popularity", "Overall_sentiment", "Positive_ratio", "Average_sentiment")] + \
                 [(topic, topic, summary.popularity, summary.get_overall_sentiment(),
                   summary.get_positive_ratio(), summary.average_sentiment)
                  for topic, summary in topics_details.items()]
    return output_csv_file("data.csv", data_array)
Beispiel #4
0
def get_topic_interval_data(topic_id, interval):
    """
    :param topic_id:
    :param interval:
    :return: Local sentiment and popularity of topic in interval for each region as a CSV response.
    """
    topic_interval_data = data.get_topic_interval_data_per_region(
        topic_id, data.parse_interval_string(interval))
    data_array = [[
        "Region_ID", "Popularity", "Average_sentiment", "Overall_sentiment"
    ]]
    for region, summary in topic_interval_data.items():
        data_array.append([
            region, summary.popularity, summary.average_sentiment,
            summary.get_overall_sentiment()
        ])
    return output_csv_file("{}.csv".format(interval), data_array)
Beispiel #5
0
def download_tweets_for_interval(interval):
    tweets = data.get_tweets_in_interval(data.parse_interval_string(interval))
    return jsonify([tweet.get_full_dict() for tweet in tweets])