/qualcheck/RunQualCheck.java
https://github.com/eswens13/RecordIndexer · Java · 46 lines · 23 code · 13 blank · 10 comment · 0 complexity · 886ffab2a732eb83680a766f1b9cdec0 MD5 · raw file
- package qualcheck;
- import java.io.IOException;
- import java.util.ArrayList;
- import qualcheck.SpellCorrector.NoSimilarWordFoundException;
- /**
- * A simple main class for running the spelling corrector
- */
- public class RunQualCheck {
-
- private Spell corrector;
-
- public RunQualCheck() {
- corrector = new Spell();
- }
-
- public String[] run(String dictionaryFilename, String word) throws IOException {
-
- corrector.useDictionary(dictionaryFilename);
- ArrayList<String> suggestions = new ArrayList<String>();
- try {
- suggestions = corrector.suggestSimilarWord(word);
-
- String[] suggestionsArray = new String[suggestions.size()];
- suggestions.toArray(suggestionsArray);
-
- return suggestionsArray;
- }
- catch(NoSimilarWordFoundException e) {
- return null;
- }
-
- }
-
-
- /*public static void main(String[] args) throws IOException {
- RunQualCheck rqc = new RunQualCheck();
- String[] words = rqc.run("testDictionary.txt", "mai");
- for(String word: words) {
- System.out.println(word);
- }
- }*/
- }