Compute similarity score between two diffs using edit distance (0.0 = different, 1.0 = identical).
(diff1: PatchSet, diff2: PatchSet)
| 75 | |
| 76 | |
| 77 | def _compute_code_sim_difflib(diff1: PatchSet, diff2: PatchSet) -> float: |
| 78 | """Compute similarity score between two diffs using edit distance (0.0 = different, 1.0 = identical).""" |
| 79 | diff1_str = "\n".join(str(f) for f in diff1) |
| 80 | diff2_str = "\n".join(str(f) for f in diff2) |
| 81 | difflib.SequenceMatcher = CSequenceMatcher |
| 82 | seq_matcher = difflib.SequenceMatcher(None, diff1_str, diff2_str, autojunk=False) |
| 83 | return seq_matcher.ratio() |
| 84 | |
| 85 | |
| 86 | def compute_code_sim_jaccard(diff1: PatchSet, diff2: PatchSet) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected