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