aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-13 02:40:20 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-13 02:40:20 +0300
commit7ec28bea5422cda4304b660eccdb39d690f74fad (patch)
treeddd2fa3d0f9aaf8adca9dbfb822d1f511d4860aa /ext/bg/js
parentc0f56480bb34b8811835b8d545443bd9ea87c997 (diff)
change db format, rename tags to definitionTags
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/database.js19
-rw-r--r--ext/bg/js/dictionary.js14
-rw-r--r--ext/bg/js/templates.js4
-rw-r--r--ext/bg/js/translator.js10
4 files changed, 23 insertions, 24 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 1c2194df..8350e214 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -68,12 +68,11 @@ class Database {
const results = [];
await this.db.terms.where('expression').equals(term).or('reading').equals(term).each(row => {
if (titles.includes(row.dictionary)) {
- const tags = row.tags.split('\t');
results.push({
expression: row.expression,
reading: row.reading,
- tags: dictFieldSplit(tags[0]),
- termTags: tags.length > 1 ? dictFieldSplit(tags[1]) : [],
+ definitionTags: dictFieldSplit(row.definitionTags),
+ termTags: dictFieldSplit(row.termTags || ''),
rules: dictFieldSplit(row.rules),
glossary: row.glossary,
score: row.score,
@@ -95,12 +94,11 @@ class Database {
const results = [];
await this.db.terms.where('sequence').equals(sequence).each(row => {
if (row.dictionary === mainDictionary) {
- const tags = row.tags.split('\t');
results.push({
expression: row.expression,
reading: row.reading,
- tags: dictFieldSplit(tags[0]),
- termTags: tags.length > 1 ? dictFieldSplit(tags[1]) : [],
+ definitionTags: dictFieldSplit(row.definitionTags),
+ termTags: dictFieldSplit(row.termTags || ''),
rules: dictFieldSplit(row.rules),
glossary: row.glossary,
score: row.score,
@@ -229,11 +227,11 @@ class Database {
const rows = [];
if (summary.version === 1) {
- for (const [expression, reading, tags, rules, score, ...glossary] of entries) {
+ for (const [expression, reading, definitionTags, rules, score, ...glossary] of entries) {
rows.push({
expression,
reading,
- tags,
+ definitionTags,
rules,
score,
glossary,
@@ -241,15 +239,16 @@ class Database {
});
}
} else {
- for (const [expression, reading, tags, rules, score, glossary, sequence] of entries) {
+ for (const [expression, reading, definitionTags, rules, score, glossary, sequence, termTags] of entries) {
rows.push({
expression,
reading,
- tags,
+ definitionTags,
rules,
score,
glossary,
sequence,
+ termTags,
dictionary: summary.title
});
}
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index d057ae83..816e96c4 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -115,8 +115,8 @@ function dictTermsCompressTags(definitions) {
let lastPos = '';
for (const definition of definitions) {
- const dictionary = JSON.stringify(definition.tags.filter(tag => tag.category === 'dictionary').map(tag => tag.name).sort());
- const pos = JSON.stringify(definition.tags.filter(tag => tag.category === 'pos').map(tag => tag.name).sort());
+ const dictionary = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'dictionary').map(tag => tag.name).sort());
+ const pos = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'pos').map(tag => tag.name).sort());
const filterOutCategories = [];
@@ -133,7 +133,7 @@ function dictTermsCompressTags(definitions) {
lastPos = pos;
}
- definition.tags = definition.tags.filter(tag => !filterOutCategories.includes(tag.category));
+ definition.definitionTags = definition.definitionTags.filter(tag => !filterOutCategories.includes(tag.category));
}
}
@@ -229,7 +229,7 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) {
definitionsByGloss[gloss] = {
expression: new Set(),
reading: new Set(),
- tags: new Set(),
+ definitionTags: new Set(),
glossary: definition.glossary,
source: result.source,
reasons: [],
@@ -253,11 +253,11 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) {
result.expressions.get(definition.expression).set(definition.reading, new Set());
}
- for (const tag of definition.tags) {
+ for (const tag of definition.definitionTags) {
if (typeof tag === 'string') {
- definitionsByGloss[gloss].tags.add(tag);
+ definitionsByGloss[gloss].definitionTags.add(tag);
} else if (tag.category && tag.category !== 'dictionary') {
- definitionsByGloss[gloss].tags.add(tag.name);
+ definitionsByGloss[gloss].definitionTags.add(tag.name);
}
}
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index e8bd43e9..b7b4721e 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -206,14 +206,14 @@ templates['model.html'] = template({"1":function(container,depth0,helpers,partia
templates['terms.html'] = template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});
- return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.definitionTags : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.only : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.program(13, data, 0),"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
var stack1;
return "<div>\n"
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitionTags : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n";
},"3":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index e307efc0..c102f6a8 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -79,9 +79,9 @@ class Translator {
for (const gloss in definitionsByGloss) {
const definition = definitionsByGloss[gloss];
- const tags = await this.expandTags(definition.tags, definition.dictionary);
+ const tags = await this.expandTags(definition.definitionTags, definition.dictionary);
tags.push(dictTagBuildSource(definition.dictionary));
- definition.tags = dictTagsSort(tags);
+ definition.definitionTags = dictTagsSort(tags);
result.definitions.push(definition);
}
@@ -166,8 +166,8 @@ class Translator {
let definitions = [];
for (const deinflection of deinflections) {
for (const definition of deinflection.definitions) {
- const tags = await this.expandTags(definition.tags, definition.dictionary);
- tags.push(dictTagBuildSource(definition.dictionary));
+ const definitionTags = await this.expandTags(definition.definitionTags, definition.dictionary);
+ definitionTags.push(dictTagBuildSource(definition.dictionary));
const termTags = await this.expandTags(definition.termTags, definition.dictionary);
definitions.push({
@@ -179,7 +179,7 @@ class Translator {
expression: definition.expression,
reading: definition.reading,
glossary: definition.glossary,
- tags: dictTagsSort(tags),
+ definitionTags: dictTagsSort(definitionTags),
termTags: dictTagsSort(termTags),
sequence: definition.sequence
});