Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need a python script that can do the following: 1. Develop an application that

ID: 3779980 • Letter: I

Question

I need a python script that can do the following:

1. Develop an application that takes the name of a text file as input, computes the frequency of every word in the file, and stores the resulting (word, frequency) pairs in a new table named Wordcounts of a new database file. The table should have columns Word and Freq for storing the (word, frequency) pairs.

2. Write a sql query to show how many ‘people’ in the file. Note: your code should be able to handle case sensitivity.

words txt Do it any way People are often unreasonable irrational, and self-centered. Forgive them anyway. If you are kind, people may accuse you of selfish ulterior motives Be kind anyway. If you are successful, you will win some unfaithful friends and some genuine enemies. Succeed anyway. If you are honest and sincere people may deceive you. Be honest and sincere anyway. What you spend years creating other could destroy overnight. Create anyway. If you find serenity and happiness some may be jealous. Be happy anyway. The good you do today, will often be forgotten Do good anyway Give the best you have, and it will never be enough. Give your best anyway.

Explanation / Answer

Solution1:

import re
freq = {}
doc_text = open('G:/projects/work/chegg/word_count/test.txt', 'r')
text = doc_text.read().lower()
match_pattern = re.findall(r'[a-z]{3,15}', text)

for word in match_pattern:
c = freq.get(word,0)
freq[word] = c + 1

freq_list = freq.keys()

for words in freq_list:
print(words, freq[words])
  
f = open('G:/projects/work/chegg/word_count/Wordcounts.txt', 'w')
for words in freq_list:
f.write(str(words))
f.write(" ")
f.write(str(freq[words]))
f.write(" ")
f.close()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote