In this project, you will develop a simple spell checker program that spots misspelled words in a file by checking each word in the file against a provided reference dictionary.

A list of correctly spelled English words is provided as a reference (ref.txt). There is one word per line in this file. The user file to be checked is a text file where each space-separated word of the file is to be examined. Punctuation, case, and numbers should be ignored. If a word from the file does not exist in the provided list then it is assumed to be misspelled.

After identifying the misspelled words, the program should prompt the user to enter a word and it should report the number of times the word appeared in the file.

Your program must do the following:

Read the reference file “ref.txt”. This file consists of words, one word per line. Use a dictionary container to store the words that are in the ref.txt.

Prompt the user for the name of the file to spell check. Program should read the words in the file and store the words in a dictionary container where the keys are the words in the file and values are the number of times the word is used in the file. Spellcheck each word and then display the words that were misspelled.

Prompt the user to enter a word and return the number of times the word was used in the file.

Make sure to eliminate the punctuation when constructing the dictionary from the input file.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

from collections import defaultdict

# punctation and numbers that need to be eliminated
punc_and_numbers = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~1234567890'

with open('ref.txt') as file: # read refernece file “ref.txt”
    ref =
    ref_words = ref.split()
    ref_dict = {}
    for key, value in enumerate(ref_words): # and store valies in a dictionary ref_dict
       ref_dict[key] = value

path_to_file = input('Input file name:') # prompt user to eneter path to file to spell check

with open(path_to_file) as file: #open the file and read the data
    sample =
    # strip all the punctuation and numbers, and convert all words to lowercase
    words = [word.strip(punc_and_numbers).lower() for word in sample.split()]
    for word in words: # if there are empty strings, remove them...

By purchasing this solution you'll be able to access the following files:

50% discount

$10.00 $5.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats