acp-kernel 0.0.59-pr.228.78 → 0.0.59-pr.229.79
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/dist/index.js
CHANGED
|
@@ -3757,7 +3757,11 @@ function build(text) {
|
|
|
3757
3757
|
}
|
|
3758
3758
|
function docFeatures(text) {
|
|
3759
3759
|
const hit = cache.get(text);
|
|
3760
|
-
if (hit)
|
|
3760
|
+
if (hit) {
|
|
3761
|
+
cache.delete(text);
|
|
3762
|
+
cache.set(text, hit);
|
|
3763
|
+
return hit;
|
|
3764
|
+
}
|
|
3761
3765
|
const f = build(text);
|
|
3762
3766
|
if (text.length > 0 && text.length <= capChars) {
|
|
3763
3767
|
while (cachedChars + text.length > capChars && cache.size > 0) {
|
|
@@ -3862,21 +3866,14 @@ var fuzzyAlgorithm = {
|
|
|
3862
3866
|
// src/search/algorithms/hybrid.ts
|
|
3863
3867
|
var W_BM25 = 0.7;
|
|
3864
3868
|
var W_FUZZY = 0.3;
|
|
3865
|
-
function maxScore(results, floor) {
|
|
3866
|
-
let max = floor;
|
|
3867
|
-
for (const r of results) {
|
|
3868
|
-
if (r.score > max) max = r.score;
|
|
3869
|
-
}
|
|
3870
|
-
return max;
|
|
3871
|
-
}
|
|
3872
3869
|
var hybridAlgorithm = {
|
|
3873
3870
|
name: "hybrid",
|
|
3874
3871
|
description: "Weighted BM25(stem) + fuzzy n-gram. Default \u2014 best precision + recall.",
|
|
3875
3872
|
score(docs, query) {
|
|
3876
3873
|
const bm = bm25Algorithm.score(docs, query);
|
|
3877
3874
|
const fz = fuzzyAlgorithm.score(docs, query);
|
|
3878
|
-
const maxBm =
|
|
3879
|
-
const maxFz =
|
|
3875
|
+
const maxBm = bm.reduce((m, r) => r.score > m ? r.score : m, 1e-9);
|
|
3876
|
+
const maxFz = fz.reduce((m, r) => r.score > m ? r.score : m, 1e-9);
|
|
3880
3877
|
const bmMap = new Map(bm.map((r) => [r.ref, r.score / maxBm]));
|
|
3881
3878
|
const fzMap = new Map(fz.map((r) => [r.ref, r.score / maxFz]));
|
|
3882
3879
|
return docs.map((d) => ({
|