summaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-17 18:13:20 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-17 18:13:20 -0700
commitf079db0471424a873f22315c7911571d467e97ad (patch)
tree96860218da185c478e269a7c12e6210ccba7ee3f /ext/bg/js/translator.js
parentbcd34149ab120f4bd0b823fbd6ae4efadfb02e90 (diff)
Support switching between edict and enamdict
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 46d63ed0..454d5079 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -63,14 +63,14 @@ class Translator {
}
}
- findTerm(text) {
+ findTerm(text, dict) {
const groups = {};
for (let i = text.length; i > 0; --i) {
const term = text.slice(0, i);
const dfs = this.deinflector.deinflect(term, t => {
const tags = [];
- for (const d of this.dictionary.findTerm(t)) {
+ for (const d of this.dictionary.findTerm(t, dict)) {
tags.push(d.tags);
}
@@ -79,7 +79,7 @@ class Translator {
if (dfs !== null) {
for (const df of dfs) {
- this.processTerm(groups, df.source, df.tags, df.rules, df.root);
+ this.processTerm(dict, groups, df.source, df.tags, df.rules, df.root);
}
}
}
@@ -125,13 +125,13 @@ class Translator {
return {results: results, length: length};
}
- findKanji(text) {
+ findKanji(text, dict) {
let results = [];
const processed = {};
for (const c of text) {
if (!processed.has(c)) {
- results = results.concat(this.dictionary.findKanji(c));
+ results = results.concat(this.dictionary.findKanji(c, dict));
processed[c] = true;
}
}
@@ -139,8 +139,8 @@ class Translator {
return results;
}
- processTerm(groups, source, tags, rules=[], root='') {
- for (const entry of this.dictionary.findTerm(root)) {
+ processTerm(dict, groups, source, tags, rules=[], root='') {
+ for (const entry of this.dictionary.findTerm(root, dict)) {
if (entry.id in groups) {
continue;
}