Example #1
0
 def test_create_contain_common_postfix(self):
     tb = trie.TrieBase([('a', 'b', 'c'), ('d', 'b', 'c')])
     eq_(tb._table[0], [-1, 1, -1, -1, 4])
     eq_(tb._table[1], [-1, -1, 2])
     eq_(tb._table[2], [-1, -1, -1, 3])
     eq_(tb._table[4], [-1, -1, 5])
     eq_(tb._table[5], [-1, -1, -1, 6])
Example #2
0
 def test_search_multichars(self):
     tb = trie.TrieBase([('しゃ', 'か', 'い')])
     result = tb.search(['しゃ'])
     eq_(result, [('しゃ', 'か', 'い')])
     result = tb.search(['しゃ', 'か'])
     eq_(result, [('しゃ', 'か', 'い')])
     result = tb.search(['しゃ', 'か', 'い'])
     eq_(result, [('しゃ', 'か', 'い')])
Example #3
0
 def test_search_case_two_words(self):
     tb = trie.TrieBase([('a', 'b', 'c'), ('a', 'b', 'd')])
     result = tb.search(['a'])
     eq_(result, [('a', 'b', 'c'), ('a', 'b', 'd')])
     result = tb.search(['a', 'b'])
     eq_(result, [('a', 'b', 'c'), ('a', 'b', 'd')])
     result = tb.search(['a', 'b', 'c'])
     eq_(result, [('a', 'b', 'c')])
Example #4
0
 def test_search_case_non_vocabulary(self):
     tb = trie.TrieBase([('a', 'b', 'c')])
     result = tb.search(['a', 'b', 'd'])
     eq_(result, [])
     result = tb.search(['a', 'd'])
     eq_(result, [])
     result = tb.search(['d'])
     eq_(result, [])
Example #5
0
 def test_search_case_non_result(self):
     tb = trie.TrieBase([('a', 'b', 'c')])
     result = tb.search(['a', 'b', 'a'])
     eq_(result, [])
     result = tb.search(['a', 'c'])
     eq_(result, [])
     result = tb.search(['b'])
     eq_(result, [])
Example #6
0
 def test_create(self):
     tb = trie.TrieBase([('a', 'b', 'c')])
     eq_(tb._table[0], [-1, 1])
     eq_(tb._table[1], [-1, -1, 2])
     eq_(tb._table[2], [-1, -1, -1, 3])
Example #7
0
 def test_create_multichars(self):
     tb = trie.TrieBase([('しゃ', 'か', 'い')])
     eq_(tb._table[0], [-1, 1])
     eq_(tb._table[1], [-1, -1, 2])
     eq_(tb._table[2], [-1, -1, -1, 3])