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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education