Calculate similarity to another error pattern.
(self, other: "ErrorPattern")
| 64 | return pattern |
| 65 | |
| 66 | def similarity_score(self, other: "ErrorPattern") -> float: |
| 67 | """Calculate similarity to another error pattern.""" |
| 68 | score = 0.0 |
| 69 | |
| 70 | # Same error type is strong signal |
| 71 | if self.error_type == other.error_type: |
| 72 | score += 0.4 |
| 73 | |
| 74 | # Similar error messages |
| 75 | msg_similarity = self._string_similarity( |
| 76 | self.error_message.lower(), |
| 77 | other.error_message.lower() |
| 78 | ) |
| 79 | score += msg_similarity * 0.4 |
| 80 | |
| 81 | # Same file type context |
| 82 | if self.context.get("file_ext") == other.context.get("file_ext"): |
| 83 | score += 0.2 |
| 84 | |
| 85 | return min(1.0, score) |
| 86 | |
| 87 | def _string_similarity(self, s1: str, s2: str) -> float: |
| 88 | """Simple string similarity using common words.""" |
no test coverage detected