Skip to content

Instantly share code, notes, and snippets.

View dasjestyr's full-sized avatar

Nunja dasjestyr

  • Scottsdale, AZ
View GitHub Profile
@ssajous
ssajous / Dice.cs
Last active October 14, 2021 15:41
Implementations of Dice's Coefficient used to get a similarity index between two strings.
public static double DiceCoefficient(string stOne, string stTwo)
{
HashSet<string> nx = BuildBigramSet(stOne);
HashSet<string> ny = BuildBigramSet(stTwo);
HashSet<string> intersection = new HashSet<string>(nx);
intersection.IntersectWith(ny);
double dbOne = intersection.Count;
return (2 * dbOne) / (nx.Count + ny.Count);