Question: Driver.java import java.io.*; public class Driver { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub SpellCheckInterface check = new SpellChecker(); check.loadDictionary(dictionary.txt);
Driver.java import java.io.*; public class Driver { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub SpellCheckInterface check = new SpellChecker(); check.loadDictionary("dictionary.txt"); if(check.checkDocument("test.txt")) System.out.println("No misspelled words found"); if(check.checkDocument("short.txt")) System.out.println("No misspelled words found"); } }_______________________________________________
SpellChecker.java![Driver.java import java.io.*; public class Driver { public static void main(String[] args)](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66cf5d09afd33_80166cf5d09a7b8c.jpg)
import java.util.*; import java.io.*; public class SpellChecker implements SpellCheckInterface { LinkedList dict; LinkedList misspelled; public SpellChecker() { dict = new LinkedList(); misspelled = new LinkedList(); } /** * Loads the dictionary contained in the specified file * * @param filename The name of the dictionary file to be loaded * @return true If the file was successfully loaded, false * if the file could not be loaded or was invalid * @throws IOException if filename does not exist */ @Override public boolean loadDictionary(String fileName) throws IOException { // Left as exercise return true; } /** * Check the document for misspelled words * * @return A list of misspelled words and * the line numbers where they occur. * @throws @throws IOException if filename does not exist */ @Override public boolean checkDocument(String fileName) throws IOException { misspelled = new LinkedList(); // Initialize for each file int lineNumber = 0; try { File infile = new File(fileName); System.out.println(" File Name:"+ fileName); try ( Scanner in = new Scanner(infile); ) { /* wrong code shold be deleted in.useDelimiter("[^A-Za-z]+"); // split input by words while (in.hasNext()){ String myWord = in.next().toLowerCase(); lineNumber++; */ // Correct code to be added while (in.hasNextLine()){ String line = in.nextLine().toLowerCase(); lineNumber++; String[] tokens = line.split("[ \\P{Alpha}]+"); for(int i=0;i ___________________________________________________
SpellCheckInterface.java
Details
Activity
Last month
Feb 18
B
Bahram Zartoshty shared an item

SpellCheckInterface.java

Can view
You
Feb 5
B
Bahram Zartoshty uploaded an item

SpellCheckInterface.java
No recorded activity before February 5, 2019
All selections cleared

import java.io.*; public interface SpellCheckInterface { /** * Loads the dictionary contained in the specified file * * @param filename The name of the dictionary file to be loaded * @return true If the file was successfully loaded, false * if the file could not be loaded or was invalid * @throws IOException if filename does not exist */ public boolean loadDictionary(String fileName) throws IOException; /** * Check the document for misspelled words * * @return true if the file was successfully spell checked, false * if the file had misspelled words * @throws IllegalArgumentException if filename is null */ public boolean checkDocument(String fileName) throws IOException; } ______________________________
Word.java
Details
Activity
Last month
Feb 18
B
Bahram Zartoshty shared an item

Word.java

Can view
You
Feb 5
B
Bahram Zartoshty uploaded an item

Word.java
No recorded activity before February 5, 2019
All selections cleared

import java.util.*; public class Word implements Comparable { private String word; private ArrayList lines; public Word() { lines = new ArrayList(); } public Word(String w, int lineNumber) { word = w; lines = new ArrayList(); lines.add(lineNumber); } public String getWord() { return word; } public ArrayList getLines() { return lines; } public void addLine(int lineNumber) { lines.add(lineNumber); } public String toString() { return word + " : "+lines.toString(); } /** *@return true if two words are equal, false otherwise */ @Override public boolean equals(Object w) { // Left as exercise } /** *@ compare two words and retun the corresponding integer value (0) */ @Override public int compareTo(Word w) { return this.word.compareTo(w.word); } }
Transcribed image text
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
