add tag meta score

This commit is contained in:
siikamiika 2017-10-24 12:38:05 +03:00
parent bf15358bb4
commit e034ca3ad4
3 changed files with 5 additions and 23 deletions

View File

@ -359,12 +359,13 @@ class Database {
} }
const rows = []; const rows = [];
for (const [name, category, order, notes] of entries) { for (const [name, category, order, notes, score] of entries) {
const row = dictTagSanitize({ const row = dictTagSanitize({
name, name,
category, category,
order, order,
notes, notes,
score,
dictionary: summary.title dictionary: summary.title
}); });
@ -449,7 +450,7 @@ class Database {
const bank = []; const bank = [];
for (const name in index.tagMeta) { for (const name in index.tagMeta) {
const tag = index.tagMeta[name]; const tag = index.tagMeta[name];
bank.push([name, tag.category, tag.order, tag.notes]); bank.push([name, tag.category, tag.order, tag.notes, tag.score]);
} }
tagDataLoaded(summary, bank, ++bankTotalCount, bankLoadedCount++); tagDataLoaded(summary, bank, ++bankTotalCount, bankLoadedCount++);

View File

@ -293,6 +293,7 @@ function dictTagSanitize(tag) {
tag.category = tag.category || 'default'; tag.category = tag.category || 'default';
tag.notes = tag.notes || ''; tag.notes = tag.notes || '';
tag.order = tag.order || 0; tag.order = tag.order || 0;
tag.score = tag.score || 0;
return tag; return tag;
} }
@ -318,26 +319,6 @@ function dictTagsSort(tags) {
}); });
} }
function dictTermTagScore(tags) {
let score = 0;
const tagScores = {
'ik': -5,
'iK': -5,
'ok': -5,
'oK': -5,
'io': -5,
'oik': -5,
'P': 10
};
for (const tag of tags) {
score += tagScores[tag] || 0;
}
return score;
}
function dictFieldSplit(field) { function dictFieldSplit(field) {
return field.length === 0 ? [] : field.split(' '); return field.length === 0 ? [] : field.split(' ');
} }

View File

@ -121,7 +121,7 @@ class Translator {
} else { } else {
return 'normal'; return 'normal';
} }
})(dictTermTagScore(result.expressions.get(expression).get(reading))) })(tags.map(tag => tag.score).reduce((p, v) => p + v, 0))
}); });
} }
} }