Simple fuzzy matching using character overlap
(query: str, text: str)
| 633 | |
| 634 | |
| 635 | def fuzzy_match(query: str, text: str) -> float: |
| 636 | """Simple fuzzy matching using character overlap""" |
| 637 | if not query or not text: |
| 638 | return 0.0 |
| 639 | |
| 640 | query_chars = set(query) |
| 641 | text_chars = set(text) |
| 642 | |
| 643 | overlap = len(query_chars.intersection(text_chars)) |
| 644 | similarity = overlap / len(query_chars.union(text_chars)) |
| 645 | |
| 646 | return similarity |
| 647 | |
| 648 | |
| 649 | def list_entities( |
no test coverage detected