Program 5: Word Frequencies (Concordance)    Use a text editor to create a text file (ex: myPaper.txt) It should contain at least 2 paragraphs with around 200 or more words. Write a Python program (HW19.py) that asks the user to provide the name of the text file. Be SURE to check that it exists!Do NOT hard-code the name of the file! Use the entry provided by the user! read from the text file NOTE: (write your program so that it ONLY works if it reads from the file specified by the user). Your program will produce a dictionary of words with the number of times each occurs. It maps a word to the number of times the word occurs Key: a word Value: the number of times the word occurs in the text. The report should be an ALPHABETIZED output table, listing the word and the number of occurrences. NOTES: The input sequence can be words, numbers or any other immutable Python object, suitable for adict    Ignore case – apple is the same as Apple is the same as APPLE, etc. Discard all punctuation and extra white space (newlines, tabs, blanks, etc.). Put the words into a The first time a word is seen, the frequency is 1. Each time the word is seen again, increment the frequency. NOTE:  you are REQUIRED to use the dictionary class for this assignment. Produce a frequency table. To alphabetize the frequency table, extract just the keys and sort them. This sorted sequence of keys can be used to extract the counts from thedict. Make sure that your output (the table) is formatted so that the columns are aligned, and so that there are titles for each column. Be sure to modularize your code, using functions appropriately. The main function should be clean and easy to read, calling the functions with meaningful names. Pass parameters – do not use global variables. BONUS  +5 pts: Create a menu-driven front-end to this application. First, populate the dictionary from the file Next, provide a menu that allows the user to Add words to the dictionaryafter asking the user for the word to add        Note:  the count should increase if the word is already there) Check if a word is already in the dictionary Delete a word from the dictionary after asking the user for the word to delete Print the dictionary entries in table form as described above. Allow the user to continue using the menu until they choose the option to quit.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Program 5: Word Frequencies (Concordance)   

  1. Use a text editor to create a text file (ex: myPaper.txt) It should contain at least 2 paragraphs with around 200 or more words.
  2. Write a Python program (HW19.py) that
  • asks the user to provide the name of the text file. Be SURE to check that it exists!
    Do NOT hard-code the name of the file! Use the entry provided by the user!
  • read from the text file
  • NOTE: (write your program so that it ONLY works if it reads from the file specified by the user).
  1. Your program will produce a dictionary of words with the number of times each occurs. It maps a word to the number of times the word occurs
  • Key: a word
  • Value: the number of times the word occurs in the text. The report should be an ALPHABETIZED output table, listing the word and the number of occurrences.

NOTES:

  • The input sequence can be words, numbers or any other immutable Python object, suitable for adict   

  • Ignore case – apple is the same as Apple is the same as APPLE, etc.

  • Discard all punctuation and extra white space (newlines, tabs, blanks, etc.).

  • Put the words into a The first time a word is seen, the frequency is 1. Each time the word is seen again, increment the frequency. NOTE:  you are REQUIRED to use the dictionary class for this assignment.

  • Produce a frequency table. To alphabetize the frequency table, extract just the keys and sort them. This sorted sequence of keys can be used to extract the counts from thedict.

  • Make sure that your output (the table) is formatted so that the columns are aligned, and so that there are titles for each column.

  • Be sure to modularize your code, using functions appropriately.
  • The main function should be clean and easy to read, calling the functions with meaningful names. Pass parameters – do not use global variables.

BONUS  +5 pts:

  • Create a menu-driven front-end to this application.
    • First, populate the dictionary from the file
    • Next, provide a menu that allows the user to
      • Add words to the dictionary
        after asking the user for the word to add
                Note:  the count should increase if the word is already there)
      • Check if a word is already in the dictionary
      • Delete a word from the dictionary after asking the user for the word to delete
      • Print the dictionary entries in table form as described above.

    • Allow the user to continue using the menu until they choose the option to quit.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr