mbd-studio-sdk 4.3.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/V1/Studio.js +7 -11
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/V1/Studio.js
CHANGED
|
@@ -120,20 +120,16 @@ export class Studio {
|
|
|
120
120
|
origin: this._origin,
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
/** Maps
|
|
123
|
+
/** Maps scoring result [{id, score}, ...] into hit._scores[scoringKey]. */
|
|
124
124
|
addScores(scoringResult, scoringKey) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
rankedItemIds.forEach((itemId, index) => {
|
|
129
|
-
rankToScore[itemId] = 1.0 - (index / rankedItemIds.length);
|
|
130
|
-
});
|
|
125
|
+
if (!this._candidates || !scoringResult || !Array.isArray(scoringResult)) return;
|
|
126
|
+
const scoreByItemId = {};
|
|
127
|
+
scoringResult.forEach(({ id, score }) => { scoreByItemId[String(id)] = score; });
|
|
131
128
|
for (const hit of this._candidates) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
if (hitScore) {
|
|
129
|
+
const hitScore = scoreByItemId[String(hit._id)];
|
|
130
|
+
if (hitScore != null) {
|
|
135
131
|
if (!hit._scores) hit._scores = {};
|
|
136
|
-
hit._scores[scoringKey] =
|
|
132
|
+
hit._scores[scoringKey] = hitScore;
|
|
137
133
|
}
|
|
138
134
|
}
|
|
139
135
|
}
|
package/index.d.ts
CHANGED
|
@@ -208,7 +208,7 @@ export class Studio {
|
|
|
208
208
|
features(version?: string): Features;
|
|
209
209
|
addFeatures(featuresResult: FeaturesResult): void;
|
|
210
210
|
scoring(): Scoring;
|
|
211
|
-
addScores(scoringResult: string
|
|
211
|
+
addScores(scoringResult: Array<{ id: string; score: number }>, scoringKey: string): void;
|
|
212
212
|
ranking(): Ranking;
|
|
213
213
|
addRanking(rankingResult: { items?: RankingItem[] }): void;
|
|
214
214
|
log(string: string): void;
|