MCPcopy Index your code
hub / github.com/expr-lang/expr / Ratio

Method Ratio

internal/difflib/difflib.go:468–474  ·  view source on GitHub ↗

Return a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2.0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. .Ratio() is expensive to compute i

()

Source from the content-addressed store, hash-verified

466// want to try .QuickRatio() or .RealQuickRation() first to get an
467// upper bound.
468func (m *SequenceMatcher) Ratio() float64 {
469 matches := 0
470 for _, m := range m.GetMatchingBlocks() {
471 matches += m.Size
472 }
473 return calculateRatio(matches, len(m.a)+len(m.b))
474}
475
476// Return an upper bound on ratio() relatively quickly.
477//

Callers 4

TestSequenceMatcherRatioFunction · 0.80
TestWithAsciiOneInsertFunction · 0.80
TestWithAsciiOnDeleteFunction · 0.80

Calls 2

GetMatchingBlocksMethod · 0.95
calculateRatioFunction · 0.85

Tested by 4

TestSequenceMatcherRatioFunction · 0.64
TestWithAsciiOneInsertFunction · 0.64
TestWithAsciiOnDeleteFunction · 0.64