SimMetricsCore

Package Description


Keywords
csharp, dotnet, fuzzy, fuzzy-search, jaro, jaro-distance, jaro-winkler, jaro-winkler-distance, levenshtein, levenshtein-distance, metric, metrics, similarity, similarity-score
License
MIT
Install
Install-Package SimMetricsCore -Version 1.0.1

Documentation

opacity

Nuget

Install-Package SimMetricsCore

dotnet add package SimMetricsCore

SimMetricsCore supports the following algorithms

BlockDistance
ChapmanLengthDeviation
ChapmanMeanLength
CosineSimilarity
DiceSimilarity
EuclideanDistance
JaccardSimilarity
Jaro 
JaroWinkler 
Levenstein // Default
MatchingCoefficient 
MongeElkan
NeedlemanWunch 
OverlapCoefficient
QGramsDistance
SmithWaterman 
SmithWatermanGotoh
SmithWatermanGotohWindowedAffine

Extension Methods

// GetSimilarity
// [0-1] => [0%-100%] similarity 
double GetSimilarity(this string firstWord, string secondWord, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)
SimMetricResult GetMinSimilarityInfo(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)

// GetSimilarities
// Get similarity score for each input.
IEnumerable<SimMetricResult> GetSimilarities(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)
IEnumerable<SimMetricResult> GetSimilarities(this string first, string[] second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)

// GetMinSimilarity
// Returns the first item that has the least similarity.
string GetMinSimilarity(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)
SimMetricResult GetMinSimilarityInfo(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)

// GetMinSimilarities
// Returns the items that have the least similarity. 
// A list can contain unique items with the same similarity score.
IEnumerable<string> GetMinSimilarities(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)
IEnumerable<SimMetricResult> GetMinSimilaritiesInfo(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)

// GetMaxSimilarity
// Returns the first item that has the most similarity.
string GetMaxSimilarity(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)
SimMetricResult GetMaxSimilarityInfo(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)

// GetMaxSimilarities
// Returns the items that have the most similarity. 
// A list can contain unique items with the same similarity score.
IEnumerable<string> GetMaxSimilarities(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)
IEnumerable<SimMetricResult> GetMaxSimilaritiesInfo(this string first, IEnumerable<string> second, SimMetricType simMetricType = SimMetricType.Levenstein, bool convertToPercentage = false)

// Contains
// Increasing the threshold to one increases the accuracy of the comparison.
bool ContainsFuzzy(this string source, string search, double threshold = 0.7, SimMetricType simMetricType = SimMetricType.Levenstein)
// Returns approved values from the 'source' items.
IEnumerable<string> ContainsFuzzy(this IEnumerable<string> source, string search, double threshold = 0.7, SimMetricType simMetricType = SimMetricType.Levenstein)
IEnumerable<string> ContainsFuzzy(this string[] source, string search, double threshold = 0.7, SimMetricType simMetricType = SimMetricType.Levenstein)

SimMetricResult class contains the following data:

public class SimMetricResult
{
    public string Item { get; set; }
    // [0-1] => [0%-100%] similarity 
    public double Score { get; set; }
}

Icons made by Freepik from www.flaticon.com