Beispiel #1
0
 def test_score_patterns_5(self):
     """Does a completely different pattern return a best match of None?"""
     best_match = process_input.score_patterns(user_input="hello world",
                                               search_patterns=[("bananas",
                                                                 "null")],
                                               r_weight=1,
                                               pr_weight=0.7)
     assert best_match is None
Beispiel #2
0
 def test_score_patterns_4(self):
     """Does a catch-all pattern match win when there's nothing better?"""
     best_match = process_input.score_patterns(user_input="hello world",
                                               search_patterns=[("*",
                                                                 "null")],
                                               r_weight=1,
                                               pr_weight=0.7)
     assert best_match[1] == "*"
Beispiel #3
0
 def test_score_patterns_3(self):
     """Does a partial star pattern match beat a catch-all match?"""
     best_match = process_input.score_patterns(user_input="hello world",
                                               search_patterns=[
                                                   ("hello *", "null"),
                                                   ("*", "null")
                                               ],
                                               r_weight=1,
                                               pr_weight=0.7)
     assert best_match[1] == "hello *"
Beispiel #4
0
 def test_score_patterns_2(self):
     """Does a slightly different pattern match beat all non-exact matches?"""
     best_match = process_input.score_patterns(user_input="hello world",
                                               search_patterns=[
                                                   ("hello wirld", "null"),
                                                   ("hello *", "null"),
                                                   ("*", "null")
                                               ],
                                               r_weight=1,
                                               pr_weight=0.7)
     assert best_match[1] == "hello wirld"
Beispiel #5
0
 def test_score_patterns_1(self):
     """Does an exact pattern match beat everything?"""
     best_match = process_input.score_patterns(user_input="hello world",
                                               search_patterns=[
                                                   ("hello world", "null"),
                                                   ("hello wirld", "null"),
                                                   ("hello *", "null"),
                                                   ("*", "null")
                                               ],
                                               r_weight=1,
                                               pr_weight=0.7)
     assert best_match[1] == "hello world"