adjust fuzzy alignment weights and normalize against larger of input sizes
tronnet/workflows: Code Style -- Web Components / style-web (push) Failing after 14s

This commit is contained in:
alu committed 2026-10-20 22:23:19 +00:00
1 parent b92aabb052
commit 744620a00e
1 file changed
+5 -3
+5 -3
View File
@@ -268,15 +268,16 @@ function sortInstances () {
else if (searchCriteria === "fuzzy") { else if (searchCriteria === "fuzzy") {
const penalties = { const penalties = {
m: 0, m: 0,
x: 1, x: 2,
o: 0, o: 3,
e: 1 e: 1
}; };
criteria = (item, query) => { criteria = (item, query) => {
// lower is better // lower is better
const { score, CIGAR } = wfa.wfAlign(query, item, penalties, true); const { score, CIGAR } = wfa.wfAlign(query, item, penalties, true);
const alignment = wfa.DecodeCIGAR(CIGAR); const alignment = wfa.DecodeCIGAR(CIGAR);
return { score: score / item.length, alignment }; const maxlength = Math.max(item.length, query.length)
return { score: score / maxlength, alignment };
}; };
} }
@@ -306,6 +307,7 @@ function sortInstances () {
for (let i = 0; i < instances.length; i++) { for (let i = 0; i < instances.length; i++) {
container.appendChild(instances[i]); container.appendChild(instances[i]);
console.log(instances[i].dataset.name, instances[i].searchQueryResult.score)
instances[i].update(); instances[i].update();
} }
} }