MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / compute_thresholds

Method compute_thresholds

src/licensedcode/models.py:2370–2396  ·  view source on GitHub ↗

Compute and set thresholds either considering the occurrence of all tokens or the occurence of unique tokens.

(self, small_rule=SMALL_RULE, tiny_rule=TINY_RULE)

Source from the content-addressed store, hash-verified

2368 raise InvalidRule(f'Invalid rule:file://{rule_file} {self}') from e
2369
2370 def compute_thresholds(self, small_rule=SMALL_RULE, tiny_rule=TINY_RULE):
2371 """
2372 Compute and set thresholds either considering the occurrence of all
2373 tokens or the occurence of unique tokens.
2374 """
2375 min_cov, self.min_matched_length, self.min_high_matched_length = (
2376 compute_thresholds_occurences(
2377 self.minimum_coverage,
2378 self.length,
2379 self.high_length,
2380 )
2381 )
2382 if not self.has_stored_minimum_coverage:
2383 self.minimum_coverage = min_cov
2384
2385 self._minimum_containment = self.minimum_coverage / 100
2386
2387 self.min_matched_length_unique, self.min_high_matched_length_unique = (
2388 compute_thresholds_unique(
2389 self.minimum_coverage,
2390 self.length,
2391 self.length_unique, self.high_length_unique,
2392 )
2393 )
2394
2395 self.is_small = self.length < small_rule
2396 self.is_tiny = self.length < tiny_rule
2397
2398 def dump(self, rules_data_dir, **kwargs):
2399 """

Callers 1

_add_rulesMethod · 0.80

Calls 2

Tested by

no test coverage detected