/qualcheck/RunQualCheck.java

https://github.com/eswens13/RecordIndexer · Java · 46 lines · 23 code · 13 blank · 10 comment · 0 complexity · 886ffab2a732eb83680a766f1b9cdec0 MD5 · raw file

  1. package qualcheck;
  2. import java.io.IOException;
  3. import java.util.ArrayList;
  4. import qualcheck.SpellCorrector.NoSimilarWordFoundException;
  5. /**
  6. * A simple main class for running the spelling corrector
  7. */
  8. public class RunQualCheck {
  9. private Spell corrector;
  10. public RunQualCheck() {
  11. corrector = new Spell();
  12. }
  13. public String[] run(String dictionaryFilename, String word) throws IOException {
  14. corrector.useDictionary(dictionaryFilename);
  15. ArrayList<String> suggestions = new ArrayList<String>();
  16. try {
  17. suggestions = corrector.suggestSimilarWord(word);
  18. String[] suggestionsArray = new String[suggestions.size()];
  19. suggestions.toArray(suggestionsArray);
  20. return suggestionsArray;
  21. }
  22. catch(NoSimilarWordFoundException e) {
  23. return null;
  24. }
  25. }
  26. /*public static void main(String[] args) throws IOException {
  27. RunQualCheck rqc = new RunQualCheck();
  28. String[] words = rqc.run("testDictionary.txt", "mai");
  29. for(String word: words) {
  30. System.out.println(word);
  31. }
  32. }*/
  33. }