本文整理匯總了Python中adapt.tools.text.trie.Trie.lookup方法的典型用法代碼示例。如果您正苦於以下問題:Python Trie.lookup方法的具體用法?Python Trie.lookup怎麽用?Python Trie.lookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類adapt.tools.text.trie.Trie
的用法示例。
在下文中一共展示了Trie.lookup方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_retrieval_based_on_insertion_order
# 需要導入模塊: from adapt.tools.text.trie import Trie [as 別名]
# 或者: from adapt.tools.text.trie.Trie import lookup [as 別名]
def test_retrieval_based_on_insertion_order(self):
trie = Trie()
trie.insert("rest")
trie.insert("restaurant")
results = list(trie.lookup("rest"))
assert len(results) == 1
results = list(trie.lookup("restaurant"))
assert len(results) == 1
示例2: test_edit_distance
# 需要導入模塊: from adapt.tools.text.trie import Trie [as 別名]
# 或者: from adapt.tools.text.trie.Trie import lookup [as 別名]
def test_edit_distance(self):
trie = Trie(max_edit_distance=1)
trie.insert("restaurant")
results = list(trie.lookup("restauran"))
assert len(results) == 1
results = list(trie.lookup("estaurant"))
assert len(results) == 1
results = list(trie.lookup("estauran"))
assert len(results) == 0
示例3: test_simple_remove
# 需要導入模塊: from adapt.tools.text.trie import Trie [as 別名]
# 或者: from adapt.tools.text.trie.Trie import lookup [as 別名]
def test_simple_remove(self):
trie = Trie()
trie.insert("1", "Number")
results = list(trie.lookup("1"))
assert len(results) == 1
assert len(results[0].get('data')) == 1
assert trie.remove("1")
results = list(trie.lookup("1"))
assert len(results) == 0
示例4: test_named_remove
# 需要導入模塊: from adapt.tools.text.trie import Trie [as 別名]
# 或者: from adapt.tools.text.trie.Trie import lookup [as 別名]
def test_named_remove(self):
trie = Trie()
trie.insert("1", "Number")
trie.insert("1", "The Loneliest")
results = list(trie.lookup("1"))
assert len(results) == 1
assert len(results[0].get('data')) == 2
assert trie.remove("1", "Number")
results = list(trie.lookup("1"))
assert len(results) == 1
assert len(results[0].get('data')) == 1
示例5: test_data_is_correct_on_insert
# 需要導入模塊: from adapt.tools.text.trie import Trie [as 別名]
# 或者: from adapt.tools.text.trie.Trie import lookup [as 別名]
def test_data_is_correct_on_insert(self):
trie = Trie()
trie.insert("restaurant", "Concept")
results = list(trie.lookup("restaurant"))
assert len(results) == 1
assert len(results[0].get('data')) == 1
data = list(results[0].get('data'))
assert data[0] == 'Concept'
示例6: test_basic_retrieval
# 需要導入模塊: from adapt.tools.text.trie import Trie [as 別名]
# 或者: from adapt.tools.text.trie.Trie import lookup [as 別名]
def test_basic_retrieval(self):
trie = Trie()
trie.insert("restaurant")
results = list(trie.lookup("restaurant"))
assert len(results) == 1