PageRenderTime 23ms CodeModel.GetById 21ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/spell/Main.java

https://gitlab.com/mountain01/spelling-corrector
Java | 50 lines | 25 code | 15 blank | 10 comment | 0 complexity | 290891d9bfb78506ef1501d12ffe2b10 MD5 | raw file
 1package spell;
 2
 3import java.io.IOException;
 4
 5import spell.SpellCorrector.NoSimilarWordFoundException;
 6
 7/**
 8 * A simple main class for running the spelling corrector
 9 */
10public class Main {
11	
12	/**
13	 * Give the dictionary file name as the first argument and the word to correct
14	 * as the second argument.
15	 */
16	public static void main(String[] args) throws NoSimilarWordFoundException, IOException {
17		
18		String dictionaryFileName = args[0];
19		String inputWord = args[1];
20		
21		/**
22		 * Create an instance of your corrector here
23		 */
24		SpellCorrector corrector = new SpellingCorrector();
25        Trie trie1 = new Words();
26
27        trie1.add("bob");
28        trie1.add("karen");
29        trie1.add("smith");
30        trie1.add("smal");
31
32        Trie trie2 = new Words();
33
34        trie2.add("bob");
35        trie2.add("karen");
36        trie2.add("smith");
37        trie2.add("smab");
38
39        boolean test = trie1.equals(trie2);
40
41        System.out.println(test);
42
43		corrector.useDictionary(dictionaryFileName);
44
45		String suggestion = corrector.suggestSimilarWord(inputWord);
46		
47		System.out.println("Suggestion is: " + suggestion);
48	}
49
50}