Python Project
Prj3_Files/Project_3.py
import nltk def process_hashes(tweet): pass #Correct the next function #The comments tell you what the code SHOULD be doing #In many cases it is not doing that #Do not add or delete lines def popular_tweets(filename, how = 'retweet', cutoff = 100, counts = False): info = {'reply':3,'retweet': 4,'favorite': 5} #map columns in data to what they represent result = {} #store results in a dictionary with open('sen_tweets_edited_2.csv', 'r') as file: #open file for line in file: #read through file line by line #print(line) #you may find this debugging print line helpful - use with SMALL file data = line.split() #separate data by column for this line #print(data) #you may find this debugging print line helpful - use with SMALL file if data[how] == cutoff: #check if we've met the cutoff #print(data[how]) #you may find this debugging print line helpful - use with SMALL file if (data[how]) in result: #check if username already in dictionary result[(data[how])] = data[2] #add to the existing tweets for that user else: result[(data[how])] += data[2] #create new list of tweets for that user if counts: #If we want counts for each user in dictionary for item in result: #for each user, figure out how many tweets they have and store in dictionary result[item] = len(data) return result def graph_usage(tweets, cutoff= 10): pass #The function below is correct #Do not change it in any way #Input is a dictionary with lists of strings as values #Output is a list of strings that is ALL of the strings from ALL of the values in the dictionary, see .pdf for example def join_tweets(info): result = [] for v in info.values(): result.extend(v) return result #Extra credit only - do not delete the def lines if you don't do these, just leave them as they are def process_hashes_regex(tweet): pass def join_tweets_lc(info): pass
Prj3_Files/Project_3_Main.py
from Project_3 import * import nltk
Prj3_Files/sen_tweets_edited_2.csv
197383 .@RoweFinkbeiner: Motherhood & family economic security policies like childcare, fair pay & paid family leave were in the room at the DNC. 5 24 38 SenGillibrand D NY 173706 Congratulations, Dante Blackmon! 1st NFL player from @kennesawstate. @kennesawstfb @11AliveNews 9 13 25 sendavidperdue R GA 58369 #Trumpcare would undermine key protections for womens health care included in the Affordable Care Act. https://t.co/ZU9AnubreQ 25 162 179 PattyMurray D WA 83280 The House passed my bill to provide dental care for veterans this afternoon. Next stop is the Presidents desk! https://t.co/svQldUKeQu 3 9 16 SenatorBurr R NC 258299 Stabenow Announces Grow it Here, Make it Here Initiative, 30% Tax Credit to Spur Bio-based Manufacturing, in Zeeland http://t.co/XVj6TiL6 1 5 0 SenStabenow D MI 287537 Proud the bill I cosponsored to give Women @usairforce Service Pilots burial rights at @ArlingtonNatl will be law https://t.co/9JNKm8bmZv 1 27 54 timkaine D VA 106833 Talking GOP budget and vote-a-rama with Nebraska's own @NickStarlingTV. #BalancedBudget http://t.co/OO8V5O0tPR 0 3 4 SenatorFischer R NE 106068 or grandparents concerned about the future we will leave our grandchildren, there is no shortage of anxiety. 0 3 7 SenatorFischer R NE 169276 My #NKSPEA mandates secondary sanctions on those helping the North Korean regime: https://t.co/aqykG8BiPN 1 1 4 SenCoryGardner R CO 280140 Another reason to love and thank science and scientists https://t.co/AXBYnc0VPj 5 35 74 SenWhitehouse D RI 14447 Iowa academy of family physicians visited w me today https://t.co/27lRluBXFt 8 1 4 ChuckGrassley R IA 16058 TUNE IN: @JimInhofe will speak on the Senate floor at 4:40 EST on threats to American energy. https://t.co/1mdHgu7f6e 1 0 3 InhofePress R OK 197909 Outrageous. Via @TIME: Military Sexual Assault Victims Discharged After Filing Complaints https://t.co/3DAiTkvHcX 10 57 78 SenGillibrand D NY 120114 Marking up my bill, Taxpayers Right-To-Know Act, today in @GOPoversight Committee. http://t.co/Yq8ysw5ui0 2 0 0 SenatorLankford R OK 145229 Approving #KeystoneXL should be a no-brainer. It would support more than 40,000 jobs and has bipartisan support. http://t.co/JP2LrI4dWv 5 2 1 SenatorWicker R MS 82069 RT @MKEBizJournal: Latest info: @SenatorBaldwin reintroduces startup bill to boost #Wisconsin's startup economy #startup https://t.co/poAaQ_ 0 5 4 SenatorBaldwin D WI 195203 Glad to hear SCOTUS hearing MI same-sex marriage case. Hope they make the right decision for #equality for all Americans 3 23 36 SenGaryPeters D MI 21397 Introduced a bill yesterday to keep the US at the forefront of the global tech. market. http://ht.ly/3JWW2 1 5 0 JeffFlake R AZ 177005 RT @TravelNevada: Check out these beautiful #RenoBalloonRaces photos from last weekend curated by @RenoTahoe. https://t.co/TEVZgzvobj https_ 0 5 8 SenDeanHeller R NV 159504 RT @CoryBooker: About to go on MSNBC @HardballChris 62 51 471 SenBooker D NJ 153818 Really, we shouldn't call this GOP health care bill a 'plan.' It's a scheme to cuts taxes for millionaires & big corporations. 17 257 355 SenBobCasey D PA 166661 RT @ClarkCountyNV: Family Assistance Center is open until 7pm today for victims & family needing help after #1October shooting. More: https_ 6 88 127 SenCortezMasto D NV 179162 .@DrNordal, it was nice meeting with you. Thanks for stopping by. 1 3 0 SenDeanHeller R NV 21691 Happy #StartupDay to the Kansans who relentlessly pursue new ideas and strive to improve our communities, nation, and world. 22 11 47 JerryMoran R KS 258235 RT @rxaver: @whitehouse My job is 50 miles from home. #40dollars is like having to buy yet another tank of gas every pay period. #stopPl ... 0 2 0 SenStabenow D MI 183588 I support public ed because I'm a product of public ed this week I enjoyed the chance to chat w the IL Associatio_ https://t.co/paOzk5AKBQ 22 77 565 SenDuckworth D IL 186072 My statement on the pending deportation of the Sanchez family: https://t.co/PBUCGLeIYA 44 133 305 SenFeinstein D CA 212838 The recent breakdown in F-35 contract negotiations is yet another symptom of our flawed defense acquisition system https://t.co/SZnGs71vLa 23 30 57 SenJohnMcCain R AZ 147495 One last pic with @SenCoryGardner & our #SOTU guests before we went into the House chamber tonight: http://t.co/0i7ZjN6iDT 3 12 11 SenBennetCO D CO 122514 I support #VT's & our nations public schools & their services & inclusion of ALL our students. That's why I'll oppose #DeVos for ED Sec 6 36 140 SenatorLeahy D VT 2838 Great to speak at @CdnCEOCouncil at meeting in D.C. Nearly 9 million U.S. jobs depend on trade and investment with Canada. 1 2 2 amyklobuchar D MN 177203 It's always good to have Nevadans visiting Capitol Hill. Enjoyed meeting with @AaronDFordNV and Dr. Tyree Carr today https://t.co/AbtFsHUWH6 4 2 9 SenDeanHeller R NV 219023 Happy Founders Day to @WestPoint_USMA! Learn more about how I can help w/ nominations to service academies: http://t.co/EOzJZzF4UO 1 2 3 SenJoniErnst R IA 205843 On this day in 1889, the town of Newcastle was founded by the Lincoln Land Company. #WyoHistory http://t.co/afgTqFX2zp 1 5 2 SenJohnBarrasso R WY 36999 Only way #Alaska girls get around Point Hope for #SpringWhaling! Glad my staff trusts my snowmachine driving skills http://t.co/0nbXzc25yP 3 4 8 lisamurkowski R AK 179956 RT @Indiana_Soy: Farm bill was #1 issue at our visit w/ @SenDonnelly today. He wants input from farmers on 2018 bill so we're providing it._ 3 9 18 SenDonnelly D IN 70270 I reintroduced #MPA to protect the healthcare of our retired miners & their families. Read my op-ed in @DM_opinion: https://t.co/RelYmPckSU 9 11 44 Sen_JoeManchin D WV 44278 #Trumpcare would shift about $2.6 billion in medical costs to the state of Hawaii. As @realDonaldTrump put it, this_ https://t.co/O2kIfMQ4bN 3 32 50 maziehirono D HI 272011 Best of luck to the Dardanelle Sand Lizards! Rooting for you during tonights game against Pottsville! 1 2 7 SenTomCotton R AR 212725 The Continuing Resolution which cuts funds for troops is a sham. Is there any wonder why the American people hold C_ https://t.co/md25Qd4UT5 205 398 976 SenJohnMcCain R AZ 82589 My Statement on the Stationing of New Tankers at Seymour Johnson Air Force Base (1/9) https://t.co/y7SKIoZpAT 4 3 7 SenatorBurr R NC 276556 This is good news. At least for now, @realDonaldTrump & AG Sessions cant bludgeon towns into complying with dumb &_ https://t.co/CiPYi48yZC 1377 5295 18906 SenWarren D MA 257631 Why are Republicans asking the Supreme Court to raise taxes on Alaska families? #ACAWorks for #Alaska http://t.co/lHeHUoXRQq 0 3 0 SenStabenow D MI 141087 .@SenSherrodBrown @SenJeffMerkley @SenMarkey @SenSanders & I asked EdSec nom DeVos to pay her PAC's $5M elexn fine https://t.co/4jF96IbFjd 7 24 36 SenatorTomUdall D NM 65743 Thanks @AllianceNews and @APHSA1 for supporting #childwelfare reform we are proposing https://t.co/OGJljIyFr8 1 7 9 RonWyden D OR 233247 Now another reason not to close #GITMO. Join me to tell @POTUS NO to terrorists in the US. https://t.co/IgmkmRtlen https://t.co/xzd3mGflHJ 3 5 6 SenPatRoberts R KS 147976 #VAWA protects victims of abuse and gets criminals off the street. Its passage should be bipartisan just as when it was first passed in '94. 0 5 0 SenBennetCO D CO 15227 Nashville Songwriters Association talked copyright with me. Songwriters Marv Green and Troy Verges_ https://t.co/dJsIpnUBoc 0 1 2 ChuckGrassley R IA 45634 A warm mahalo @DeptVetAffairs & @IHSHawaii for coming together to provide transitional housing for our vets in need. http://t.co/bT7DHeIdVy 3 6 2 maziehirono D HI 283851 Montana evening #lastbestplace https://t.co/kNX3G6anMs 0 14 40 SteveDaines R MT 132475 RT @SenGillibrand: Honored to support @SenatorShaheen's bill to require Tricare to provide birth control coverage without a co-pay: http://_ 3 24 17 SenatorShaheen D NH 64640 Pressure and thorough vetting works. We must keep it up. https://t.co/w0534teFji 20 172 640 RonWyden D OR 215088 S.D. high school students applications for the U.S. Senate Youth Program are due on Friday. More on USSYP here: https://t.co/kqsGvwFSI5 0 2 4 SenJohnThune R SD 156237 President Obama not enforcing his own red line in #Syria is the lowest point Ive seen in U.S. foreign policy. https://t.co/5U46dRy9WM 31 80 129 SenBobCorker R TN 88964 RT @savingseafood: Sen. Maria Cantwell introduces bipartisan bill to establish ocean acidification monitoring strategy @SenatorCantwell htt_ 0 2 3 SenatorCantwell D WA 54106 RT @RebeccaGuyFNP: Thank you @MikeCrapo for meeting with the members of Idaho's #bleedingdisorders community! #NHFWD https://t.co/LdPMmlwpWz 1 2 6 MikeCrapo R ID 103980 Pres. Obama should not create special exemptions for unions, while non-union employers struggle under Obamacare. http://t.co/iYuxAUfERN 3 11 3 SenatorEnzi R WY 282365 An honor to be with the Montana delegation to celebrate conservation. https://t.co/Kjf5Tma3GC 13 6 25 SteveDaines R MT 142051 Also met farmers Earl & Cheryl Yazzie, who are among the many families impacted by #GoldKingMine spill. They deserve compensation. 1 4 2 SenatorTomUdall D NM 32764 @GovernorPerry is a great choice to lead @ENERGY. He brings a lot to the table as a very successful governor of a large, energy-rich state. 10 10 15 LindseyGrahamSC R SC 56494 Are you watching the Presidents address to the nation on #Syria? Let me know your thoughts. #idpol 5 4 0 MikeCrapo R ID 65538 On the north Ore. Coast, a top spot to visit on #NationalParkWeek & any time is Fort Clatsop. https://t.co/YoG3rg1gCb 0 6 18