Skip to content

Fuzzy fuzz tokensetratio

github-actions[bot] edited this page Aug 28, 2026 · 28 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Fuzzy is 0.4.0 — read its documentation.

Fuzz.TokenSetRatio

The words as sets, so extra words on one side stop counting against it.

public static double TokenSetRatio(string a, string b)

Parametersa and b are the strings to compare.

Returnsdouble in [0, 100], computed over the intersection and the two differences of the word sets.

Example — one side carrying words the other does not.

using Lodestar.Fuzzy;

string query = "mariners vs angels";
string candidate = "los angeles angels vs seattle mariners";

double subset = Fuzz.TokenSetRatio(query, candidate);  // => 100

Remarks100, because every word of the shorter side appears in the longer one. That is the most forgiving of the seven and the easiest to misuse: it will score 100 for a query that is a subset of a candidate, however much else that candidate says.

Right for "does this short label refer to this long one" — a team name against a full fixture, a brand against a product title. Wrong for deduplication, where two records differing by several words are usually two things.

Duplicated words do not help: a set counts a word once, so "the the cat" and "the cat" compare as equal sets.

Applies to — net10.0, netstandard2.0.

See alsoFuzz.TokenSortRatio, Fuzz.PartialTokenSetRatio.

Lodestar

Project

Clone this wiki locally