Simple string similarity using common words.
(self, s1: str, s2: str)
| 85 | return min(1.0, score) |
| 86 | |
| 87 | def _string_similarity(self, s1: str, s2: str) -> float: |
| 88 | """Simple string similarity using common words.""" |
| 89 | words1 = set(re.findall(r'\w+', s1)) |
| 90 | words2 = set(re.findall(r'\w+', s2)) |
| 91 | if not words1 or not words2: |
| 92 | return 0.0 |
| 93 | intersection = words1 & words2 |
| 94 | union = words1 | words2 |
| 95 | return len(intersection) / len(union) if union else 0.0 |
| 96 | |
| 97 | |
| 98 | class ErrorDatabase: |