PageRenderTime 358ms CodeModel.GetById 58ms RepoModel.GetById 1ms app.codeStats 0ms

/src/spelling/corrector/StatSpellingCorrectorHelper.java

https://github.com/juliengrenier/java-spelling-corrector
Java | 75 lines | 64 code | 11 blank | 0 comment | 0 complexity | cd134a04b69b9e3814e5494260d343ed MD5 | raw file
  1. package spelling.corrector;
  2. import java.util.Collection;
  3. import java.util.List;
  4. public class StatSpellingCorrectorHelper implements SpellingCorrectorHelper {
  5. final private SpellingCorrectorHelper helper;
  6. protected StatSpellingCorrectorHelper(SpellingCorrectorHelper helper) {
  7. this.helper = helper;
  8. }
  9. protected StatSpellingCorrectorHelper() {
  10. this(new DefaultSpellingCorrectorHelper());
  11. }
  12. public List<String> getAlterations(String word) {
  13. System.out.println("StatSpellingCorrectorHelper.getAlterations()");
  14. long begin = System.nanoTime();
  15. List<String> result = this.helper.getAlterations(word);
  16. long end = System.nanoTime();
  17. System.out.println("Elapsed time : " + (end - begin) + " nanoseconds");
  18. return result;
  19. }
  20. public List<String> getDeletion(String word) {
  21. System.out.println("StatSpellingCorrectorHelper.getDeletion()");
  22. long begin = System.nanoTime();
  23. List<String> result = this.helper.getDeletion(word);
  24. long end = System.nanoTime();
  25. System.out.println("Elapsed time : " + (end - begin) + " nanoseconds");
  26. return result;
  27. }
  28. public List<String> getInsertions(String word) {
  29. System.out.println("StatSpellingCorrectorHelper.getInsertions()");
  30. long begin = System.nanoTime();
  31. List<String> result = this.helper.getInsertions(word);
  32. long end = System.nanoTime();
  33. System.out.println("Elapsed time : " + (end - begin) + " nanoseconds");
  34. return result;
  35. }
  36. public List<String> getTransposition(String word) {
  37. System.out.println("StatSpellingCorrectorHelper.getTransposition()");
  38. long begin = System.nanoTime();
  39. List<String> result = this.helper.getTransposition(word);
  40. long end = System.nanoTime();
  41. System.out.println("Elapsed time : " + (end - begin) + " nanoseconds");
  42. return result;
  43. }
  44. public Collection<String> getFirstDegreeAlternatives(String word) {
  45. System.out.println("StatSpellingCorrectorHelper.getAlternatives()");
  46. long begin = System.nanoTime();
  47. Collection<String> result = this.helper
  48. .getFirstDegreeAlternatives(word);
  49. long end = System.nanoTime();
  50. System.out.println("Elapsed time : " + (end - begin) + " nanoseconds");
  51. return result;
  52. }
  53. public Collection<String> getSecondDegreeAlternatives(
  54. Collection<String> words) {
  55. System.out
  56. .println("StatSpellingCorrectorHelper.getKnown_Alternatives()");
  57. long begin = System.nanoTime();
  58. Collection<String> result = this.helper
  59. .getSecondDegreeAlternatives(words);
  60. long end = System.nanoTime();
  61. System.out.println("Elapsed time : " + (end - begin) + " nanoseconds");
  62. return result;
  63. }
  64. }