Recursively builds the list of words. * v: Node to check * cWord : The word built up to v
(self, v, cWord)
| 87 | return None |
| 88 | |
| 89 | def build_word_list(self, v, cWord): |
| 90 | """ |
| 91 | Recursively builds the list of words. |
| 92 | * v: Node to check |
| 93 | * cWord : The word built up to v |
| 94 | """ |
| 95 | if(not v): |
| 96 | return None |
| 97 | |
| 98 | wList = [] |
| 99 | for i, k in v.children.items(): |
| 100 | tempWord = cWord + i |
| 101 | |
| 102 | if(k.word): |
| 103 | #If the iterated prefix is a word, add it to the list |
| 104 | wList.append(tempWord) |
| 105 | |
| 106 | #The list of words under tWord |
| 107 | wList.extend(self.build_word_list(k, tempWord)) |
| 108 | |
| 109 | return wList |