Subject Computer Science Python Programming

Question

Word Counter

Overview
Create a program that analyzes a text file and counts how many time various words are used within it.
User flow
1. The program asks a user what file to open.
2. The program then asks the user to enter a comma-separated list of words to analyze within the file.
3. The program then outputs the frequency of each word within the file.

Sample session
User responses are bold.
What file would you like to open? universal_declaration_of_human_rights_in_nigerian_pidgin_english.txt
What words would you like to search for? wey, dem, unifasiti, ting

... analyzing ... hold on ...

Frequency of word usage within universal_declaration_of_human_rights_in_nigerian_pidgin_english.txt:
    wey               / 19 occurrences
    dem             / 17 occurrences
    unifasiti       / 22 occurrences
    ting             / 63 occurrences

Requirements
▪ Include a sample text file along with your code when submitting your assignment. Package both files into a zip file.
▪ If the user includes spaces in their list of words (as I have done in the example session above), they should be stripped out and ignored.
▪ capitalization should be ignored.
▪ there is no limit to how many words the user can enter.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#def main():
filename = input("What file would you like to open?: ")
# shakespeare.txt...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats