StringComparison 2.0.0
dotnet add package StringComparison --version 2.0.0
NuGet\Install-Package StringComparison -Version 2.0.0
<PackageReference Include="StringComparison" Version="2.0.0" />
paket add StringComparison --version 2.0.0
#r "nuget: StringComparison, 2.0.0"
// Install StringComparison as a Cake Addin #addin nuget:?package=StringComparison&version=2.0.0 // Install StringComparison as a Cake Tool #tool nuget:?package=StringComparison&version=2.0.0
String Comparison
String Comparison for C#.NET
Project Description
StringComparison is a library developed for reconciling naming conventions between different models of the electric grid.
I have stripped off the power system specific code and put together what can effectively be used as a string extension for determining approximate equality between two strings.
All of the algorithms used here have been pulled from online resources, translated into C#, and compiled into this library.
I found several other similar open-source implementations around but nothing for .NET/C#. Adding the *.dll to your project will give you access to this extension and the individual extensions under the hood of the IsSimilarity()
extension.
Algorithms included in this project
- Hamming Distance
- Jaccard Distance
- Jaro Distance
- Jaro-Winkler Distance
- Levenshtein Distance
- Longest Common Subsequence
- Longest Common Substring
- Overlap Coefficient
- Ratcliff-Obershelp Similarity
- Sorensen-Dice Distance
- Tanimoto Coefficient
String Comparision
While all of the algorithms are exposed and can be used and can provide their raw results,
they have been conveniently combined in a way that they can selectively be used to judge the approximate equality of two strings.
This is done through the IsSimilar
extension and by setting the desired StringComparisonOptions
and StringComparisonTolerance
.
For two strings that are desired to be compared approximately, a boolean response of equality can be garnered in the following way:
Installation
Download last release https://github.com/Behzadkhosravifar/StringComparison/releases
or install from NuGet https://www.nuget.org/packages/StringComparison. To install run the following command in the Package Manager Console
Install-Package StringComparison
Usage
string source = "behzad";
string target = "behsad";
var options = new List<StringComparisonOptions>();
// Choose which algorithms should weigh in for the comparison
options.Add(StringComparisonOptions.UseOverlapCoefficient);
options.Add(StringComparisonOptions.UseLongestCommonSubsequence);
options.Add(StringComparisonOptions.UseLongestCommonSubstring);
// Choose the relative strength of the comparison - is it almost exactly equal? or is it just close?
var tolerance = StringComparisonTolerance.Strong;
// Get a boolean determination of approximate equality
bool result = source.IsSimilar(target, options, tolerance);
double howManySimilar = source.SimilarityPercent(target, options);
double simLevenshtein = source.LevenshteinDistancePercentage(target);
double simJaro = 1 - source.JaroDistance(target);
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request 😃
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
DotNet core version of StringComparison project