diff --git a/uttut/pipeline/ops/utils/trie.py b/uttut/pipeline/ops/utils/trie.py index ca849d5..f80ea55 100644 --- a/uttut/pipeline/ops/utils/trie.py +++ b/uttut/pipeline/ops/utils/trie.py @@ -5,9 +5,7 @@ def __init__(self): self._word = None def has_child(self, key): - if key in self._children: - return True - return False + return key in self._children def get_child(self, key): return self._children[key] @@ -16,7 +14,10 @@ def insert_child(self, key): self._children[key] = TrieNode() def set_word(self, word): - self._word = word + if not self._word: + self._word = word + else: + raise ValueError('Word exists') def get_word(self): return self._word