Advertisement
natalierey

Untitled

Feb 13th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. // sig = "228"
  2. @Override
  3. public Set<String> signatureToWords(String signiture)
  4. {
  5. Set<String> matching = new HashSet<String>();
  6.  
  7. System.out.println("i = " + i);
  8. if (i>0)
  9. {
  10. System.out.println("current tree: " + currentTree.getValue());
  11. }
  12.  
  13. if (i == signiture.length())
  14. {
  15. if (i==0)
  16. {
  17. throw new IllegalArgumentException("Word must not be null");
  18. }
  19. else
  20. {
  21. for (int j=0; j<currentTree.getValue().size(); j++)
  22. {
  23. matching.add(currentTree.getValue().get(j));
  24. }
  25. System.out.println("matching words added.");
  26. System.out.println("matching"+ matching);
  27. }
  28. System.out.println("matching set size: " + matching.size());
  29. return matching;
  30. }
  31. else
  32. {
  33. if (i < signiture.length())
  34. {
  35. if (signiture.charAt(i) == '2')
  36. {
  37. if (i==0)
  38. {
  39. currentTree = dictionaryTree.getT2();
  40. }
  41. else
  42. {
  43. currentTree = currentTree.getT2();
  44. }
  45. i+=1;
  46. signatureToWords(signiture);
  47. }
  48. else if (signiture.charAt(i) == '3')
  49. {
  50. if (i==0)
  51. {
  52. currentTree = dictionaryTree.getT3();
  53. }
  54. else
  55. {
  56. currentTree = currentTree.getT3();
  57. }
  58. i+=1;
  59. signatureToWords(signiture);
  60. }
  61. else if (signiture.charAt(i) == '4')
  62. {
  63. if (i==0)
  64. {
  65. currentTree = dictionaryTree.getT4();
  66. }
  67. else
  68. {
  69. currentTree = currentTree.getT4();
  70. }
  71. i+=1;
  72. signatureToWords(signiture);
  73. }
  74. else if (signiture.charAt(i) == '5')
  75. {
  76. if (i==0)
  77. {
  78. currentTree = dictionaryTree.getT5();
  79. }
  80. else
  81. {
  82. currentTree = currentTree.getT5();
  83. }
  84. i+=1;
  85. signatureToWords(signiture);
  86. }
  87. else if (signiture.charAt(i) == '6')
  88. {
  89. if (i==0)
  90. {
  91. currentTree = dictionaryTree.getT6();
  92. }
  93. else
  94. {
  95. currentTree = currentTree.getT6();
  96. }
  97. i+=1;
  98. signatureToWords(signiture);
  99. }
  100. else if (signiture.charAt(i) == '7')
  101. {
  102. if (i==0)
  103. {
  104. currentTree = dictionaryTree.getT7();
  105. }
  106. else
  107. {
  108. currentTree = currentTree.getT7();
  109. }
  110. i+=1;
  111. signatureToWords(signiture);
  112. }
  113. else if (signiture.charAt(i) == '8')
  114. {
  115. if (i==0)
  116. {
  117. currentTree = dictionaryTree.getT8();
  118. }
  119. else
  120. {
  121. currentTree = currentTree.getT8();
  122. }
  123. i+=1;
  124. signatureToWords(signiture);
  125. }
  126. else if (signiture.charAt(i) == '9')
  127. {
  128. if (i==0)
  129. {
  130. currentTree = dictionaryTree.getT9();
  131. }
  132. else
  133. {
  134. currentTree = currentTree.getT9();
  135. }
  136. i+=1;
  137. signatureToWords(signiture);
  138. }
  139. }
  140. System.out.println("matching size is now: " + matching.size());
  141. }
  142. return matching;
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement