StringSimilarity 1.0.3
dotnet add package StringSimilarity --version 1.0.3
NuGet\Install-Package StringSimilarity -Version 1.0.3
<PackageReference Include="StringSimilarity" Version="1.0.3" />
<PackageVersion Include="StringSimilarity" Version="1.0.3" />
<PackageReference Include="StringSimilarity" />
paket add StringSimilarity --version 1.0.3
#r "nuget: StringSimilarity, 1.0.3"
#:package StringSimilarity@1.0.3
#addin nuget:?package=StringSimilarity&version=1.0.3
#tool nuget:?package=StringSimilarity&version=1.0.3
StringSimilarity
This class library calculates a score from 0 to 1 based on the similarity of two supplied strings.
StringSimilarity targets .NET Standard 2.1, .NET Core 3.1, .NET Framework 4.5.2, .NET 5.0, and .NET 6.0.
Help or Feedback
First things first - do you need help or have feedback? Contact me at joel dot christner at gmail dot com or file an issue here!
New in v1.0.2.2
- Maintenance release; library behavior is unchanged
- Symbol package (
.snupkg) now published alongside the NuGet package - Test dependencies refreshed (Touchstone 0.2.0, xUnit runner 4.0.0, NUnit 5.0.0, Microsoft.NET.Test.Sdk 18.10.1, coverlet 10.1.0)
Score Computation
- If one string is null/empty and the other is not, the score is 0
- If both strings are null/empty, the score is 1
- If both strings are equal, the score is 1
- Otherwise, a length score is multiplied by a character match score, where length score = (min / max) and character match score is (num matching / total)
- The character match score compares the sets of distinct characters in each string; total is the number of distinct characters in whichever string has more
- Comparison is case-sensitive and ordinal, so
ABCversusabcscores 0 - Character order and frequency are not considered, so anagrams of the same length (for example
listenandsilent) score 1
Example
Refer to the Test project for an interactive example.
using Similarity;
Console.Write("String 1 : ");
string str1 = Console.ReadLine();
Console.Write("String 2 : ");
string str2 = Console.ReadLine();
Console.WriteLine("Score : " + StringSimilarity.Calculate(str1, str2));
Running the Tests
Automated tests are built with Touchstone. All test cases live in Test.Shared and are executed by three runners:
Test.Automated- console runner (dotnet run --project Test.Automated -f net8.0, add-- --results results.jsonto export JSON)Test.Xunit- xUnit runner (dotnet test Test.Xunit)Test.Nunit- NUnit runner (dotnet test Test.Nunit)
The Test project is an interactive console application for trying the library by hand.
Version History
Refer to CHANGELOG.md for the full version history.
| 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. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. 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. |
-
.NETFramework 4.6.2
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- 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.
Maintenance release: refreshed test dependencies, symbol package (snupkg) published