<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tweepy, csv
from tweepy import OAuthHandler
 
class GetTweets():
    consumer_key = 'mRJGFxAWklN3ffMzNnbbPwmyi'
    consumer_secret = '<KEY>'
    access_token_raw = '<KEY>'
    access_token = access_token_raw.encode('utf-8')
    access_secret = '<KEY>'
    
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_secret)
    
    api = tweepy.API(auth)
    
    csvFile = open('E:/Twitter Sentiment Anlayzer/Gamification---Twitter-Sentiment-Analyzer/tweet.csv', 'w+')
    
    csvWriter = csv.writer(csvFile)
    
    # print api.rate_limit_status()
    print ""
    query = raw_input("Enter a query search term: ")
    print ""
    
    for tweet in tweepy.Cursor(api.search, 
                        q=query, 
                        show_user = False, 
                        lang="en").items(600):
        csvWriter.writerow([tweet.text.encode('utf-8')])
        print tweet.text.encode('utf-8')
    
    csvFile.close()
    
    # Read from csv to list
    # with open('E:/tweet.csv', 'rb') as f:
        #reader = csv.reader(f)
        #your_list = list(reader)
        
    #print your_list<commit_msg>Optimized to take query as input from the game<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tweepy, csv
from tweepy import OAuthHandler
 
class GetTweets():
    def getting_query_result(self, query):
        consumer_key = 'mRJGFxAWklN3ffMzNnbbPwmyi'
        consumer_secret = '<KEY>'
        access_token_raw = '<KEY>'
        access_token = access_token_raw.encode('utf-8')
        access_secret = '<KEY>'
        
        auth = OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_secret)
        
        api = tweepy.API(auth)
    
        csvFile = open('E:/Twitter Sentiment Anlayzer/Gamification---Twitter-Sentiment-Analyzer/tweet.csv', 'w+')
        
        csvWriter = csv.writer(csvFile)
        
        # print api.rate_limit_status()
        # print ""
        # query = raw_input("Enter a query search term: ")
       
        for tweet in tweepy.Cursor(api.search, 
                            q=query, 
                            show_user = False, 
                            lang="en").items(10):
            csvWriter.writerow([tweet.text.encode('utf-8')])
            #print tweet.text.encode('utf-8')
        print "Saved sample tweets from query in tweet.csv"
        csvFile.close()
    
    # Read from csv to list
    # with open('E:/tweet.csv', 'rb') as f:
        #reader = csv.reader(f)
        #your_list = list(reader)
        
    #print your_list
{'fraction_non_alphanumeric': 0.11971567527123082, 'fraction_numerical': 0.005611672278338945, 'mean_word_length': 2.112922002328289, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6905102', 'n_tokens_mistral': 903, 'n_tokens_neox': 852, 'n_words': 167}