UNPKG

rack-node

Version:

write like human, search like computer

27 lines (26 loc) 844 B
"use strict"; /** * Parvez M Robin * this@parvezmrobin.com * Jul 07, 2020 */ Object.defineProperty(exports, "__esModule", { value: true }); class AssociationFrequencyScoreProvider { constructor(tokenMap) { this.tokenMap = tokenMap; this.tokenScores = new Map(); } getScore() { for (const tokenMapKey of this.tokenMap.keys()) { const apis = this.tokenMap.get(tokenMapKey); for (let i = 0; i < apis.length; i++) { const api = apis[i]; const score = 1 - (i / apis.length); const currentScore = this.tokenScores.get(api) || 0; this.tokenScores.set(api, currentScore + score); } } return this.tokenScores; } } exports.default = AssociationFrequencyScoreProvider;