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

Method qdensity

src/licensedcode/match.py:565–579  ·  view source on GitHub ↗

Return the query density of this match as a ratio of its length to its qmagnitude, a float between 0 and 1. A dense match has all its matched query tokens contiguous and a maximum qdensity of one. A sparse low qdensity match has some non-contiguous matched query toke

(self)

Source from the content-addressed store, hash-verified

563 return self.end_line - self.start_line + 1
564
565 def qdensity(self):
566 """
567 Return the query density of this match as a ratio of its length to its
568 qmagnitude, a float between 0 and 1. A dense match has all its matched
569 query tokens contiguous and a maximum qdensity of one. A sparse low
570 qdensity match has some non-contiguous matched query tokens interspersed
571 between matched query tokens. An empty match has a zero qdensity.
572 """
573 mlen = self.len()
574 if not mlen:
575 return 0
576 qmagnitude = self.qmagnitude()
577 if not qmagnitude:
578 return 0
579 return mlen / qmagnitude
580
581 def idensity(self):
582 """

Callers 2

representationMethod · 0.95
filter_spurious_matchesFunction · 0.80

Calls 2

lenMethod · 0.95
qmagnitudeMethod · 0.95

Tested by

no test coverage detected