very simple, question 1, part 1 part 2, and phases 1 and 2
COMP 2503 Task 5 Fall 2021 This is a temporary work document to save and modify your responses. Once you have completed the questions and are ready to submit, copy and paste your responses into the google form. Emailed submissions of this document will not be accepted. Reminder: Check the task rubric to see how you will be marked and hints at important things to include Total marks 20 Tasks are due on the date and time indicated. Any late tasks will lose 10% per day (including weekends) and no assignments will be accepted after 5 days late. Due: Thursday, Dec 9th before midnight, Weight: 11% For the questions below you, will need to import all the provided code into a single project and make sure that Junit has been added to the project. Question 1 - Part 1 [5 marks] Revenge of the contact system For this question, you will be once again modifying a small program that currently uses an ArrayList to store information to now store the data in the built in java Hashtable. In the package ContactSystem, you will find a small program that allows a user to add, remove, and update a list of contacts (name, email, ect..). Question 1 - Part 2 [15 marks] Spell For this question, you will me completing a program that implements a very basic spell checker that uses a hash table to store a list of known misspelled words. Description The basic execution of the program should be as follows: 1. Open a file that contains a list of known misspelled words and how they should properly be spelled. 2. Fill a hash table based upon the wrong words in the file. Here the key will be the “wrong word” and the value stored will be the correct spelling for the word. 3. Open a text file that will be checked for any misspelled worlds 4. The final list of found wrong words is then displayed on the console. a. For each wrong word it must indicated the line number the word was found on and the location in the line of the word. The location of the word is equal to the number of words that appear before it in the line plus 1. For example: “This is a test acheive”. In this line “achieve” is spelt wrong and is the fifth word in the line. For this assignment you are given some basic classes that you must use along with a driver and skeleton class for the Spell Checker. You have also been provided with a directory of test files “test_Data”. Add this directory to your project. COMP 2503 Task 5 Fall 2021 Provided Code Do not rename any of the classes or methods you have been provided with Driver.java – contains the main for the program SpellChecker.java – the skeleton class where you will insert your code. o Note: it would be a good idea to add other classes to create a good design. o Leave the current method definitions in the SpellChecker exactly as they are now so that the test driver used during marking can properly create and work with your class. MisspelledWordFound.java – A class used to return your final results. Phase 1 : Fill the Hash Table with Misspelled Words For phase 1 of the project you have to open the file of known misspelled words and fill the hash table. Below are the basic steps you should follow to complete this phase: 1. You can use the Hashtable class ( java.util ) or Hashmap (java.util) for this assignment. 2. The name of the file containing the list of misspelled worlds is passed into the constructor of the SpellChecker class. From here you must open the file and read in all the information and store it in the table. 3. Each line in the file has the following format: a. [wrongword][space][correct word] b. Example: accross across 4. You will not have to deal with any error checking of the input file. It will always be in this format 5. As you read in each line you should break it into the misspelled world and correctly spelled word 6. Insert the word into your hash table (key = misspelled word, data = correctly spelled word) a. Remember : the key should be case insensitive 7. Once you have this phase completed in full and verified move onto phase 2. COMP 2503 Task 5 Fall 2021 Phase 2: Checking a file for spelling mistakes In this phase you will now be using your Hash table built in phase 1 to check a file for possible spelling mistakes. In the SpellChecker class you will find a method called checkFile. The basics steps this method should follow are given below: 1. Open the file using the name passed to the checkFile method a. Note: for all test input files you will never have to deal with any kind of punctuation or brackets. Every line will only have words separated by spaces. 2. Loop through all the words in the file. If you find a misspelled work, create a new MisspelledWordFound object and store all necessary information and add it to your result list. You must include the line the word was found on and the word location within that line. For example: “This is a test acheive”. In this line “achieve” is spelt wrong and is the fifth word in the line. 3. Return the array list of results from the checkFile method. 4. If you have done everything proper then the main driver should print out all the found spelling mistakes. For example given the following text: This is a test acheive another ecstacy test The resulting output should be: line=1, wordLocation=5, originalWord=acheive, correctWord=achieve line=2, wordLocation=2, originalWord=ecstacy, correctWord=ecstasy COMP 2503 Task 5 Fall 2021 Example output Misspelled word file: WrongWords1 Input file to check: TestInput1A Expected output: line=1, wordLocation=5, originalWord=acheive, correctWord=achieve line=2, wordLocation=2, originalWord=ecstacy, correctWord=ecstasy Misspelled word file: WrongWords2 Input file to check: TestInput1B Expected output: line=1, wordLocation=5, originalWord=acheive, correctWord=achieve line=2, wordLocation=2, originalWord=ecstacy, correctWord=ecstasy Misspelled word file: WrongWords2 Input file to check: TestInput1A Expected output: line=1, wordLocation=2, originalWord=apparantly, correctWord=apparently line=1, wordLocation=6, originalWord=acheive, correctWord=achieve line=2, wordLocation=2, originalWord=ecstacy, correctWord=ecstasy line=3, wordLocation=1, originalWord=collegue, correctWord=colleague line=4, wordLocation=3, originalWord=gaurd, correctWord=guard COMP 2503 Task 5 Fall 2021 Misspelled word file: WrongWords3 DiffCase Input file to check: TestInput1A Expected output: line=1, wordLocation=5, originalWord=acheive, correctWord=achieve line=2, wordLocation=2, originalWord=ecstacy, correctWord=ecstasy Misspelled word file: WrongWords2 Input file to check: TestInput DiffCase Expected output: line=1, wordLocation=5, originalWord=ACHEIVE, correctWord=achieve line=2, wordLocation=2, originalWord=EcstacY, correctWord=ecstasy