Skip to content

Commit 1d32d08

Browse files
committed
Refine the display of diff_ratio at percentage #688
Signed-off-by: Thomas Druez <tdruez@nexb.com>
1 parent e239b8f commit 1d32d08

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

scanpipe/pipes/d2d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def get_diff_ratio(to_resource, from_resource):
150150
return matcher.quick_ratio()
151151

152152

153-
def _resource_path_match(to_resource, from_resources):
153+
def _resource_path_match(to_resource, from_resources, diff_ratio_threshold=0.7):
154154
path_parts = Path(to_resource.path.lstrip("/")).parts
155155
path_parts_len = len(path_parts)
156156

@@ -174,14 +174,14 @@ def _resource_path_match(to_resource, from_resources):
174174

175175
for match in matches:
176176
diff_ratio = get_diff_ratio(to_resource=to_resource, from_resource=match)
177-
if diff_ratio and diff_ratio < 0.7:
177+
if diff_ratio and diff_ratio < diff_ratio_threshold:
178178
continue
179179

180180
extra_data = {
181181
"path_score": f"{len(current_parts)}/{path_parts_len - 1}",
182182
}
183183
if diff_ratio:
184-
extra_data["diff_ratio"] = round(diff_ratio, 2)
184+
extra_data["diff_ratio"] = f"{diff_ratio:.1%}"
185185

186186
pipes.make_relationship(
187187
from_resource=match,

0 commit comments

Comments
 (0)