Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Omar Natour 11/30/16
- * Csc-220 Data Structures
- * Hw8 Spell checker
- * create a program that can check words against a created dictionary class
- * ojnatour0001@student.stcc.edu
- */
- package chapter24;
- import java.io.File;
- import java.io.FileNotFoundException;
- public class SpellCheck {
- static Dictionary English = new Dictionary();
- public static void main(String[] args) {
- English.loadDictionary("words2.txt");
- System.out.println(performCheck("sometext.txt"));
- }
- public static String performCheck(String filename) {
- String output = "";
- try {
- ScannerWithLineno sc = new ScannerWithLineno(new File("chapter24/sometext.txt"));
- while (sc.hasNext()) {
- String current = sc.next();
- if (!English.contains(current))
- output += "*" + current + "* ";
- else
- output += current + " ";
- }
- sc.close();
- } catch (FileNotFoundException fnfe) {
- System.err.println(fnfe);
- } catch (Exception e) {
- System.err.println(e);
- }
- return output;
- }
- }
Add Comment
Please, Sign In to add comment