Skip to content

Commit

Permalink
Refine the display of diff_ratio at percentage #688
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Apr 24, 2023
1 parent e239b8f commit 1d32d08
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scanpipe/pipes/d2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def get_diff_ratio(to_resource, from_resource):
return matcher.quick_ratio()


def _resource_path_match(to_resource, from_resources):
def _resource_path_match(to_resource, from_resources, diff_ratio_threshold=0.7):
path_parts = Path(to_resource.path.lstrip("/")).parts
path_parts_len = len(path_parts)

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

for match in matches:
diff_ratio = get_diff_ratio(to_resource=to_resource, from_resource=match)
if diff_ratio and diff_ratio < 0.7:
if diff_ratio and diff_ratio < diff_ratio_threshold:
continue

extra_data = {
"path_score": f"{len(current_parts)}/{path_parts_len - 1}",
}
if diff_ratio:
extra_data["diff_ratio"] = round(diff_ratio, 2)
extra_data["diff_ratio"] = f"{diff_ratio:.1%}"

pipes.make_relationship(
from_resource=match,
Expand Down

0 comments on commit 1d32d08

Please # to comment.