本文整理汇总了Python中adapt.tools.text.trie.Trie.gather方法的典型用法代码示例。如果您正苦于以下问题:Python Trie.gather方法的具体用法?Python Trie.gather怎么用?Python Trie.gather使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类adapt.tools.text.trie.Trie
的用法示例。
在下文中一共展示了Trie.gather方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_edit_distance_confidence
# 需要导入模块: from adapt.tools.text.trie import Trie [as 别名]
# 或者: from adapt.tools.text.trie.Trie import gather [as 别名]
def test_edit_distance_confidence(self):
trie = Trie(max_edit_distance=2)
trie.insert("a")
trie.insert("bb")
trie.insert("ccc")
trie.insert("dddd")
trie.insert("100")
results = list(trie.gather("b"))
assert len(results) == 1
assert results[0].get('confidence') == 0.5
results = list(trie.gather("1 of"))
assert len(results) == 3
示例2: test_gather
# 需要导入模块: from adapt.tools.text.trie import Trie [as 别名]
# 或者: from adapt.tools.text.trie.Trie import gather [as 别名]
def test_gather(self):
trie = Trie()
trie.insert("rest")
trie.insert("restaurant")
results = list(trie.gather("restaurant"))
assert len(results) == 1
assert results[0].get('key') == "restaurant"
示例3: test_insert_single_character_entity
# 需要导入模块: from adapt.tools.text.trie import Trie [as 别名]
# 或者: from adapt.tools.text.trie.Trie import gather [as 别名]
def test_insert_single_character_entity(self):
trie = Trie()
trie.insert("1", "Number")
results = list(trie.gather("1 of the big bang theory"))
assert len(results) == 1
assert len(results[0].get('data')) == 1
示例4: test_retrieval_of_multi_word_entity
# 需要导入模块: from adapt.tools.text.trie import Trie [as 别名]
# 或者: from adapt.tools.text.trie.Trie import gather [as 别名]
def test_retrieval_of_multi_word_entity(self):
trie = Trie()
trie.insert("play", "PlayVerb")
trie.insert("the big bang theory", "Television Series")
results = list(trie.gather("1 of the big bang theory"))
assert len(results) == 0
示例5: test_edit_distance_no_confidence
# 需要导入模块: from adapt.tools.text.trie import Trie [as 别名]
# 或者: from adapt.tools.text.trie.Trie import gather [as 别名]
def test_edit_distance_no_confidence(self):
trie = Trie(max_edit_distance=2)
trie.insert("1", "Number")
results = list(trie.gather("of the big bang theory"))
assert len(results) == 0