Fuzzy 0.4.0 fuzz ratio - CyrilB1531/lodestar GitHub Wiki
Lodestar.Fuzzy 0.4.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
Fuzz.Ratio
Edit-distance similarity over the whole of both strings.
public static double Ratio(string a, string b)
Parameters — a and b are the strings to compare. Order does not change the answer.
Returns — double in [0, 100]. 100 when identical, 0 when they share nothing.
Example — a transposition, and the two extremes.
using Lodestar.Fuzzy;
double typo = Fuzz.Ratio("apple pie", "appel pie"); // => 88.88888888888889
double same = Fuzz.Ratio("abc", "abc"); // => 100
double nothing = Fuzz.Ratio("abc", "xyz"); // => 0
Remarks — this is the scorer to reach for when the two strings are the same kind of thing: two spellings of a name, two renderings of an address. It compares everything, which is its strength and its limit.
Length is what breaks it. Fuzz.Ratio("apple", "an apple a day") is low, not because the strings
disagree but because most of the second is absent from the first — and
PartialRatio is the answer to that shape.
Applies to — net10.0, netstandard2.0.
See also — Fuzz.PartialRatio,
Fuzz.TokenSortRatio.