PageRenderTime 27ms CodeModel.GetById 22ms RepoModel.GetById 0ms 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
  1. package spell;
  2. import java.io.IOException;
  3. import spell.SpellCorrector.NoSimilarWordFoundException;
  4. /**
  5. * A simple main class for running the spelling corrector
  6. */
  7. public class Main {
  8. /**
  9. * Give the dictionary file name as the first argument and the word to correct
  10. * as the second argument.
  11. */
  12. public static void main(String[] args) throws NoSimilarWordFoundException, IOException {
  13. String dictionaryFileName = args[0];
  14. String inputWord = args[1];
  15. /**
  16. * Create an instance of your corrector here
  17. */
  18. SpellCorrector corrector = new SpellingCorrector();
  19. Trie trie1 = new Words();
  20. trie1.add("bob");
  21. trie1.add("karen");
  22. trie1.add("smith");
  23. trie1.add("smal");
  24. Trie trie2 = new Words();
  25. trie2.add("bob");
  26. trie2.add("karen");
  27. trie2.add("smith");
  28. trie2.add("smab");
  29. boolean test = trie1.equals(trie2);
  30. System.out.println(test);
  31. corrector.useDictionary(dictionaryFileName);
  32. String suggestion = corrector.suggestSimilarWord(inputWord);
  33. System.out.println("Suggestion is: " + suggestion);
  34. }
  35. }