summaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 6c028c5c..9987f820 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -56,27 +56,24 @@ class Translator {
findTermGroups(text) {
const groups = {};
- const promises = [];
+ const deinflectPromises = [];
for (let i = text.length; i > 0; --i) {
- promises.push(
+ deinflectPromises.push(
this.deinflector.deinflect(text.slice(0, i), term => {
- return this.dictionary.findTerm(term).then(definitions => definitions.map(def => def.tags));
+ return this.dictionary.findTerm(term).then(definitions => definitions.map(definition => definition.tags));
}).then(inflects => {
+ const processPromises = [];
for (const inflect of inflects) {
- this.processTerm(
- groups,
- inflect.source,
- inflect.tags,
- inflect.rules,
- inflect.root
- );
+ processPromises.push(this.processTerm(groups, inflect.source, inflect.tags, inflect.rules, inflect.root));
}
+
+ return Promise.all(processPromises);
})
);
}
- return Promise.all(promises).then(Promise.resolve(groups));
+ return Promise.all(deinflectPromises).then(Promise.resolve(groups));
}
findTerm(text) {