allow adjusting algorithm parameters
cjquines opened this issue · comments
you said it yourself that these numbers were arbitrary so what if they werent
Line 395 in 0fc889c
the arbitrary parts are:
score -= (12+unmatchedDistance) * extraMatchGroupCount
, or how much we penalize having multiple groups. this could be agroupPenalty
parameter, default 12?score -= matchesBest[0]*10
, or how much we penalize not being near the start.distancePenalty
, default 10?score *= (uniqueBeginningIndexes-24)*10
i have absolutely no idea what this is it seems small too so idkif(isSubstring) score /= 10
maybesubstringBonus
?if(isSubstringBeginning) score /= 10
maybesubstringBeginningBonus
? maybe this can just be equal tosubstringBonus
and we don't need a param for this lolscore -= targetLen - searchLen
this seems like it should have a multiplier around it, calledlengthPenalty
, something likescore -= (targetLen - searchLen) * lengthPenalty
default 1?
this doesn't make it any slower and i think it's pretty useful. for example, my application doesn't want to penalize distance to the start. fusejs is nice for this because it has ignoreLocation for this, but i don't like fuse due to performance issues.
hmm. i don't think it's worth the complexity. i don't think most people care about these options?
maybe if you're one of the few people who wants to change the numbers, then just change the numbers (edit the code).
what's your use case that wants to ignore location?
hmm thats fair. my use case is that im indexing over descriptions, so it's not necessarily true that what you want is in the beginning.