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
()
| 463 | // want to try .QuickRatio() or .RealQuickRation() first to get an |
| 464 | // upper bound. |
| 465 | func (m *SequenceMatcher) Ratio() float64 { |
| 466 | matches := 0 |
| 467 | for _, m := range m.GetMatchingBlocks() { |
| 468 | matches += m.Size |
| 469 | } |
| 470 | return calculateRatio(matches, len(m.a)+len(m.b)) |
| 471 | } |
| 472 | |
| 473 | // Return an upper bound on ratio() relatively quickly. |
| 474 | // |