In this article, we are going to try use limited memory as we force to work on during early 50s. The memory limitation will force the programmer to come up with ways of rotating data through the available memory. Let discuss more on the program.
Practice with Memory limit Style
- Create a list of stop_words.txt to identify words.
- Create a function to open file and its option – r, rb (read or read binary)
- Next, we define a data list array to be used for loading the words from file.
- It will also include start index, index, flag, word, words and its memory position, frequency
- Read from the command input – file name (input.txt)
- In the main loop, read each line from input file.
- Get the value for each row and check if words are founded.
- Create word_freqs.txt file to store value word not found in stop words file.
- It will store the words and frequency
- If this is 1st time the word is found, then save into the file with reoccurrence = 1
- If more than 1, reoccurrence set to +=1
- Next, in the 2nd part of the code is to read the top 25 lines of word freq file
- Get the reoccurrence number and the word
- Print out the values.
Let try to run the program and see the outcome.
Thanks for reading and enjoy your day.