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