MCPcopy Create free account
hub / github.com/cogentcore/core / Ratio

Method Ratio

texteditor/difflib/bytes/bytes.go:531–537  ·  view source on GitHub ↗

Ratio returns 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 co

()

Source from the content-addressed store, hash-verified

529// want to try .QuickRatio() or .RealQuickRation() first to get an
530// upper bound.
531func (m *SequenceMatcher) Ratio() float64 {
532 matches := 0
533 for _, m := range m.GetMatchingBlocks() {
534 matches += m.Size
535 }
536 return calculateRatio(matches, len(m.a)+len(m.b))
537}
538
539// QuickRatio returns an upper bound on ratio() relatively quickly.
540//

Callers 5

TestSequenceMatcherRatioFunction · 0.45
TestWithAsciiOneInsertFunction · 0.45
TestWithAsciiOnDeleteFunction · 0.45
FancyReplaceMethod · 0.45

Calls 2

GetMatchingBlocksMethod · 0.95
calculateRatioFunction · 0.70

Tested by 4

TestSequenceMatcherRatioFunction · 0.36
TestWithAsciiOneInsertFunction · 0.36
TestWithAsciiOnDeleteFunction · 0.36