Question
In Java please In this assignment, you will write a simple spell-checker. Your program should be named Spell and take two file names as command-line
In Java please
In this assignment, you will write a simple spell-checker. Your program should be named Spell and take two file names as command-line arguments. Your program will be invoked from the command line as Spell dictionary.txt fileToCheck.txt The first file name is the dictionary with correctly spelled words. The second file is the text to be spell-checked. Your program should check all words in fileToCheck.txt. Nothing needs to be done for words that are correctly spelled, i.e. those found in the dictionary file. Your program should suggest possible correct spellings for words not in the dictionary file by printing to the standard output. You should perform the following modifications of a misspelled word to handle commonly made mistakes:
Letter substitution: iterate over characters in the misspelled word, trying to replace the current character with a different character. For example, in a misspelled word' lat', substituting' c' instead of' l' will produce the word' cat' in a dictionary. There are 25 different characters to try for the current character. Thus, if the length of a word is k characters, the number of modifications to try is 25k.
Letter omission: try to omit (in turn, one by one) a single character in the misspelled word and check if the resulting new word is in the dictionary. For example, if the misspelled word is' catt', omitting the last character' t' will produce the word' cat' in the dictionary. In this case, there are k modifications to try where k is the number of characters in the word.
Letter insertion: try to insert a letter in the misspelled word. For example, for' plce', inserting' a' after' l' produces a correctly spelled word' place'. If a word is k characters long, there are 26*(k+1) modifications to try since there are 26 characters to insert and k+1 places (including in the beginning and at the end of the word) to insert a character.
Letter reversal: Try swapping every pair of adjacent characters. For example, in' paernt', swapping' e' and' r' produces a correctly spelled word' parent'. For a word of length k, there are k - 1 pairs to swap.
You are to implement the program based on a dictionary data structure. First, your program should read all words from the input dictionary file (specified by the first command line argument) and insert them into a dictionary data structure, let us call it D. Then your program should open the second file (containing the text to be spell-checked). As you read words from the second file, if any word is not in D, that means it is a misspelled word that needs to be handled. You must try all possible modifications of the word outlined in the 'overview' section. It's expected that your implementation will convert all words into lowercase so that the words 'Cat' and' cat' are treated the same. Thus, all the words you read from a file using your program will be lowercase.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started