summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-24 12:38:05 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-24 12:38:05 +0300
commite034ca3ad4f88282e8dfec27df5cb7c55e0a47c6 (patch)
tree165f11bf51670ca87b4c8cce30dee0c458b4c933
parentbf15358bb433be22bf412a14911bf275079ae4fc (diff)
add tag meta score
-rw-r--r--ext/bg/js/database.js5
-rw-r--r--ext/bg/js/dictionary.js21
-rw-r--r--ext/bg/js/translator.js2
3 files changed, 5 insertions, 23 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 15291968..469b1311 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -359,12 +359,13 @@ class Database {
}
const rows = [];
- for (const [name, category, order, notes] of entries) {
+ for (const [name, category, order, notes, score] of entries) {
const row = dictTagSanitize({
name,
category,
order,
notes,
+ score,
dictionary: summary.title
});
@@ -449,7 +450,7 @@ class Database {
const bank = [];
for (const name in index.tagMeta) {
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++);
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index ee056273..50932735 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -293,6 +293,7 @@ function dictTagSanitize(tag) {
tag.category = tag.category || 'default';
tag.notes = tag.notes || '';
tag.order = tag.order || 0;
+ tag.score = tag.score || 0;
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) {
return field.length === 0 ? [] : field.split(' ');
}
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 22c5022f..5fcdea76 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -121,7 +121,7 @@ class Translator {
} else {
return 'normal';
}
- })(dictTermTagScore(result.expressions.get(expression).get(reading)))
+ })(tags.map(tag => tag.score).reduce((p, v) => p + v, 0))
});
}
}