Advertisement
natalierey

Untitled

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