PageRenderTime 61ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/src/spelling/corrector/StatSpellingCorrector.java

https://github.com/juliengrenier/java-spelling-corrector
Java | 31 lines | 27 code | 4 blank | 0 comment | 0 complexity | 5f9a73718c1af4ca5dc5a1d09e9a5872 MD5 | raw file
  1. package spelling.corrector;
  2. import java.util.Collection;
  3. public class StatSpellingCorrector implements SpellingCorrector {
  4. final private SpellingCorrector corrector;
  5. protected StatSpellingCorrector(SpellingCorrector corrector){
  6. this.corrector = corrector;
  7. }
  8. protected StatSpellingCorrector(){
  9. this(new DefaultSpellingCorrector(new StatSpellingCorrectorHelper()));
  10. }
  11. public String correct(String word) {
  12. System.out.println("StatSpellingCorrector.correct()");
  13. long begin = System.nanoTime();
  14. String correction = this.corrector.correct(word);
  15. long end = System.nanoTime();
  16. System.out.println("Elapsed time : "+ (end-begin) + " nanoseconds");
  17. return correction;
  18. }
  19. public Collection<String> getCandidates(String word) {
  20. System.out.println("StatSpellingCorrector.getCandidates()");
  21. long begin = System.nanoTime();
  22. Collection<String> result = this.corrector.getCandidates(word);
  23. long end = System.nanoTime();
  24. System.out.println("Elapsed time : "+ (end-begin) + " nanoseconds");
  25. return result;
  26. }
  27. }