aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-09-10 22:35:31 -0700
committerAlex Yatskov <alex@foosoft.net>2016-09-10 22:35:31 -0700
commit64d6b8761d512ca608e1d1aedc14bebd3581283f (patch)
treee933715608fc05b538de0b4f4c053fe2ea4a12bf /ext
parent3ec57d5bf658c247835fc933c2c41ea4e5ea52f6 (diff)
WIP
Diffstat (limited to 'ext')
-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) {