Question: Write an algorithm before writing the code and include a short write - up of the algorithm in a text file or PDF document along

Write an algorithm before writing the code and include a short write-up of the algorithm in a text file or PDF document along with the code. Remember to test your solution thoroughly. Code that does not work correctly or does not compile will lose credit. Please submit a digital copy, by the due date and time, via Canvas. The digital copy of your code should be a zip file containing the project folder named with your last name followed by the project number. For example, canetti2.zip would be my .zip file for project 02. Good luck!
Create a text editor program, to do this create (or select a text file) to edit. The program will read in this text file in and store the text. It will then present a menu to the user to manipulate the file. Note if using an existing file it must accompany your program such that your program can hardcode the location when run, if a file is created ensure it is creating the file in the same folder as the .py file (in both cases the program should run without editing the file location). The program itself should have the following functions and provide the user to edit the text in the following ways:
A 'AllWordCount' function which will count the frequency of each word in the file and output the top 5 most common words that appear.
Function 'SingleWordCount' will ask the user for a word as input (check to make sure is a single word, you might want to create a function to handle input is a single word) and output the number of times that word appears.
'ReplaceWord' will take a word as input and take another input as a replacement. It will replace the word and output the number of words changed.
The Function 'AddText' will add text to the existing text in the file
The 'DeleteText' function will take as input text and delete the first instance of that text from the file
The function 'HighLight' which will take an input word and then output the text with all instances of that word surrounded by symbols to make it easier to see.
example start text: "Hello this is tom and this is ann, we are both students"example output text highlighting 'this': "Hello **this** is Tom and **this** is Ann, we are both students"
Lastly there should be a function 'readTextFile' that reads the file and stores it for use in the program and another function 'saveTextFile' that will save all changes made to the text and should be called after all changes to the text.
Example Output:
```
===Edit Menu===
1: Top 5 most common words
2: Single Word Frequency
3: Replace a word
4: Add Text
5: Delete Text
6: Highlight Text
=============
>>input: 2
>>input Word: hello
HELLO appears 10 times in the text
===Edit Menu===
1: Top 5 most common words
2: Single Word Frequency
3: Replace a word
4: Add Text
5: Delete Text
6: Highlight Text
=============
>>input: 3
>>input target word: Hello
>>input replacement: Howdy
10 words replaced with HOWDY
```
Note your output does not need to look exactly the same

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!