Skip to content

Commit e4776ef

Browse files
committed
[SP-2874]: add min_accepted_score
1 parent b0aa437 commit e4776ef

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/scanoss/cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from .constants import (
6161
DEFAULT_API_TIMEOUT,
6262
DEFAULT_HFH_DEPTH,
63+
DEFAULT_HFH_MIN_ACCEPTED_SCORE,
6364
DEFAULT_HFH_RANK_THRESHOLD,
6465
DEFAULT_HFH_RECURSIVE_THRESHOLD,
6566
DEFAULT_POST_SIZE,
@@ -883,6 +884,15 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
883884
default=DEFAULT_HFH_RECURSIVE_THRESHOLD,
884885
help=f'Minimum score threshold to consider a match (optional - default: {DEFAULT_HFH_RECURSIVE_THRESHOLD})',
885886
)
887+
p_folder_scan.add_argument(
888+
'--min-accepted-score',
889+
type=float,
890+
default=DEFAULT_HFH_MIN_ACCEPTED_SCORE,
891+
help=(
892+
'Only show results with a score at or above this threshold '
893+
f'(optional - default: {DEFAULT_HFH_MIN_ACCEPTED_SCORE})'
894+
),
895+
)
886896
p_folder_scan.set_defaults(func=folder_hashing_scan)
887897

888898
# Sub-command: folder-hash
@@ -2478,6 +2488,7 @@ def folder_hashing_scan(parser, args):
24782488
rank_threshold=args.rank_threshold,
24792489
depth=args.depth,
24802490
recursive_threshold=args.recursive_threshold,
2491+
min_accepted_score=args.min_accepted_score,
24812492
)
24822493

24832494
if scanner.scan():

src/scanoss/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
DEFAULT_HFH_RANK_THRESHOLD = 5
1717
DEFAULT_HFH_DEPTH = 1
1818
DEFAULT_HFH_RECURSIVE_THRESHOLD = 0.8
19+
DEFAULT_HFH_MIN_ACCEPTED_SCORE = 0.15

src/scanoss/scanners/scanner_hfh.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from scanoss.constants import (
3333
DEFAULT_HFH_DEPTH,
34+
DEFAULT_HFH_MIN_ACCEPTED_SCORE,
3435
DEFAULT_HFH_RANK_THRESHOLD,
3536
DEFAULT_HFH_RECURSIVE_THRESHOLD,
3637
)
@@ -61,6 +62,7 @@ def __init__( # noqa: PLR0913
6162
rank_threshold: int = DEFAULT_HFH_RANK_THRESHOLD,
6263
depth: int = DEFAULT_HFH_DEPTH,
6364
recursive_threshold: float = DEFAULT_HFH_RECURSIVE_THRESHOLD,
65+
min_accepted_score: float = DEFAULT_HFH_MIN_ACCEPTED_SCORE,
6466
):
6567
"""
6668
Initialize the ScannerHFH.
@@ -73,6 +75,7 @@ def __init__( # noqa: PLR0913
7375
rank_threshold (int): Get results with rank below this threshold (default: 5).
7476
depth (int): How many levels to scan (default: 1).
7577
recursive_threshold (float): Minimum score threshold to consider a match (default: 0.25).
78+
min_accepted_score (float): Only show results with a score at or above this threshold (default: 0.15).
7679
"""
7780
self.base = ScanossBase(
7881
debug=config.debug,
@@ -103,6 +106,7 @@ def __init__( # noqa: PLR0913
103106
self.scan_results = None
104107
self.rank_threshold = rank_threshold
105108
self.recursive_threshold = recursive_threshold
109+
self.min_accepted_score = min_accepted_score
106110

107111
def scan(self) -> Optional[Dict]:
108112
"""
@@ -115,6 +119,7 @@ def scan(self) -> Optional[Dict]:
115119
'root': self.folder_hasher.hash_directory(path=self.scan_dir),
116120
'rank_threshold': self.rank_threshold,
117121
'recursive_threshold': self.recursive_threshold,
122+
'min_accepted_score': self.min_accepted_score,
118123
}
119124

120125
spinner = Spinner('Scanning folder...')

0 commit comments

Comments
 (0)