@arsedizioni/ars-utils 21.1.89 → 21.1.90

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.
@@ -1300,14 +1300,18 @@ class ClipperDocumentComponent extends ClipperDocumentManager {
1300
1300
  else {
1301
1301
  if (r.value?.items && r.value?.items.length > 0) {
1302
1302
  let minScore = 10;
1303
+ let maxScore = 0;
1303
1304
  r.value.items[0].anchors.forEach(n => {
1304
1305
  if (n.score < minScore) {
1305
1306
  minScore = n.score;
1306
1307
  }
1308
+ if (n.score > maxScore) {
1309
+ maxScore = n.score;
1310
+ }
1307
1311
  });
1308
- minScore = Math.trunc(minScore);
1312
+ maxScore = maxScore - minScore;
1309
1313
  r.value.items[0].anchors.forEach(n => {
1310
- let score = n.score - minScore;
1314
+ let score = (n.score - minScore) / maxScore || 1;
1311
1315
  n.score = score;
1312
1316
  n.veryRelevant = score > 0.7;
1313
1317
  });
@@ -2170,6 +2174,17 @@ class ClipperSearchResultManager extends ClipperDocumentManager {
2170
2174
  if (n.anchors) {
2171
2175
  let anchorType;
2172
2176
  let anchors = [];
2177
+ let minScore = 10;
2178
+ let maxScore = 0;
2179
+ n.anchors.forEach(a => {
2180
+ if (a.score < minScore) {
2181
+ minScore = a.score;
2182
+ }
2183
+ if (a.score > maxScore) {
2184
+ maxScore = a.score;
2185
+ }
2186
+ });
2187
+ maxScore = maxScore - minScore;
2173
2188
  n.anchors.forEach(a => {
2174
2189
  if (a.type === 20)
2175
2190
  return;
@@ -2178,13 +2193,14 @@ class ClipperSearchResultManager extends ClipperDocumentManager {
2178
2193
  anchors.push({ text: a.typeDescription });
2179
2194
  anchorType = a.type;
2180
2195
  }
2196
+ let score = (a.score - minScore) / maxScore || 1;
2181
2197
  anchors.push({
2182
2198
  text: a.text,
2183
2199
  title: a.title,
2184
2200
  documentId: a.documentId,
2185
2201
  uri: a.uri,
2186
- veryRelevant: a.score > 0.7,
2187
- score: a.score,
2202
+ veryRelevant: score > 0.7,
2203
+ score: score,
2188
2204
  chunk: a.chunk
2189
2205
  });
2190
2206
  });