logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Garima ThakurFinance
(5/5)

692 Answers

Hire Me
expert
Gary BambrickResume writing
(5/5)

880 Answers

Hire Me
expert
StatAnalytica ExpertSocial sciences
(5/5)

592 Answers

Hire Me
expert
Faith BrownnComputer science
(4/5)

792 Answers

Hire Me
Linear Programming

word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Program 3 should first tell users that this is a word analysis program. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file.

A word may appear in multiple lines. If a word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file. Using try/except for invalid user input. The program reads the contents of the text file, strip/remove new-line and punctuation characters, and then create a dictionary in which the key-value pairs are described as follows:

• Key. the words found in the file.

• Value. Is a list that contains the line numbers in the file where the word (the key) is found. Be aware that a list may have only one element. Once the dictionary has been built, the program should create another text file for output, named “words_index.txt”. Next, write the contents of the dictionary to the file as an alphabetical listing of the words that are stored as keys in the dictionary (sorting the keys), along with the line numbers where the words appear in the original file.

Please see the sample file for your reference. Your program must write/create at least 4 functions:

1. a function gets the input file name from the user

2. a function creates the dictionary

3. (Bonus, 10 Points) a function to write the top 6 words by the number they appear in the input file by descending order with the number to the output file “words_index.txt”.

4. a function to write the alphabetical listing of the words with their line numbers to the output file “words_index.txt”.

5. the main() function which the program starts here. Looking to seeing everyone to submit a well-done program! Here are some tips:

• Documents/Comments of your program (Never more)

• Testing your program by the given two sample files, input file “romeo.txt” and output file “romeo_index.txt”

 • Remember the output file name of your program is words_index.txt.

• For this program, not running one (syntax error) will receive NO point. • Be sure each line of the code and its comment is your own. romeo.txt But $soft! What light through yonder window breaks? It is the east and Juliet is @the sun. Arise fair sun and kill the envious moon, Who is already sick# and pale with grief! romeo_index.txt Text File to be analyzed: romeo.txt The top 6 Most Common Words: and:3 the:2 sun:2 is:

2 yonder:

1 The alphabetical listing of the words: Arise : 3 But : 1 It : 2 Juliet : 2 Who : 4 already :

4 and : 2, 3, 4 breaks : 1 east : 2 envious : 3 fair : 3 grief : 4 is : 2, 4 kill : 3 light : 1 moon : 3 pale : 4 sick : 4 soft : 1 sun : 2, 3 the : 2, 3 through : 1 what : 1 window : 1 with : 4 yonder : 1 PLEASE WRITE A UNIQUE CODE NO PLAGIRISM

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme