FuzzyComparisonLibrary 1.0.0

dotnet add package FuzzyComparisonLibrary --version 1.0.0
                    
NuGet\Install-Package FuzzyComparisonLibrary -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FuzzyComparisonLibrary" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FuzzyComparisonLibrary" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="FuzzyComparisonLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FuzzyComparisonLibrary --version 1.0.0
                    
#r "nuget: FuzzyComparisonLibrary, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FuzzyComparisonLibrary@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FuzzyComparisonLibrary&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=FuzzyComparisonLibrary&version=1.0.0
                    
Install as a Cake Tool

FuzzyComparisonLibrary

Overview

FuzzyComparisonLibrary is a C# library for calculating the similarity between two strings using multiple fuzzy comparison algorithms. The library supports multithreaded processing to enhance performance, making it efficient for applications requiring quick and reliable string similarity calculations.

Supported Algorithms

  • Levenshtein Similarity
  • Jaro-Winkler Similarity
  • Cosine Similarity
  • Trigram Overlap Similarity
  • SimHash Similarity
  • MinHash Similarity

Author

Adam Lange code@adamlange.pl

Source Code

FuzzyComparisonLibrary on GitHub

Installation

Include the FuzzyComparisonLibrary in your project by adding the source code or compiling it into a DLL.

Usage

Example 1: Unified Similarity Calculation

using System;
using FuzzyComparisonLibrary;

class Program
{
    static void Main(string[] args)
    {
        string source = "hello world";
        string target = "hola world";

        double similarity = FuzzyComparer.GetUnifiedSimilarity(source, target);
        Console.WriteLine($"Unified Similarity: {similarity:P2}");
    }
}

Example 2: Specific Algorithm Calculation

using System;
using FuzzyComparisonLibrary;

class Program
{
    static void Main(string[] args)
    {
        string source = "hello";
        string target = "hallo";

        double levenshteinSimilarity = FuzzyComparer.GetSimilarityByMethod(source, target, FuzzyComparer.LevenshteinSimilarity);
        Console.WriteLine($"Levenshtein Similarity: {levenshteinSimilarity:P2}");

        double jaroWinklerSimilarity = FuzzyComparer.GetSimilarityByMethod(source, target, FuzzyComparer.JaroWinklerSimilarity);
        Console.WriteLine($"Jaro-Winkler Similarity: {jaroWinklerSimilarity:P2}");

        double cosineSimilarity = FuzzyComparer.GetSimilarityByMethod(source, target, FuzzyComparer.CosineSimilarity);
        Console.WriteLine($"Cosine Similarity: {cosineSimilarity:P2}");

        double trigramOverlapSimilarity = FuzzyComparer.GetSimilarityByMethod(source, target, FuzzyComparer.TrigramOverlapSimilarity);
        Console.WriteLine($"Trigram Overlap Similarity: {trigramOverlapSimilarity:P2}");

        double simHashSimilarity = FuzzyComparer.GetSimilarityByMethod(source, target, FuzzyComparer.SimHashSimilarity);
        Console.WriteLine($"SimHash Similarity: {simHashSimilarity:P2}");

        double minHashSimilarity = FuzzyComparer.GetSimilarityByMethod(source, target, FuzzyComparer.MinHashSimilarity);
        Console.WriteLine($"MinHash Similarity: {minHashSimilarity:P2}");
    }
}

Available Methods

GetUnifiedSimilarity

Calculates a unified similarity score by averaging the results of all supported algorithms.

double similarity = FuzzyComparer.GetUnifiedSimilarity(source, target);
GetSimilarityByMethod

Allows computation of similarity using a specific algorithm by passing the desired method.

double similarity = FuzzyComparer.GetSimilarityByMethod(source, target, FuzzyComparer.LevenshteinSimilarity);
LevenshteinSimilarity

Calculates similarity based on Levenshtein (edit distance).

double similarity = FuzzyComparer.LevenshteinSimilarity(source, target);
JaroWinklerSimilarity

Calculates similarity using the Jaro-Winkler algorithm.

double similarity = FuzzyComparer.JaroWinklerSimilarity(source, target);
CosineSimilarity

Calculates similarity based on cosine similarity of character bigrams.

double similarity = FuzzyComparer.CosineSimilarity(source, target);
TrigramOverlapSimilarity

Calculates similarity based on the overlap of character trigrams.

double similarity = FuzzyComparer.TrigramOverlapSimilarity(source, target);
SimHashSimilarity

Calculates similarity using the SimHash algorithm.

double similarity = FuzzyComparer.SimHashSimilarity(source, target);
MinHashSimilarity

Calculates similarity using the MinHash algorithm for shingles.

double similarity = FuzzyComparer.MinHashSimilarity(source, target);

Features

  • Multithreaded implementation for improved performance.
  • Flexible API to compute unified or individual similarity scores.
  • Support for various string similarity algorithms.

License

MIT License

Copyright (c) 2025 Adam Lange code@adamlange.pl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, contact Adam Lange at code@adamlange.pl.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.0.0 140 1/27/2025