本文整理汇总了Python中trie.Trie.contains方法的典型用法代码示例。如果您正苦于以下问题:Python Trie.contains方法的具体用法?Python Trie.contains怎么用?Python Trie.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trie.Trie
的用法示例。
在下文中一共展示了Trie.contains方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_contains_trie_has_two
# 需要导入模块: from trie import Trie [as 别名]
# 或者: from trie.Trie import contains [as 别名]
def test_contains_trie_has_two():
"""Test insertion of second token on trie."""
from trie import Trie
trie = Trie()
token = 'pig'
token2 = 'piglet'
trie.insert(token)
trie.insert(token2)
assert trie.contains(token)
assert trie.contains(token2)
示例2: test_contatins_false
# 需要导入模块: from trie import Trie [as 别名]
# 或者: from trie.Trie import contains [as 别名]
def test_contatins_false():
"""Test contains responds with false for a word that is not inserted."""
from trie import Trie
t = Trie()
t.insert("cat")
result = t.contains("dog")
assert result is False
示例3: test_contatins
# 需要导入模块: from trie import Trie [as 别名]
# 或者: from trie.Trie import contains [as 别名]
def test_contatins():
"""Test contains responds with true for a word that has been inserted."""
from trie import Trie
t = Trie()
t.insert("cat")
result = t.contains("cat")
assert result is True
示例4: test_contains_on_shorter
# 需要导入模块: from trie import Trie [as 别名]
# 或者: from trie.Trie import contains [as 别名]
def test_contains_on_shorter():
"""Test contains returns false on non-inserted longer word."""
from trie import Trie
trie = Trie()
token = 'pig'
trie.insert(token)
assert trie.contains('piglet') is False
示例5: test_contains_on_partial
# 需要导入模块: from trie import Trie [as 别名]
# 或者: from trie.Trie import contains [as 别名]
def test_contains_on_partial():
"""Test contains returns false on partial match."""
from trie import Trie
trie = Trie()
token = 'piglet'
trie.insert(token)
assert trie.contains('pig') is False
示例6: test_contains_given_string_one_string_
# 需要导入模块: from trie import Trie [as 别名]
# 或者: from trie.Trie import contains [as 别名]
def test_contains_given_string_one_string_():
"""Test that a given string is in the list."""
from trie import Trie
trie = Trie()
token = 'pig'
trie.insert(token)
assert trie.contains(token)