MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / _compute_code_sim_difflib

Function _compute_code_sim_difflib

codeclash/analysis/code_evolve/main.py:77–83  ·  view source on GitHub ↗

Compute similarity score between two diffs using edit distance (0.0 = different, 1.0 = identical).

(diff1: PatchSet, diff2: PatchSet)

Source from the content-addressed store, hash-verified

75
76
77def _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
86def compute_code_sim_jaccard(diff1: PatchSet, diff2: PatchSet) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected