當前位置: 首頁>>代碼示例>>Python>>正文


Python Trie.lookup方法代碼示例

本文整理匯總了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
開發者ID:Ace139,項目名稱:adapt,代碼行數:10,代碼來源:TrieTest.py

示例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
開發者ID:Ace139,項目名稱:adapt,代碼行數:11,代碼來源:TrieTest.py

示例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
開發者ID:Ace139,項目名稱:adapt,代碼行數:12,代碼來源:TrieTest.py

示例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
開發者ID:Ace139,項目名稱:adapt,代碼行數:14,代碼來源:TrieTest.py

示例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'
開發者ID:Ace139,項目名稱:adapt,代碼行數:10,代碼來源:TrieTest.py

示例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
開發者ID:Ace139,項目名稱:adapt,代碼行數:7,代碼來源:TrieTest.py


注:本文中的adapt.tools.text.trie.Trie.lookup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。