Nov-27-2020, 06:40 PM
(This post was last modified: Nov-27-2020, 06:40 PM by shirleylam852.)
@perfringo
I assumed it was correct bc my professor gave me changes and that was the only part left I needed to write. I guess you could be right.
Task Step-by-step:
Modify function cleanedup so that it keeps not only letters, but also digits 0123456789 and symbols @ and _
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'], ... ]
Use sort to sort the above list and print out 3 most frequently mentioned usernames.
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.
I assumed it was correct bc my professor gave me changes and that was the only part left I needed to write. I guess you could be right.
Task Step-by-step:
Modify function cleanedup so that it keeps not only letters, but also digits 0123456789 and symbols @ and _
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'], ... ]
Use sort to sort the above list and print out 3 most frequently mentioned usernames.
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.