updating from dev

This commit is contained in:
2026-05-04 04:24:18 +02:00
parent 46afca976d
commit 2f1e42343b
76 changed files with 5554 additions and 2527 deletions

View File

@@ -4,27 +4,29 @@ export default (obj, word) => {
return obj.map(tmp => {
let rscore = 0
, startat = 0
, string = tmp.tag
, cscore
, score;
for(let i = 0; i < word.length; i++) {
const idxOf = string.toLowerCase().indexOf(word.toLowerCase()[i], startat);
const stringNorm = (tmp.tag || "").normalize('NFC').toLowerCase();
const wordNorm = (word || "").normalize('NFC').toLowerCase();
for(let i = 0; i < wordNorm.length; i++) {
const idxOf = stringNorm.indexOf(wordNorm[i], startat);
if(-1 === idxOf)
return { score: 0 };
if(startat === idxOf)
cscore = 0.7;
else {
cscore = 0.1;
if(string[idxOf - 1] === ' ')
if(stringNorm[idxOf - 1] === ' ')
cscore += 0.8;
}
if(string[idxOf] === word[i])
if(stringNorm[idxOf] === wordNorm[i])
cscore += 0.1;
rscore += cscore;
startat = idxOf + 1;
}
score = 0.5 * (rscore / string.length + rscore / word.length);
if(word.toLowerCase()[0] === string.toLowerCase()[0] && score < 0.85)
score = 0.5 * (rscore / stringNorm.length + rscore / wordNorm.length);
if(wordNorm[0] === stringNorm[0] && score < 0.85)
score += 0.15;
return {