def hist_fitted_subject(one, two, three):
    plt.figure(figsize=(12, 7))

    users = [one, two, three]
    colors = ['red', 'green', 'blue']

    for x in range(0, 3):
        user_name = users[x]
        file_name = handle_dict[user_name]
        full_tweet_texts = text_extract(file_name)
        polarity, subjectivity = pull_sentiment_polar_subjective(
            full_tweet_texts)

        array = np.array(subjectivity)
        removed_zero = array[array != 0]
        sns.distplot(removed_zero,
                     label=candidates[user_name],
                     color=colors[x])

    plt.xlabel("Subjectivity")
    plt.title("Subjectivity Curve Comparison\n {} vs {} vs {}".format(
        candidates[sys.argv[1]], candidates[sys.argv[2]],
        candidates[sys.argv[3]]))
    plt.legend()
    plt.show()
Ejemplo n.º 2
0
def provide_sentiment(user_name, about_trump):
    if about_trump:
        polarity, subjectivity = extract_about_trump(user_name)
    else:
        file_name = handle_dict[user_name]
        full_tweets = text_extract(file_name)
        polarity, subjectivity = pull_sentiment_polar_subjective(full_tweets)

    return polarity, subjectivity
Ejemplo n.º 3
0
def get_topics_totals(user_name, topics):
	file_name = handle_dict[user_name]
	full_tweet_texts = text_extract(file_name)
	found = []
	print(topics)
	for x in range(len(full_tweet_texts)):
		for topic in topics:
			if topic in full_tweet_texts[x]:
				found.append(full_tweet_texts[x])
				break
	return len(found)
Ejemplo n.º 4
0
                               fontsize=6,
                               fontweight='heavy',
                               labelpad=0)
    ax[row, column].tick_params(labelsize=6, pad=-4)


if __name__ == "__main__":
    fig, ax = plt.subplots(2, 2, figsize=(12, 7))
    cand = []
    axis_coord = [[0, 0], [0, 1], [1, 0], [1, 1]]
    color = ['red', 'green', 'blue', 'cyan', 'purple']
    for x in range(1, len(sys.argv)):
        user_name = sys.argv[x]
        file_name = handle_dict[user_name]
        cand.append(candidates[user_name])
        full_tweet_texts = text_extract(file_name)
        polarity, subjectivity = pull_sentiment_polar_subjective(
            full_tweet_texts)

        coordinates = axis_coord[x - 1]
        plot_with_axes(coordinates[0],
                       coordinates[1],
                       subjectivity,
                       polarity,
                       color[x - 1],
                       label="All Tweets",
                       alpha=0.2)

        #polarity, subjectivity = extract_about_trump(user_name)
        #plot_with_axes(coordinates[0], coordinates[1], subjectivity,
        #				 polarity, color[x], label="Talking about Trump", alpha=0.3)