Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SOCNYC-Assign3 - Google Docs R ||||| The Future of the Gig Professionals: A... Intro bbhosted.cuny.edu how do i set the folder path to a

imageimageimageimageimageimage

SOCNYC-Assign3 - Google Docs R ||||| The Future of the Gig Professionals: A... Intro bbhosted.cuny.edu how do i set the folder path to a folder... Take-home test for Unit 5 with open('nytimes. tweets') as lines: for line in lines: print(line) @ At-Home Tests - 2023 Spring Term (1)... Mentions Take-home test for Unit 5 You are given a collection of text files, each containing 1000 recent tweets posted by several popular Twitter accounts. Each line in a file is one tweet, so if we read the files the usual way, each line will corresponds to a separate tweet: If you are getting a decoding error, to correctly open UTF-8 encoded text files, use a variant of the function open: C Homework Help - Q&A from Online Tu... y + SOCNYC-Assign3 - Google Docs R ||||| The Future of the Gig Professionals: A... bbhosted.cuny.edu how do i set the folder path to a folder... At-Home Tests - 2023 Spring Term (1)... If you are getting a decoding error, to correctly open UTF-8 encoded text files, use a variant of the function open: with open('nytimes. tweets', encoding='utf-8') as lines: for line in lines: print(line) Take-home test for Unit 5 A username prefixed with @ is called a mention. For example, the tweet below contains four mentions (@voguemagazine, @FentyOfficial, @ethjgreen, and @yusefhairnyc): Rihanna @rihanna Oct 9, 2019 So proud to be on another cover of @voguemagazine wearing my own designs from @FentyOfficial !!! On stands October 16th! Photographer: @ethjgreen Fashion Editor: Tonne Goodman Hair: @yusefhairnyc Makeup: Kanako Takase vogue.cm/Tp750AW The above tweet is represented by the following string in the text file rihanna. tweets, any mention can be identified a word that starts with @ : So proud to be on another cover of @voguemagazine wearing my own designs from @FentyOfficial !!! On stands October 16th! Photographer: @ethjgreen Fashion Editor: Tonne Goodman Hair: @yusefhairnyc Makeup: Kanako Takase https//vogue.cm/Tp750AW pic.twitter.com/LU9TEe1NEh Task We will write a program for finding the most frequently mentioned usernames in each of the provided files. To correctly identify mentions, we have to cleanup each tweet, keeping only letters, digits, and symbols @ and _. After each Homework Help - Q&A from Online Tu... DIDO Take-home test for Unit 5 C @ Mentions y + SOCNYC-Assign3 - Google Docs R The Future of the Gig Professionals: A... ||||| nytimes. tweets bbhosted.cuny.edu Task We will write a program for finding the most frequently mentioned usernames in each of the provided files. To correctly identify mentions, we have to cleanup each tweet, keeping only letters, digits, and symbols @and. After each tweet is cleaned up, we have to go through its words, and if the word starts with @, it is a mention. how do i set the folder path to a folder... Step-by-step: 1. Modify function cleanedup so that it keeps not only letters, but also digits 0123456789 and symbols @ and 2. Write a new function findMentions that takes a filename as a parameter and reports 3 usernames most frequently mentioned in that file. The function should create a dictionary of counts for all username mentions (words starting with @). After reading through the file and accumulating the counts for all mentioned usernames, use the dictionary to create a list like this: [[15, '@alice'], [20, '@bob'], [7, '@carol'], ... ] @caityweaver 3 At-Home Tests - 2023 Spring Term (1)... Use sort to sort the above list and print out 3 most frequently mentioned usernames. 3. Check each file in the current folder (using os.listdir('.') ), if the file name ends with .tweets, call findMentions on the file to find its most frequent mentions. @nytmag 5 @nytparenting 5 justinbieber. tweets Take-home test for Unit 5 Example output If you copy all provided .tweets files in the folder with your script, its output will look as follows: C Homework Help - Q&A from Online Tu... Task t here to chong neck tant de les fes et bon and the ch y + SOCNYC-Assign3 - Google Docs The Future of the Gig Professionals: A... nytimes. tweets R @caityweaver 3 @nytmag 5 @nytparenting 5 justinbieber. tweets Example output If you copy all provided .tweets files in the folder with your script, its output will look as follows: @applemusic 15 @theellenshow 15 @skrillex 20 aoc.tweets @rashidatlaib 5 @ayannapressley 6 @ilhanmn 9 espn. tweets @nba 21 @thecheckdown 29 @kingjames 32 rihanna. tweets @rihanna 21 @savagexfenty 29 @fentybeauty 48. amyschumer. tweets @bridgeteverett @rachelfeinstein 15 @comedycentral 49 ladygaga. tweets bbhosted.cuny.edu how do i set the folder path to a folder... At-Home Tests - 2023 Spring Term (1)... Take-home test for Unit 5 Homework Help - Q&A from Online Tu... Task Step-by-step C Example output to gigan with They of all Cha y + SOCNYC-Assign3 - Google Docs R The Future of the Gig Professionals: A... @comedycentral 49 ladygaga. tweets @ahsfx 10 @btwfoundation 11 @applemusic 13 BillGates. tweets ||| @theeconomist 11 @warrenbuffett 15 @melindagates 18. BarackObama. tweets @ofa 5 @vp 5 @michelleobama 9 ID_AA_Carmack. tweets @boztank 3 @joerogan 3 @elonmusk 5 Kaepernick7. tweets @mikailsprice 26 @darthkaepernick 28 @kaepernick7 138 doctorow. tweets @cbc 3 @doctorow 3 @sensanders 7 i bbhosted.cuny.edu how do i set the folder path to a folder... At-Home Tests - 2023 Spring Term (1)... Take-home test for Unit 5 The summary of each .tweets file does not have to appear in the same order shown above, but each username must be followed by its count, and the lines must be sorted by count in increasing order. C Homework Help - Q&A from Online Tu... Example output y + SOCNYC-Assign3 - Google Docs The Future of the Gig Professionals: A... BarackObama. tweets @ofa 5 @vp 5 @michelleobama 9 R ID_AA_Carmack. tweets @boztank 3 @joerogan 3 @elonmusk 5 Kaepernick7. tweets @mikailsprice 26 @darthkaepernick 28 @kaepernick7 138 doctorow. tweets @cbc 3 @doctorow 3 @sensanders 7 1 A Last updated 2020-11-11 11:02:07 -0500 bbhosted.cuny.edu how do i set the folder path to a folder... At-Home Tests - 2023 Spring Term (1)... Take-home test for Unit 5 The summary of each .tweets file does not have to appear in the same order shown above, but each username must be followed by its count, and the lines must be sorted by count in increasing order. Your program's output must look as close as possible to what is shown above. In particular, if your program's output contains anything that looks like [3, '@caityweaver'], that is not correct! Homework Help - Q&A from Online Tu... dide C y +

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Marketing And Export Management

Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr

8th Edition

1292016922, 978-1292016924

More Books

Students also viewed these Programming questions

Question

r G

Answered: 1 week ago