Exemple #1
0
def process_tweet(tweet):
    post = tweet.text
    sentiment_value = s.classify(post)
    print(post,",",sentiment_value)
    output = open("twitter-out1.txt","a")
    output.write(sentiment_value)
    output.write('\n')
    output.close()
Exemple #2
0
    def on_data(self, data):

        all_data = json.loads(data)

        tweet = all_data["text"]
        sentiment_value = s.classify(tweet)
        print(tweet,",",sentiment_value)
        output = open("stream-out.txt","a")
        output.write(sentiment_value)
        output.write('\n')
        output.close()

        return True
Exemple #3
0
index_score = [280,285,147,175,173,158,189,127,124,60]
voting_result = [0.04,0.01,0,0,0.08,0.03,0.44,0.39,0,0]
sentiment_score = []
sov_score = []
sovp_score = []
sovn_score = []

for p in players:
    counter = []
    query= 'SELECT * FROM (' + ','.join(map(str, players)) + ')'
    c.execute(query)
    results = c.fetchall()
    for row in results:
        post = row[3]
        # print(post)
        sentiment_value = s.classify(post)
        counter.append(sentiment_value)
        choice_pos = counter.count("pos")
        choice_neu = counter.count("neu")
        choice_neg = counter.count("neg")
        sent_score = math.log10((choice_pos+1)/(choice_neg+1))
        sov = (len(counter)/274715)
        sovp = choice_pos/91992
        sovn = choice_neg/4919
        sentiment_score.append(sent_score)
        sov_score.append(sov)
        sovp_score.append(sovp)
        sovn_score.append(sovn)
        print("pos:", sovp)
        print("sov:", sov)
        print("neg:", sovn)