<commit_before>from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
from keys import *
import time
import json

import settings
import sqlite3

from SentimentAnalysis.sentimentAnalysis import *

from flask_socketio import SocketIO, emit, join_room, leave_room, close_room, rooms, disconnect

def start(socketio):
    #Get input in the form of string
    #key_word = input('Enter the search keyword: ')
    key_word = "North Korea"
    print ("Streaming results of %s" % key_word)
    settings.init()
    #class listener inherting from StreamListener
    class listener(StreamListener):
        def on_data(self, data):
            try:
                global stocketio
                # Loads for a stirng, load for an object file
                json_obj = json.loads(data)  
                info = ""
                sent = 0

                # Selects value of name of lsit user of obj jsonObj
                info +=  json_obj['user']['name']
                info += " tweeted: \n"
                info += json_obj['text']
                info += "\n on " + json_obj['created_at'] + "\n"
                settings.tweetListBuffer.append(json_obj['text'])

                # Collect info
                #date = json_obj['created_at']

                #sent = getSentiment(json_obj['text'])
                
                # Must have socket sleep to return info
                socketio.sleep(.5)

                # Send information of tweets through socket 
                socketio.emit('my_response',
                              {'data': json_obj['text'], 
                              'count': 0,
                              'sentiment': 0},
                              namespace='/test')

                #print( info )
                #print (settings.tweetListBuffer)
                return True

            except Exception as e:
                print( "ERROR" )
                #print( 'failed ondata' , str(e) )
                #return False

    def on_error(self, status):
        print (status)
<commit_msg>Added sentiment into data emit<commit_after>from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
from keys import *
import time
import json

import settings
import sqlite3

from SentimentAnalysis.sentimentAnalysis import *

from flask_socketio import SocketIO, emit, join_room, leave_room, close_room, rooms, disconnect

def start(socketio):
    #Get input in the form of string
    #key_word = input('Enter the search keyword: ')
    key_word = "North K<PASSWORD>"
    print ("Streaming results of %s" % key_word)
    settings.init()
    #class listener inherting from StreamListener
    class listener(StreamListener):
        def on_data(self, data):
            try:
                global stocketio
                # Loads for a stirng, load for an object file
                json_obj = json.loads(data)  
                info = ""
                sent = 0

                # Selects value of name of lsit user of obj jsonObj
                info +=  json_obj['user']['name']
                info += " tweeted: \n"
                info += json_obj['text']
                info += "\n on " + json_obj['created_at'] + "\n"
                settings.tweetListBuffer.append(json_obj['text'])

                # Collect info
                #date = json_obj['created_at']

                sent = getSentiment(json_obj['text'])
                
                # Must have socket sleep to return info
                socketio.sleep(.5)

                # Send information of tweets through socket 
                socketio.emit('my_response',
                              {'data': json_obj['text'], 
                              'count': 0,
                              'sentiment': sent},
                              namespace='/test')

                #print( info )
                #print (settings.tweetListBuffer)
                return True

            except Exception as e:
                print( "ERROR" )
                #print( 'failed ondata' , str(e) )
                #return False

    def on_error(self, status):
        print (status)

{'fraction_non_alphanumeric': 0.08430857415810843, 'fraction_numerical': 0.0021495103893002148, 'mean_word_length': 1.5677498467198039, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1297863', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1030, 'n_words': 326}