Subject Computer Science Java Programming

Question

Data Structures
In this assignment, you will write a spell-checker for text files. Your program should take a file name as a command-line argument and check the file for any misspelled words. If a word is misspelled, the program should output a line number and line containing the word and highlight the word by printing a sequence of carets (‘^’) underneath it on the next line.
Your program should consider any sequence of one or more letters separated by whitespace or punctuation a word. Do not attempt to handle words with apostrophes or other intra-word accents correctly: e.g. “you’re” should scan as “you” and “re”. The Character class has a method isLetter which you can use to determine whether a char is a letter in the alphabet.
The file words.txt contains a list of valid words. Use this file as your dictionary. For each word in the input file, scan through words.txt until a matching word is found; if no matching word is found, consider the word misspelled.
See below for words.txt

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;


public class SpellChecker {
public static void main(String[] args)
{
if(args.length != 1)
{
System.out.println("Please enter in the filename of document to check");
System.exit(0);
}

try{
BufferedReader in = new BufferedReader(new FileReader(args[0]));
int read, lineCount = 0;
String line = "", word = "";
while((line = in.readLine()) != null)...

This is only a preview of the solution. Please use the purchase button to see the entire solution

$20.00

or $1 if you
register a new account!

Related Homework Solutions

Get help from a qualified tutor
Live Chats