This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
from tweepy import Cursor,API | |
from tweepy.streaming import StreamListener | |
from tweepy import OAuthHandler,Stream | |
import Credential | |
auth=OAuthHandler(Credential.CUSTOMER_KEY,Credential.CUSTOMER_SECRECT_KEY) | |
auth.set_access_token(Credential.ACCESS_TOKEN,Credential.ACCESS_SECRECT_TOKEN) | |
api=API(auth,wait_on_rate_limit=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data=pd.read_csv('location.csv') | |
print(data.columns) | |
data=data[['country_name','city_name','country_iso_code']] | |
print(data) | |
data.to_csv('city_country_data.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def string_to_json(line): | |
import ast | |
jsonval=ast.literal_eval(line) | |
return jsonval | |
location=[] | |
for line in open('tweetCur.json', 'r',encoding="utf-8"): | |
line=string_to_json(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import tqdm | |
data=pd.read_csv('city_country_data.csv') | |
df=pd.DataFrame(columns=['Country','code']) | |
with open('location.txt','r')as r: | |
location=r.readlines() | |
for i in tqdm.tqdm(data['country_name'].unique()): | |
for j in location: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.offline as py | |
import pandas as pd | |
df = pd.read_csv('tweet_location.csv') | |
count_dict=dict(df['Country'].value_counts()) | |
df['count']=df['Country'].map(count_dict) | |
df=df.drop(['Unnamed: 0'],axis=1) | |
df=df.drop_duplicates() | |
print(df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONTRACTION_MAP = { | |
"ain't": "is not", | |
"aren't": "are not", | |
"can't": "cannot", | |
"can't've": "cannot have", | |
"'cause": "because", | |
"could've": "could have", | |
"couldn't": "could not", | |
"couldn't've": "could not have", | |
"didn't": "did not", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import urllib3 | |
import json | |
http=urllib3.PoolManager() | |
Abbr_dict={} | |
#Function to get the Slangs from https://www.noslang.com/dictionary/ | |
def getAbbr(alpha): | |
global Abbr_dict | |
r=http.request('GET','https://www.noslang.com/dictionary/'+alpha) | |
soup=BeautifulSoup(r.data,'html.parser') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
with open('ShortendText.json','r') as file: | |
Abbr_dict=json.loads(file.read()) | |
splitLine=line.split() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from textblob import TextBlob | |
#line == text | |
blob=TextBlob(line) | |
blob.correct() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gingerit.gingerit import GingerIt | |
parser = GingerIt() | |
#line==string you wanna correct | |
tweet=parser.parse(line) |
OlderNewer