def benchmark(nb_crypto): liste_polarity = [] liste_average_senti = [] liste_crypto = get_ordonate_crypto_list() print(liste_crypto[:nb_crypto]) for crypto in liste_crypto[:nb_crypto]: loc_file = tws.get_tweet_from_subject(10, "en", crypto, 20, 20, 20) print(loc_file) df = pd.read_csv("data/" + loc_file, sep="\\", names=['Content']) clean = nlp.clean_df(df) tweet_list = sent_analy.get_sentence_from_array(clean) liste_average_senti.append( sent_analy.get_sentiment_analyse(tweet_list, schema=False)) liste_polarity.append(get_signe(liste_average_senti[-1])) list_norm_average_senti = normalize(liste_average_senti) print_benchmark(list_norm_average_senti, liste_polarity) fig = plt.figure(figsize=(nb_crypto, 5)) ax = fig.add_axes([0, 0, 1, 1]) ax.set_title('Bilan analyse sentimental pour ' + str(nb_crypto) + " Crypto") ax.set_ylabel('Scores (Achat si sup à zéro Vente si inf)') crypto_sentiment = print_benchmark(list_norm_average_senti, liste_polarity) labels = liste_crypto[:nb_crypto] ax.bar(labels, crypto_sentiment) plt.show()
def main(): loc_file = tws.get_tweet_from_subject(10,"en","bitcoin",20,20,20) print("\n Nom du fichier :",loc_file,"\n") df = pd.read_csv("data/" +loc_file, sep="\\", names=['Content']) clean = nlp.clean_df(df) tweet_list = sent_analy.get_sentence_from_array(clean) sent_analy.get_sentiment_analyse(tweet_list) ## Benchmark crypto cryp_ben.benchmark(nb_crypto=5)
# -*- coding: utf-8 -*- """ Created on Fri Dec 4 11:45:05 2020 @author: Victor HENRIO """ import nlp import tweet_scraping_scroll as tws import sentiment_analysis as sent_analy import pandas as pd if __name__ == "__main__": loc_file = tws.get_tweet_from_subject(10, "en", "bitcoin", 20, 20, 20) print(loc_file) df = pd.read_csv("data/" + loc_file, sep="\\", names=['Content']) clean = nlp.clean_df(df) tweet_list = sent_analy.get_sentence_from_array(clean) sent_analy.get_sentiment_analyse(tweet_list)