@@ -24,7 +24,8 @@ class MatchData:
2424 score : int = 0
2525
2626
27- def string_matcher (query : str , text : str , ignore_case : bool = True , query_search_precision : int = DEFAULT_QUERY_SEARCH_PRECISION ) -> MatchData :
27+ def string_matcher (query : str , text : str , ignore_case : bool = True ,
28+ query_search_precision : int = DEFAULT_QUERY_SEARCH_PRECISION ) -> MatchData :
2829 """Compare query to text"""
2930 if not text or not query :
3031 return MatchData (False , query_search_precision )
@@ -54,13 +55,8 @@ def string_matcher(query: str, text: str, ignore_case: bool = True, query_search
5455 index_list : List [int ] = []
5556 space_indices : List [int ] = []
5657 for text_index in range (len (full_text_lower )):
57- if current_acronym_query_index >= len (query_lower ) and acronyms_matched == len (query_lower ):
58-
59- if is_acronym_count (full_text_lower , text_index ):
60- acronyms_total_count += 1
61- continue
62-
63- if current_acronym_query_index >= len (query_lower ) or current_acronym_query_index >= len (query_lower ) and all_query_substrings_matched :
58+ if (current_acronym_query_index >= len (query_lower ) or
59+ (current_acronym_query_index >= len (query_lower ) and all_query_substrings_matched )):
6460 break
6561
6662 if full_text_lower [text_index ] == SPACE_CHAR and current_query_substring_char_index == 0 :
@@ -75,7 +71,8 @@ def string_matcher(query: str, text: str, ignore_case: bool = True, query_search
7571 if is_acronym_count (text , text_index ):
7672 acronyms_total_count += 1
7773
78- if all_query_substrings_matched or full_text_lower [text_index ] != current_query_substring [current_query_substring_char_index ]:
74+ if all_query_substrings_matched or (full_text_lower [text_index ]
75+ != current_query_substring [current_query_substring_char_index ]):
7976 match_found_in_previous_loop = False
8077 continue
8178
@@ -88,7 +85,8 @@ def string_matcher(query: str, text: str, ignore_case: bool = True, query_search
8885 elif not match_found_in_previous_loop :
8986 start_index_to_verify = text_index - current_query_substring_char_index
9087
91- if all_previous_chars_matched (start_index_to_verify , current_query_substring_char_index , full_text_lower , current_query_substring ):
88+ if all_previous_chars_matched (start_index_to_verify , current_query_substring_char_index , full_text_lower ,
89+ current_query_substring ):
9290 match_found_in_previous_loop = True
9391 first_match_index_in_word = start_index_to_verify if current_query_substring_index == 0 else first_match_index
9492
@@ -133,7 +131,8 @@ def string_matcher(query: str, text: str, ignore_case: bool = True, query_search
133131 return MatchData (False , query_search_precision )
134132
135133
136- def calculate_search_score (query : str , text : str , first_index : int , space_indices : List [int ], match_length : int , all_substrings_contained_in_text : bool ):
134+ def calculate_search_score (query : str , text : str , first_index : int , space_indices : List [int ],
135+ match_length : int , all_substrings_contained_in_text : bool ):
137136 score = 100 * (len (query ) + 1 ) / ((1 + first_index ) + (match_length + 1 ))
138137
139138 if first_index == 0 and all_substrings_contained_in_text :
@@ -155,7 +154,9 @@ def calculate_search_score(query: str, text: str, first_index: int, space_indice
155154 return score
156155
157156
158- def get_updated_index_list (start_index_to_verify : int , current_query_substring_char_index : int , first_matched_index_in_word : int , index_list : List [int ]):
157+ def get_updated_index_list (start_index_to_verify : int ,
158+ current_query_substring_char_index : int ,
159+ first_matched_index_in_word : int , index_list : List [int ]):
159160 updated_list : List [int ] = []
160161
161162 for idx , item in enumerate (index_list ):
@@ -174,7 +175,9 @@ def all_query_substrings_matched_func(current_query_substring_index: int, query_
174175 return current_query_substring_index >= query_substrings_length
175176
176177
177- def all_previous_chars_matched (start_index_to_verify : int , current_query_substring_char_index : int , full_text_lower : str , current_query_substring : str ) -> bool :
178+ def all_previous_chars_matched (start_index_to_verify : int ,
179+ current_query_substring_char_index : int ,
180+ full_text_lower : str , current_query_substring : str ) -> bool :
178181 all_match = True
179182 for i in range (current_query_substring_char_index ):
180183 if full_text_lower [start_index_to_verify + i ] != current_query_substring [i ]:
0 commit comments