You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/BuildReport/Scripts/Editor/FuzzyString/SorensenDiceDistance.cs

21 lines
509 B
C#

3 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FuzzyString
{
public static partial class ComparisonMetrics
{
public static double SorensenDiceDistance(this string source, string target)
{
return 1 - source.SorensenDiceIndex(target);
}
public static double SorensenDiceIndex(this string source, string target)
{
return (2 * Convert.ToDouble(source.Intersect(target).Count())) / (Convert.ToDouble(source.Length + target.Length));
}
}
}