superminhash
Version:
TypeScript implementation of the SuperMinHash algorithm for Jaccard similarity estimation
32 lines (31 loc) • 1.34 kB
TypeScript
export type HashableElement = unknown;
export declare class SuperMinHash {
readonly signatureSize: number;
private readonly seed;
static readonly DEFAULT_SIGNATURE_SIZE = 256;
static readonly DEFAULT_SEED = 42;
private readonly signature;
private empty;
private static readonly MAX_INPUT_LENGTH;
private static readonly MAX_HASH_VALUE;
constructor(signatureSize?: number, seed?: number);
private generateSeedString;
add(elements: Iterable<HashableElement>): void;
private initProcessingContext;
private cloneProcessingContext;
private processElementWithContext;
private selectRandomPosition;
private ensurePositionsInitialized;
private swapPositions;
private updateSignatureIfNeeded;
private adjustMaxBucketIndex;
similarity(other: SuperMinHash): number;
getJaccardIndex(other: SuperMinHash): number;
getSignature(): Uint32Array;
isEmpty(): boolean;
serialize(): Uint8Array;
static deserialize(binary: Uint8Array): SuperMinHash;
static compareSerialized(firstSignature: Uint8Array, secondSignature: Uint8Array): number;
static fromRawSignature(signature: Uint32Array, seed: number, empty?: boolean): SuperMinHash;
static fromIterable(elements: Iterable<HashableElement>, signatureSize?: number, seed?: number): SuperMinHash;
}