Skip to content

Commit 691d92f

Browse files
committed
[SP-2874]: add min_accepted_score
1 parent 9362b38 commit 691d92f

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,
@@ -865,6 +866,15 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
865866
default=DEFAULT_HFH_RECURSIVE_THRESHOLD,
866867
help=f'Minimum score threshold to consider a match (optional - default: {DEFAULT_HFH_RECURSIVE_THRESHOLD})',
867868
)
869+
p_folder_scan.add_argument(
870+
'--min-accepted-score',
871+
type=float,
872+
default=DEFAULT_HFH_MIN_ACCEPTED_SCORE,
873+
help=(
874+
'Only show results with a score at or above this threshold '
875+
f'(optional - default: {DEFAULT_HFH_MIN_ACCEPTED_SCORE})'
876+
),
877+
)
868878
p_folder_scan.set_defaults(func=folder_hashing_scan)
869879

870880
# Sub-command: folder-hash
@@ -2390,6 +2400,7 @@ def folder_hashing_scan(parser, args):
23902400
rank_threshold=args.rank_threshold,
23912401
depth=args.depth,
23922402
recursive_threshold=args.recursive_threshold,
2403+
min_accepted_score=args.min_accepted_score,
23932404
)
23942405

23952406
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)