/src/spelling/corrector/StatSpellingCorrector.java
Java | 31 lines | 27 code | 4 blank | 0 comment | 0 complexity | 5f9a73718c1af4ca5dc5a1d09e9a5872 MD5 | raw file
- package spelling.corrector;
-
- import java.util.Collection;
-
- public class StatSpellingCorrector implements SpellingCorrector {
- final private SpellingCorrector corrector;
- protected StatSpellingCorrector(SpellingCorrector corrector){
- this.corrector = corrector;
- }
- protected StatSpellingCorrector(){
- this(new DefaultSpellingCorrector(new StatSpellingCorrectorHelper()));
- }
- public String correct(String word) {
- System.out.println("StatSpellingCorrector.correct()");
- long begin = System.nanoTime();
- String correction = this.corrector.correct(word);
- long end = System.nanoTime();
- System.out.println("Elapsed time : "+ (end-begin) + " nanoseconds");
- return correction;
- }
-
- public Collection<String> getCandidates(String word) {
- System.out.println("StatSpellingCorrector.getCandidates()");
- long begin = System.nanoTime();
- Collection<String> result = this.corrector.getCandidates(word);
- long end = System.nanoTime();
- System.out.println("Elapsed time : "+ (end-begin) + " nanoseconds");
- return result;
- }
-
- }