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

Method set_relevance

src/licensedcode/models.py:2515–2544  ·  view source on GitHub ↗

Set the ``relevance`` attribute to a computed value for this rule. The relevance is a float between 0 and 100 where 100 means highly relevant and 0 means not relevant at all. The relevance is computed using this approach: - pre-defined, stored relevance is

(self)

Source from the content-addressed store, hash-verified

2513 return self
2514
2515 def set_relevance(self):
2516 """
2517 Set the ``relevance`` attribute to a computed value for this rule. The
2518 relevance is a float between 0 and 100 where 100 means highly relevant
2519 and 0 means not relevant at all.
2520
2521 The relevance is computed using this approach:
2522
2523 - pre-defined, stored relevance is used as-is
2524 - false positive or SPDX rules have 100 relevance.
2525 - relevance is computed based on the rule length
2526 """
2527
2528 if self.is_false_positive:
2529 self.relevance = 100
2530 self.has_stored_relevance = True
2531 return
2532
2533 if self.is_required_phrase and not self.relevance:
2534 self.relevance = 90
2535 self.has_stored_relevance = True
2536 return
2537
2538 computed_relevance = compute_relevance(self.length)
2539
2540 if self.has_stored_relevance:
2541 if self.relevance == computed_relevance:
2542 self.has_stored_relevance = False
2543 else:
2544 self.relevance = computed_relevance
2545
2546 @staticmethod
2547 def from_match_data(license_match_mapping):

Calls 1

compute_relevanceFunction · 0.85