print(textmatcher.isvalidmatch( query= 'IN',value="INVOICE", threshold=80,…
- User
print(text_matcher.is_valid_match( query= 'IN',value="INVOICE", threshold=80, match_type="partial")) print(text_matcher.is_valid_match( query="INVOICE",value='IN', threshold=80, match_type="partial")) (True, 100.0, 0, 2) (True, 100.0, 0, 2) but the second one is clearly not a match , since we are searching for "INVOICE" and "IN" is just not a remoate match but still got 100/100 score how to get a better score def is_valid_match(query,value,threshold=90, match_type="partial"): """ Check if an query matches a value using fuzzy matching.
codeReturns (matched, score, start_idx, end_idx), where for: - full: start_idx=0, end_idx=len(query) - partial: the best-matching substring’s [src_start, src_end) """ if not value or not query: return False, 0, 0, 0 # --- FULL MATCH --- if match_type == "full": score = fuzz.ratio(value, query) return (score >= threshold), score, 0, len(query) # --- PARTIAL MATCH via alignment helper --- alignment = fuzz.partial_ratio_alignment(value, query, score_cutoff=threshold) if not alignment: return False, 0, 0, 0 return True, alignment.score, alignment.src_start, alignment.src_end
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.