-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpellChecker.java
More file actions
34 lines (29 loc) · 901 Bytes
/
SpellChecker.java
File metadata and controls
34 lines (29 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
public class SpellChecker{
public static final String SYMBOL = "[^\\w]";
public static void main(String[] args) {
SpellDictionary dObject = new SpellDictionary("Dictionary.txt");
if(args.length == 0){
Scanner userFile = new Scanner(System.in);
ArrayList<String> file = new ArrayList<String>();
while(userFile.hasNextLine()){
String p = userFile.next();
p = p.toLowerCase().replaceAll(SYMBOL,"");
file.add(p);
}
for(int a = 0; a < file.size(); a++){
dObject.spellCheck(file.get(a));
}
}//closes if
else{
for(int i = 0; i < args.length; i++){
// dObject.checkWords(args[i]);
dObject.spellCheck(args[i]);
}
}
} //close main
}//close class