本文整理汇总了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