Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- LinearProbingHashST<String, String> st = new LinearProbingHashST<String, String>();
- // reads the text file with collections of misspellings and corresponding
- // correct spelling of words and puts into hash table
- In dictionary = new In(args[0]);
- while (dictionary.hasNextLine()) {
- String misspelled = dictionary.readString();
- String corrected = dictionary.readLine().trim();
- st.put(misspelled, corrected);
- }
- System.out.println();
- // reads the second file of text with eventual misspellings and replaces
- // these with the correct ones
- Scanner sc = new Scanner(System.in);
- while (sc.hasNext()) {
- String next = sc.next();
- if (st.contains(next)) System.out.print(st.get(next) + " ");
- else System.out.print(next + " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement