proffreda

Trump and Clinton Hashtags

Jul 31st, 2016
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.74 KB | None | 0 0
  1. import re
  2. import json
  3. from collections import Counter
  4.  
  5. # The first argument of open() will be whatever you saved your JSON as
  6. with open("realDonaldTrumpTweets", 'r') as savedData:
  7. tweets = json.load(savedData)
  8.  
  9. text = "".join(w.lower()+' ' for t in tweets for w in t.split())
  10. text = re.sub('[^a-z\ \'\#\@]+', ' ', text)
  11. # create a list by splitting the text string
  12. text = text.split()
  13.  
  14. stopwords="a,able,about,across,after,all,almost,also,am,among,an,and,any,are,as,at,be,because,been,but,by,can,cannot,co,could,dear,did,do,does,either,else,ever,every,for,from,get,got,had,has,have,he,her,hers,him,his,how,however,http,i,if,in,into,is,it,its,just,least,let,like,likely,may,me,might,most,must,my,neither,no,nor,not,of,off,often,on,only,or,other,our,own,rather,said,say,says,she,should,since,so,some,t,than,that,the,their,them,then,there,these,they,this,tis,to,too,twas,us,wants,was,we,were,what,when,where,which,while,who,whom,why,will,with,would,yet,you,your"
  15.  
  16. stopwordlist= stopwords.split(',')
  17.  
  18. goodwordlist = [ w for w in text if w not in stopwordlist]
  19. hashtags = Counter( [w for w in goodwordlist if w[0] == '#'])
  20. print(hashtags.most_common())
  21.  
  22.  
  23.  
  24. ######Output for @realDonaldTrump ######
  25. [('#trump', 424), ('#makeamericagreatagain', 279), ('#votetrump', 75), ('#americafirst', 36), ('#gopdebate', 31), ('#fitn', 29), ('#trumptrain', 27), ('#iacaucus', 21), ('#supertuesday', 21), ('#imwithyou', 19), ('#rncincle', 15), ('#crookedhillary', 15), ('#maga', 13), ('#trumppence', 13), ('#wiprimary', 13), ('#', 13), ('#nyprimary', 11), ('#inprimary', 10), ('#caucusfortrump', 10), ('#votetrumpsc', 9), ('#potus', 8), ('#votetrumpnh', 8), ('#nhprimary', 7), ('#scprimary', 7), ('#votetrumpnv', 7), ('#gopconvention', 5), ('#newyorkvalues', 5), ('#obamacare', 4), ('#icymi', 4), ('#wisconsin', 4), ("#'s", 4), ('#nevadacaucus', 4), ('#isis', 4), ('#tbt', 3), ('#makeamericasafeagain', 3), ('#teamtrump', 3), ('#votetrumpny', 3), ('#votetrumpmi', 3), ('#nhpolitics', 3), ('#foxnews', 3), ('#fox', 3), ('#utah', 3), ('#azprimary', 3), ('#biloxi', 3), ('#msm', 3), ('#hannity', 3), ('#demdebate', 3), ('#t', 2), ('#makeamericaworkagain', 2), ('#women', 2), ('#arizonaprimary', 2), ('#paprimary', 2), ('#benghazi', 2), ('#iowacaucus', 2), ('#marybrigidmcmanamon', 2), ('#laurencetribe', 2), ('#crippledamerica', 2), ('#nevertrump', 2), ('#nvcaucus', 2), ('#cnn', 2), ('#lesm', 2), ('#missuniverse', 2), ('#sotu', 2), ('#donaldtrump', 2), ('#trumpornobody', 2), ('#utahcaucus', 2), ('#tedcruz', 2), ('#wakeupamerica', 2), ('#lyingted', 2), ('#neverhillary', 2), ('#riprimary', 2), ('#gop', 2), ('#ussyorktown', 2), ('#supersaturday', 2), ('#kimmel', 2), ('#utcaucus', 2), ('#rtm', 1), ('#oh', 1), ('#wattersworld', 1), ('##', 1), ('#watch', 1), ('#harveypitt', 1), ('#wausau', 1), ('#mississippi', 1), ('#stanleycup', 1), ('#az', 1), ('#monmouth', 1), ('#trumpforpresident', 1), ('#votetrumpnc', 1), ('#rememberourvets', 1), ('#indprimary', 1), ('#laurence', 1), ('#joetheismann', 1), ('#tcot', 1), ('#stopcommoncore', 1), ('#fns', 1), ('#wcs', 1), ('#go', 1), ('#nato', 1), ('#mexico', 1), ('#noloyalty', 1), ('#rnc', 1), ('#pjnet', 1), ('#mo', 1), ('#fairandbalancedmyass', 1), ('#trumpsupporters', 1), ('#wewanttrump', 1), ('#haileypuckett', 1), ('#happymothersday', 1), ('#lssc', 1), ('#robotrubio', 1), ('#votetrumpwi', 1), ('#newday', 1), ('#kansascaucus', 1), ('#excellent', 1), ('#nebraskaprimary', 1), ('#votetrumpid', 1), ('#cruzcrew', 1), ('#vaticanwalls', 1), ('#hillaryforprison', 1), ('#derp', 1), ('#nevercruz', 1), ('#naturalborn', 1), ('#cincodemayo', 1), ('#ford', 1), ('#fl', 1), ('#nascar', 1), ('#whyisupporttrump', 1), ('#votersspeak', 1), ('#thankavet', 1), ('#neprimary', 1), ('#americagreatagain', 1), ('#rubio', 1), ('#sb', 1), ('#rogerailes', 1), ('#trumpdog', 1), ('#caprimary', 1), ('#elkhart', 1), ('#morningjoe', 1), ('#ctprimary', 1), ('#davidcameron', 1), ('#iowa', 1), ('#letsdothis', 1), ('#thedonald', 1), ('#trumpcountry', 1), ('#jonas', 1), ('#dtmag', 1), ('#rogerstone', 1), ('#lets', 1), ('#gopincle', 1), ('#pearlharbor', 1), ('#hillarykaine', 1), ('#politician', 1), ('#colbert', 1), ('#presidenttrump', 1), ('#victory', 1), ('#mediafraud', 1), ('#alwaystrump', 1), ('#commoncore', 1), ('#armedforcesday', 1), ('#endcommoncore', 1), ('#carrier', 1), ('#southcarolina', 1), ('#kenlangone', 1), ('#newyork', 1), ('#mattschlapp', 1), ('#jenniferrubin', 1), ('#gplfers', 1), ('#teachers', 1), ('#leadright', 1), ('#jobs', 1), ('#votetrumpil', 1), ('#trumpwaikiki', 1), ('#riggedsystem', 1), ('#repmikekelly', 1), ('#dday', 1), ('#bikersfortrump', 1), ('#donald', 1), ('#superbowlsunday', 1), ('#snowflakegardenbrunch', 1), ('#cbnnews', 1), ('#bush', 1), ('#votetrumpma', 1), ('#throwbackthursday', 1), ('#itisntabouther', 1), ('#newhampshire', 1), ('#dnc', 1), ('#theremembranceproject', 1), ('#reuterspoll', 1), ('#commonlaw', 1), ('#iapolitics', 1), ('#brussels', 1), ('#votetrumpks', 1), ('#wearebernie', 1), ('#frozen', 1), ('#tump', 1), ('#greta', 1), ('#votetrumpvt', 1), ('#votetrumphi', 1), ('#demsinphilly', 1), ('#deprimary', 1), ('#yuge', 1), ('#michaelmoore', 1), ('#littlemarco', 1), ('#cruzfraud', 1), ('#utahprimary', 1), ('#mdw', 1), ('#maitnerstrong', 1), ('#msprimary', 1), ('#mahalo', 1), ('#neverdems', 1), ('#ha', 1), ('#maralago', 1), ('#ut', 1), ('#happynewyearamerica', 1), ('#il', 1), ('#icaucused', 1), ('#politicallycorrect', 1), ('#economy', 1), ('#fail', 1), ('#trumpinstagram', 1), ('#megynkellypresents', 1), ('#dealwithit', 1), ('#winnersarentlosers', 1), ('#makeyoutubegreatagain', 1), ('#trumplv', 1), ('#amazon', 1), ('#primary', 1), ('#hypocrisy', 1), ("#wh'", 1), ('#ca', 1), ('#racine', 1), ('#wvprimary', 1), ('#flashbackfriday', 1), ('#with', 1), ('#mdprimary', 1), ('#votetrumpms', 1), ('#ontherecord', 1), ('#vote', 1), ('#arizona', 1), ('#trumprocksamerica', 1), ('#orprimary', 1), ('#meetthetrumps', 1), ('#americansamoa', 1), ('#trumpdallas', 1), ('#ted', 1), ('#neilcavuto', 1), ('#lonestarstate', 1), ('#primaryday', 1), ('#tryme', 1), ('#googletrends', 1), ('#goldenglobe', 1), ('#johnryder', 1), ('#mormon', 1), ('#dem', 1), ('#eauclaire', 1), ('#secondamendment', 1), ('#southcarolinaprimary', 1), ('#iowan', 1), ('#aipac', 1), ('#trumpiswithyou', 1), ('#potusyourefired', 1), ('#donaldtrumpforpresident', 1), ('#westerntuesday', 1), ('#ivoted', 1), ('#nc', 1), ('#lightweightsenatormarcorubio', 1), ('#upupup', 1), ('#indiana', 1), ('#cruz', 1)]
  26.  
  27.  
  28. ######Output for @HillaryClinton #####################
  29. [('#demdebate', 85), ('#imwithher', 51), ('#demsinphilly', 50), ('#rncincle', 49), ('#gopdebate', 35), ('#demtownhall', 27), ('#supertuesday', 14), ('#tbt', 12), ('#demconvention', 11), ('#estoyconella', 10), ('#scotus', 9), ('#womancard', 8), ('#equalpayday', 7), ('#nobillnobreak', 5), ('#demplatform', 5), ('#', 5), ('#stopgunviolence', 5), ('#primaryday', 5), ('#trumpyourself', 4), ('#doyourjob', 4), ('#strongertogether', 4), ('#caucusforher', 4), ('#brexitvote', 4), ('#demsinphl', 4), ('#sheswithus', 3), ('#wemadehistory', 3), ('#madeforhistory', 3), ('#fightforfamilies', 3), ('#womenshistorymonth', 3), ('#raisethewage', 3), ('#actonclimate', 3), ('#disarmhate', 3), ('#fitn', 3), ('#hillary', 3), ('#hillyes', 3), ('#citizensunited', 2), ('#lssc', 2), ('#clintonkaine', 2), ('#feelthebern', 2), ('#stopthehate', 2), ('#juntossepuede', 2), ('#sitin', 2), ('#nomoresilence', 2), ('#ivoted', 2), ('#shareyourpay', 2), ('#lgbt', 2), ('#earthday', 2), ('#orlandounited', 2), ('#gunviolence', 2), ('#rollcallvote', 2), ('#marchmatters', 2), ('#msnbctownhall', 2), ('#creatorsaskhrc', 2), ('#codemdinner', 2), ('#hearthillary', 2), ('#hillaryinnv', 2), ('#iwd', 2), ('#enough', 2), ('#lovetrumpshate', 2), ('#hillaryclinton', 1), ('#teacherappreciationday', 1), ('#mothersday', 1), ('#cesarchavezday', 1), ('#demsinphil', 1), ('#de', 1), ('#titleix', 1), ('#nato', 1), ('#goodtrouble', 1), ('#nycpride', 1), ('#makersandtakers', 1), ('#paaflcioconvention', 1), ('#fixdemocracyfirst', 1), ('#imwithhe', 1), ('#filibuster', 1), ('#spartans', 1), ('#mikepence', 1), ('#whcd', 1), ('#turkey', 1), ('#caribbean', 1), ('#equalplayequalpay', 1), ('#mar', 1), ('#ddaware', 1), ('#irandeal', 1), ('#gotvforhrc', 1), ('#fightforher', 1), ('#orlando', 1), ('#mayorsagainstdiscrimination', 1), ('#grammys', 1), ('#rollingvictory', 1), ('#democraticsitin', 1), ('#srebrenica', 1), ('#firstinpotus', 1), ('#standtogether', 1), ('#trumpsctownhall', 1), ('#wimbledon', 1), ('#dayofsilence', 1), ('#naacp', 1), ('#womenofcolor', 1), ('#dday', 1), ('#transdayofvisibility', 1), ('#veterans', 1), ('#txlege', 1), ('#madeinamerica', 1), ('#equalpay', 1), ('#hill', 1), ('#cesarchavez', 1), ('#hillaryoncnn', 1), ('#apahm', 1), ('#studentsforhillary', 1), ("#rncincle's", 1), ('#michaelbrown', 1), ('#marchwithher', 1), ('#goptownhall', 1), ('#eastvillage', 1), ('#seiuforhillary', 1), ('#holdthefloor', 1), ('#paidfamilyleave', 1), ('#breakingbarriers', 1), ('#sayhername', 1), ('#washingtondc', 1), ('#imw', 1), ('#hrc', 1), ('#hillinois', 1), ('#womeninstem', 1), ('#campaignfinance', 1), ('#hillaryongma', 1), ('#virwinia', 1), ('#mayday', 1), ('#restorethevra', 1), ('#fightfor', 1), ('#worldwaterday', 1), ('#thetoast', 1), ('#internationalnursesday', 1), ('#endgun', 1), ('#miforhillary', 1), ('#uaw', 1), ('#caprimary', 1), ('#dncinphl', 1), ('#ohhillyes', 1), ('#wibackher', 1), ('#vegas', 1), ('#teamhillary', 1), ('#ppact', 1), ('#charleston', 1), ('#holdt', 1), ('#cortesuprema', 1), ('#mothersofthemovement', 1), ('#caleitc', 1), ('#brooklyndebate', 1), ('#worldtbday', 1), ('#worldrefugeeday', 1), ('#neverforget', 1), ('#yeswecan', 1), ('#sandrabland', 1), ('#hrcinsc', 1), ('#juntosconhillary', 1), ('#fairness', 1), ('#nobil', 1), ('#sanders', 1), ('#fighting', 1), ('#sallyrideday', 1), ('#statehood', 1), ('#womenofcourage', 1), ('#wonk', 1), ('#saveelephants', 1), ('#hillaryforohio', 1), ('#prince', 1), ('#understandslavery', 1), ('#aslongasittakes', 1), ('#usmc', 1), ('#philandocastile', 1), ('#moreincommon', 1), ('#friedrichs', 1), ('#thanksobama', 1), ('#newyorkvalues', 1), ('#aidsfreegeneration', 1), ('#armybday', 1), ('#enthusiasm', 1), ('#diadelatierra', 1), ('#aca', 1), ('#internationalwomensday', 1), ('#tcot', 1), ('#houstonflood', 1), ('#decision', 1), ('#notonemore', 1), ('#work', 1), ('#memorialday', 1), ('#changeagents', 1), ('#troopsvstorture', 1), ('#flintwatercrisis', 1), ('#olmstead', 1), ('#itsgotimenevada', 1), ('#nvdemscaucus', 1), ('#brexit', 1), ('#innercircle', 1), ('#nhpolitics', 1), ('#netneutrality', 1), ('#khizrkhan', 1), ('#teamobama', 1), ('#fightforfam', 1), ('#gibill', 1), ('#turnuptovote', 1), ('#hillaryontheview', 1), ('#westvirginia', 1), ('#onebostonday', 1), ('#selma', 1), ('#kentuckyderby', 1)]
Advertisement
Add Comment
Please, Sign In to add comment