summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-15 17:05:09 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-22 14:43:06 -0500
commit45c685d00a7b98c33118dc50efd780e5be483936 (patch)
tree00aec03b33918a34337f71f23108e6f2f2afa95b /ext/bg/js/dictionary.js
parent50a171bc75f3329fec9d0aa24c4838f675a1b66d (diff)
Add variables for expression and reading
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 532d17c7..3a4a58a1 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -178,11 +178,13 @@ function dictTermsMergeBySequence(definitions, mainDictionary) {
function dictTermsMergeByGloss(result, definitions, appendTo=null, mergedIndices=null) {
const definitionsByGloss = appendTo !== null ? appendTo : new Map();
for (const [index, definition] of definitions.entries()) {
+ const {expression, reading} = definition;
+
if (mergedIndices !== null) {
- const expressionMap = result.expressions.get(definition.expression);
+ const expressionMap = result.expressions.get(expression);
if (
typeof expressionMap !== 'undefined' &&
- typeof expressionMap.get(definition.reading) !== 'undefined'
+ typeof expressionMap.get(reading) !== 'undefined'
) {
mergedIndices.add(index);
} else {
@@ -207,11 +209,11 @@ function dictTermsMergeByGloss(result, definitions, appendTo=null, mergedIndices
definitionsByGloss.set(gloss, glossDefinition);
}
- glossDefinition.expression.add(definition.expression);
- glossDefinition.reading.add(definition.reading);
+ glossDefinition.expression.add(expression);
+ glossDefinition.reading.add(reading);
- result.expression.add(definition.expression);
- result.reading.add(definition.reading);
+ result.expression.add(expression);
+ result.reading.add(reading);
for (const tag of definition.definitionTags) {
if (!glossDefinition.definitionTags.find((existingTag) => existingTag.name === tag.name)) {
@@ -221,16 +223,16 @@ function dictTermsMergeByGloss(result, definitions, appendTo=null, mergedIndices
if (appendTo === null) {
// result->expressions[ Expression1[ Reading1[ Tag1, Tag2 ] ], Expression2, ... ]
- if (!result.expressions.has(definition.expression)) {
- result.expressions.set(definition.expression, new Map());
+ if (!result.expressions.has(expression)) {
+ result.expressions.set(expression, new Map());
}
- if (!result.expressions.get(definition.expression).has(definition.reading)) {
- result.expressions.get(definition.expression).set(definition.reading, []);
+ if (!result.expressions.get(expression).has(reading)) {
+ result.expressions.get(expression).set(reading, []);
}
for (const tag of definition.termTags) {
- if (!result.expressions.get(definition.expression).get(definition.reading).find((existingTag) => existingTag.name === tag.name)) {
- result.expressions.get(definition.expression).get(definition.reading).push(tag);
+ if (!result.expressions.get(expression).get(reading).find((existingTag) => existingTag.name === tag.name)) {
+ result.expressions.get(expression).get(reading).push(tag);
}
}
}
@@ -251,7 +253,7 @@ function dictTermsMergeByGloss(result, definitions, appendTo=null, mergedIndices
}
return definitionsByGloss;
-}
+ }
function dictTagBuildSource(name) {
return dictTagSanitize({name, category: 'dictionary', order: 100});