예제 #1
0
 def test_should_tolerate_varying_space_in_haystack_and_needle(self):
     haystack = 'Smith ,J .A .'
     needle = 'Smith, J. A.'
     assert fuzzy_search_index_range(haystack, needle, 0.5) == (0, 13)
예제 #2
0
 def test_should_find_longer_needle(self):
     haystack = 'PO Box 12345'
     needle = 'P.O. Box 12345'
     # Note: ideally it would match (0, 12)
     assert fuzzy_search_index_range(haystack, needle, 0.8) == (3, 12)
예제 #3
0
 def test_should_find_exact_match_containing_dot(self):
     haystack = 'abc.'
     needle = 'abc.'
     assert fuzzy_search_index_range(haystack, needle, 0.8) == (0, 4)
예제 #4
0
 def test_should_tolerate_space_in_haystack(self):
     haystack = 'abc .'
     needle = 'abc.'
     assert fuzzy_search_index_range(haystack, needle, 0.9) == (0, 5)
예제 #5
0
 def test_should_find_exact_match_surrounded_by_line_feed(self):
     haystack = '\nabc\n'
     needle = 'abc'
     assert fuzzy_search_index_range(haystack, needle, 0.8) == (1, 4)
예제 #6
0
 def test_should_find_exact_match_surrounded_by_dot(self):
     haystack = '.abc.'
     needle = 'abc'
     assert fuzzy_search_index_range(haystack, needle, 0.8) == (1, 4)
예제 #7
0
 def test_should_find_exact_match_surrounded_by_square_brackets(self):
     haystack = '[abc]'
     needle = 'abc'
     assert fuzzy_search_index_range(haystack, needle, 0.8) == (1, 4)
예제 #8
0
 def test_should_find_exact_match_inside(self):
     haystack = 'xyz abc 123'
     needle = 'abc'
     assert fuzzy_search_index_range(haystack, needle, 0.8) == (4, 7)
예제 #9
0
 def test_should_find_exact_complete_match(self):
     haystack = 'abc'
     needle = 'abc'
     assert fuzzy_search_index_range(haystack, needle, 0.8) == (0, 3)