Skip to content

A text similarity metric library, e.g. from edit distance's (Levenshtein, Gotoh, Jaro, etc) to other metrics, (e.g Soundex, Chapman). This library is compiled based on the .NET standard with a lot of useful extension methods.

License

Notifications You must be signed in to change notification settings

HamedFathi/SimMetricsCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opacity

Open Source Love Nuget 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
// Getting closer to '1.0' for the 'threshold' 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

About

A text similarity metric library, e.g. from edit distance's (Levenshtein, Gotoh, Jaro, etc) to other metrics, (e.g Soundex, Chapman). This library is compiled based on the .NET standard with a lot of useful extension methods.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages