adjust fuzzy alignment weights and normalize against larger of input sizes
tronnet/workflows: Code Style -- Web Components / style-web (push) Failing after 17s
tronnet/workflows: Code Style -- Web Components / style-web (push) Failing after 17s
This commit is contained in:
1 parent
b92aabb052
commit
93a42ea343
1 file changed
+5
-3
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user