Exemplo n.º 1
0
 def test_immediacy_bonus(self):
     score = search.MATCH_BONUS + search.immediacy_bonus(2)
     self.assertEqual(search.score('cba b', 'a'), score)
Exemplo n.º 2
0
 def test_immediacy_bonus_at_beginning(self):
     score = search.WORD_BONUS \
             +  search.MATCH_BONUS \
             + search.immediacy_bonus(0)
     self.assertEqual(search.score('a b', 'a'), score)
Exemplo n.º 3
0
 def test_one_small_gap_with_two_word_bonuses(self):
     score = 2 * search.WORD_BONUS \
             + 2 * search.MATCH_BONUS \
             + search.gap_bonus(2) \
             + search.immediacy_bonus(0)
     self.assertEqual(search.score('b defg', 'bd'), score)
Exemplo n.º 4
0
 def test_weight_consecutive_more_than_acronym(self):
     self.assertGreater(
         search.score('cab', 'ab'),
         search.score('c a b', 'ab')
     )
Exemplo n.º 5
0
 def test_match_multiple_letters_with_beginning_bonus(self):
     score = search.WORD_BONUS \
             + 2 * search.MATCH_BONUS \
             + search.gap_bonus(1) \
             + search.immediacy_bonus(0)
     self.assertEqual(search.score('bcde', 'bc'), score)
Exemplo n.º 6
0
 def test_one_small_gap(self):
     score = 2 * search.MATCH_BONUS \
             + search.gap_bonus(2) \
             + search.immediacy_bonus(1)
     self.assertEqual(search.score('abcdefg', 'bd'), score)
Exemplo n.º 7
0
 def test_word_bonus(self):
     score = search.WORD_BONUS \
             + search.MATCH_BONUS \
             + search.immediacy_bonus(4)
     self.assertEqual(search.score('foo bar', 'b'), score)
Exemplo n.º 8
0
 def test_beginning_bonus_more_text(self):
     score = search.WORD_BONUS \
             + search.MATCH_BONUS \
             + search.immediacy_bonus(0)
     self.assertEqual(search.score('bar', 'b'), score)
Exemplo n.º 9
0
 def test_second_letter_mismatch(self):
     self.assertEqual(search.score('acde', 'abc'), 0)
Exemplo n.º 10
0
 def test_first_letter_mismatch(self):
     self.assertEqual(search.score('bcde', 'abc'), 0)
Exemplo n.º 11
0
 def test_match_multiple_letters(self):
     score = 2 * search.MATCH_BONUS \
             + search.gap_bonus(1) \
             + search.immediacy_bonus(1)
     self.assertEqual(search.score('abcde', 'bc'), score)
Exemplo n.º 12
0
 def test_match(self):
     score = search.MATCH_BONUS + search.immediacy_bonus(1)
     self.assertEqual(search.score('abc', 'b'), score)
Exemplo n.º 13
0
 def test_blank(self):
     self.assertEqual(search.score('', ''), 0)