summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/js/deinflector.js4
-rw-r--r--ext/bg/js/dictionary.js40
-rw-r--r--ext/bg/js/translator.js8
3 files changed, 33 insertions, 19 deletions
diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js
index 3c24ae3a..ec43f037 100644
--- a/ext/bg/js/deinflector.js
+++ b/ext/bg/js/deinflector.js
@@ -52,6 +52,10 @@ class Deinflection {
for (const v of variants) {
let allowed = this.tags.length === 0;
for (const tag of this.tags) {
+ //
+ // TODO: Handle addons through tags.json or rules.json
+ //
+
if (v.tagsIn.indexOf(tag) !== -1) {
allowed = true;
break;
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 4645189d..90a40ee5 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -41,8 +41,29 @@ class Dictionary {
results = results.concat(
indices.map(index => {
const [e, r, t, ...g] = dict.defs[index];
- const tags = Dictionary.fixupTags(t.split(' '));
- return {id: index, expression: e, reading: r, glossary: g, tags: tags};
+ const addons = [];
+ const tags = t.split(' ');
+
+ //
+ // TODO: Handle addons through data.
+ //
+
+ for (const tag of tags) {
+ if (tag.startsWith('v5') && tag !== 'v5') {
+ addons.push('v5');
+ } else if (tag.startsWith('vs-')) {
+ addons.push('vs');
+ }
+ }
+
+ return {
+ id: index,
+ expression: e,
+ reading: r,
+ glossary: g,
+ tags: tags.concat(addons),
+ addons: addons
+ };
})
);
}
@@ -63,19 +84,4 @@ class Dictionary {
return results;
}
-
- static fixupTags(tags) {
- const results = [];
- for (const tag of tags) {
- if (tag.startsWith('v5') && tag !== 'v5') {
- results.push('v5');
- } else if (tag.startsWith('vs-')) {
- results.push('vs');
- }
-
- results.push(tag);
- }
-
- return results;
- }
}
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index edbf10cc..6be80581 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -162,7 +162,7 @@ class Translator {
let tagItems = [];
for (const tag of entry.tags) {
const tagItem = this.tags[tag];
- if (tagItem) {
+ if (tagItem && entry.addons.indexOf(tag) === -1) {
tagItems.push({
class: tagItem.class || 'default',
order: tagItem.order || Number.MAX_SAFE_INTEGER,
@@ -170,6 +170,11 @@ class Translator {
name: tag
});
}
+
+ //
+ // TODO: Handle tagging as popular through data.
+ //
+
if (tag === 'P') {
popular = true;
}
@@ -195,7 +200,6 @@ class Translator {
return 0;
});
-
if (matched) {
groups[entry.id] = {
expression: entry.expression,