Question: Write a Java application that implements a simple spell checker. The spell checker should work as follows: the user runs the application with the input

Write a Java application that implements a simple spell checker. The spell checker should work as follows: the user runs the application with the input file as an argument to the program, and then the program will parse the file and check if there are any tokens that are not in the dictionary, ignoring single characters (such as a or I) and numeric values. Any words that are not found in the dictionary will be printed (with no duplication) on the screen. Note that you do not need to worry about sorting output words or prompting the user for corrections.

You must test your program with the files bonk.txt (file to be spell checked) and dictionary.txt (an optimized dictionary).

Sample run: C:\PathName> java SpellChecker bonk.txt Application description goes here (this is a sampleyou need to provide your own). Reading input file: bonk.txt Duke Bonk semi affectionately Bonkistry etc Chem UVirginia hangovers everything UVa Unprepared

Spellchecker.java file

public class SpellChecker { /** * This method takes in a filename and spells check it * @param filename an input file stream (i.e. bonk.txt) * @return ArrayList list of words not found in dictionary */ public ArraysList spell(String filename) { // method body } /** * This method takes the list of words not found in the dictionary * and prints a list of non-duplicate words * @param ArrayList List of words not found in dictionary */ public void printNonDuplicates(ArrayList ) { // method body }

/** * This method returns true if a word in input file stream * (i.e. bonk.txt) is in the dictionary, false otherwise. * @param word a string that contains a word to be checked * @return the boolean status of the word (i.e. true or false) */ public boolean inDictionary(String word, String[] dictionary) { // method body } public static void main(String[] args) { // Prompt the user to enter a file to be spell checked SpellChecker sc = new SpellChecker(); sc.spell(filename); } }

bonk.txt file

Introductory Chemistry at Duke has been taught for about a zillion years by Professor Bonk (really), and his course is semi-affectionately known as "Bonkistry." He has been around forever, so I would not put it past him to come up with something like this. Anyway, one year there were these two guys who were taking Chemistry and who did pretty well on all of the quizzes and the midterms and labs, etc., such that going into the final they had a solid A. These two friends were so confident going into the final that the weekend before finals week (even though the Chem final was on Monday), they decided to go up to UVirginia and party with some friends up there. So they did this and had a great time. However, with their hangovers and everything, they overslept all day Sunday and did not make it back to Duke until early monday morning. Rather than taking the final then, what they did was to find Professor Bonk after the final and explain to him why they missed the final. They told him that they went up to UVa for the weekend, and had planned to come back in time to study, but that they had a flat tire on the way back and did not have a spare and could not get help for a long time and so were late getting back to campus. Bonk thought this over and then agreed that they could make up the final on the following day. The two guys were elated and relieved.

So, they studied that night and went in the next day at the time that Bonk had told them. He placed them in separate rooms and handed each of them a test booklet and told them to begin. They looked at the first problem, which was something simple about molarity and solutions and was worth 5 points. "Cool" they thought, "this is going to be easy." They did that problem and then turned the page. They were unprepared, however, for what they saw on the next page. It said:

(95 points) Which tire?

dictionary.txt file

a at and an he why though examination professor chemistry has been taught for about zillion year years by introductory really his course is known as around forever so I would not put it past him to come up with some thing something like this anyway one there were are these well decided have two guys who were take taking did pretty very good on all of the quiz quizzes midterm midterms lab labs such that go goes going into final had they solid friend friends so were confident going into weekend before finals week even through Monday decide go up party with great time however hangover their overslept all day Sunday make back it until early monday morning rather than taking then what find after explain missed told went weekend planned had come back time study but flat tire way back spare could get help long late getting campus thought over agreed make up following guys elated relieved studied night next told placed them in separate rooms handed each of test booklet begin looked first problem something simple about molarity solutions was worth five points cool going turned page saw said needles pass which be easy

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 Databases Questions!