@nftgo/gorarity
Version:
An algorithm to calculate rarity of NFT(how special it is), based on Jaccard Distance.
29 lines (28 loc) • 1.43 kB
TypeScript
import { Collection, Token } from '../../models';
import { IScoringHandler } from '../scoring-handler';
export declare class JaccardDistanceScoringHandler implements IScoringHandler {
/**
* @description Calculate the score of each token.
* @param collection
* @param tokens
* @returns The scores of each token, which has the same order with tokens.
*/
scoreTokens(collection: Collection, tokens: Token[]): number[];
/**
* @description Calculate the score of each token.
* The token score is defined as the sum of Jaccard Distance between this token and all other token.
* @param tokenIds Indicate all tokens using tokenId.
* @param indexesList Indicate the token traits using indexes, and the indexes list has the same order with tokenIds.
* @returns The scores of each token, which has the same order with tokenIds.
*/
private calcScores;
/**
* @description We use the Jaccard Distance as the algorithm for calculating the difference between two sets,
* you can get more information from here: https://en.wikipedia.org/wiki/Jaccard_index.
* @param traitsA The traits set of token A.
* @param traitsB The traits set of token B.
* @returns Distance. The distance indicate the difference between two sets. The bigger the distance, the more different between two sets.
*/
private calcDistance;
private normalizeScores;
}