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.javaDriver.java import java.io.*; public class Driver { public static void main(String[] args)

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

throws IOException{ // TODO Auto-generated method stub SpellCheckInterface check = new SpellChecker();

SpellCheckInterface.java

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"); }

Can view

You

Feb 5

B

Bahram Zartoshty uploaded an item

} _______________________________________________ SpellChecker.java import java.util.*; import java.io.*; public class SpellChecker implements SpellCheckInterface

SpellCheckInterface.java

No recorded activity before February 5, 2019

All selections cleared

{ LinkedList dict; LinkedList misspelled; public SpellChecker() { dict = new LinkedList();

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

misspelled = new LinkedList(); } /** * Loads the dictionary contained in

Word.java

the specified file * * @param filename The name of the dictionary

Can view

You

Feb 5

B

Bahram Zartoshty uploaded an item

file to be loaded * @return true If the file was successfully

Word.java

No recorded activity before February 5, 2019

All selections cleared

loaded, false * if the file could not be loaded or was

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

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!