jweinst1
12/9/2015 - 8:48 AM

statementtrie.py

statementtrie.py

#statement trie

class strie (object):
	
	def __init__(self):
		self.trie = {}
	def __repr__(self):
		return str(self.trie)
	def __str__(self):
		return str(self.trie)
	def statement(self, phrase):
		words = phrase.split()
		current = self.trie
		while len(words) > 0:
			word = words.pop(0)
			if word in current.keys():
				current = current[word]
			else:
				current[word] = {}
				current = current[word]