VOOZH about

URL: https://www.nuget.org/packages/MinHashSharp/

⇱ NuGet Gallery | MinHashSharp 1.1.1




MinHashSharp 1.1.1

dotnet add package MinHashSharp --version 1.1.1
 
 
NuGet\Install-Package MinHashSharp -Version 1.1.1
 
 
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="MinHashSharp" Version="1.1.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MinHashSharp" Version="1.1.1" />
 
Directory.Packages.props
<PackageReference Include="MinHashSharp" />
 
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 MinHashSharp --version 1.1.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MinHashSharp, 1.1.1"
 
 
#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 MinHashSharp@1.1.1
 
 
#: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=MinHashSharp&version=1.1.1
 
Install as a Cake Addin
#tool nuget:?package=MinHashSharp&version=1.1.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MinHashSharp - A Robust Library for Similarity Estimation

👁 NuGet

MinHashSharp offers a simple lightweight data structure designed to index and estimate Jaccard similarity between sets. Leveraging its robust structure, it has been successfully tested on datasets as large as 60GB, encompassing tens of millions of documents, while ensuring smooth and efficient operations.

Installation

To incorporate MinHashSharp into your project, choose one of the following methods:

.NET CLI

dotnet add package MinHashSharp

NuGet Package Manager

Install-Package MinHashSharp

For detailed package information, visit MinHashSharp on NuGet.

Key Features

The library currently offers two classes:

MinHash: A probabilistic data structure for computing Jaccard similarity between sets.

MinHashLSH: A class for supporting big-data fast querying using an approximate Jaccard similarity threshold.

Sample usage

string s1 = "The quick brown fox jumps over the lazy dog and proceeded to run towards the other room";
string s2 = "The slow purple elephant runs towards the happy fox and proceeded to run towards the other room";
string s3 = "The quick brown fox jumps over the angry dog and proceeded to run towards the other room";

var m1 = new MinHash(numPerm: 128).Update(s1.Split());
var m2 = new MinHash(numPerm: 128).Update(s2.Split());
var m3 = new MinHash(numPerm: 128).Update(s3.Split());

Console.WriteLine(m1.Jaccard(m2));// 0.51

var lsh = new MinHashLSH(threshold: 0.8, numPerm: 128);

lsh.Insert("s1", m1);
lsh.Insert("s2", m2);

Console.WriteLine(string.Join(", ", lsh.Query(m3))); // s1

Multi-threading

The library is entirely thread-safe except for the MinHashLSH.Insert function (and the custom injected hash function, if relevant). Therefore, you can create MinHash objects on multiple threads and query the same MinHashLSH object freely. If you are indexing sets on multiple threads, then just make sure to gain exclusive access to the LSH around every Insert call:

lock (lsh) {
 lsh.Insert("s3", m3);
}

Custom hash function

By default, the library uses the Farmhash function introduced by Google for efficiency. For more accurate hashes, one can inject a custom hash function into the MinHash object.

For example, if you want to use the C# default string hash function:

static uint StringHash(string s) => (uint)s.GetHashCode();

var m = new MinHash(numPerm: 128, hashFunc: StringHash).Update(s1.Split());
Product Versions Compatible and additional computed target framework versions.
.NET net6.0 net6.0 is compatible.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.1 5,813 11/30/2023
1.1.0 189 11/30/2023
1.0.1 248 10/31/2023

1.1.0: Added serialize/deserialize option for an LSH index; Added option to "freeze" index.