aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2018-03-12 13:04:37 -0700
committerAlex Yatskov <alex@foosoft.net>2018-03-12 13:04:37 -0700
commit68cdd7d85b741d34133ea04b95a4eb1e49553ace (patch)
treeb6041ae3bbd2c327e57ca0766d77f3e11c654066 /ext/bg/js/translator.js
parentf0e9716aa5e763480cf6accceefcea4fa73bc149 (diff)
parent2470b6209a27ceea814a13d920a20683bacf09a6 (diff)
Merge branch 'dev'
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js22
1 files changed, 13 insertions, 9 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 005dd5de..c6af1f4e 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -75,9 +75,11 @@ class Translator {
const rawDefinitionsBySequence = await this.database.findTermsBySequence(Number(sequence), options.general.mainDictionary);
for (const definition of rawDefinitionsBySequence) {
- const tags = await this.expandTags(definition.definitionTags, definition.dictionary);
- tags.push(dictTagBuildSource(definition.dictionary));
- definition.definitionTags = tags;
+ const definitionTags = await this.expandTags(definition.definitionTags, definition.dictionary);
+ definitionTags.push(dictTagBuildSource(definition.dictionary));
+ definition.definitionTags = definitionTags;
+ const termTags = await this.expandTags(definition.termTags, definition.dictionary);
+ definition.termTags = termTags;
}
const definitionsByGloss = dictTermsMergeByGloss(result, rawDefinitionsBySequence);
@@ -91,9 +93,11 @@ class Translator {
for (const reading of result.expressions.get(expression).keys()) {
for (const definition of await this.database.findTermsExact(expression, reading, secondarySearchTitles)) {
- const tags = await this.expandTags(definition.definitionTags, definition.dictionary);
- tags.push(dictTagBuildSource(definition.dictionary));
- definition.definitionTags = tags;
+ const definitionTags = await this.expandTags(definition.definitionTags, definition.dictionary);
+ definitionTags.push(dictTagBuildSource(definition.dictionary));
+ definition.definitionTags = definitionTags;
+ const termTags = await this.expandTags(definition.termTags, definition.dictionary);
+ definition.termTags = termTags;
secondarySearchResults.push(definition);
}
}
@@ -113,11 +117,11 @@ class Translator {
const expressions = [];
for (const expression of result.expressions.keys()) {
for (const reading of result.expressions.get(expression).keys()) {
- const tags = await this.expandTags(result.expressions.get(expression).get(reading), result.dictionary);
+ const termTags = result.expressions.get(expression).get(reading);
expressions.push({
expression: expression,
reading: reading,
- termTags: dictTagsSort(tags),
+ termTags: dictTagsSort(termTags),
termFrequency: (score => {
if (score > 0) {
return 'popular';
@@ -126,7 +130,7 @@ class Translator {
} else {
return 'normal';
}
- })(tags.map(tag => tag.score).reduce((p, v) => p + v, 0))
+ })(termTags.map(tag => tag.score).reduce((p, v) => p + v, 0))
});
}
}