aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-12 23:12:20 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-12 23:12:20 -0700
commit972b945b4cf37b421b53086ce592f385ebb83a35 (patch)
treef0a84a67f42d69534253b9e5d5060b6fb5015601 /ext/bg/js/dictionary.js
parentbf28dea2838619c6446367f240e240cdddef3586 (diff)
Work on new dictionary format
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js33
1 files changed, 25 insertions, 8 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index feb8c92b..185aaee2 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -33,16 +33,33 @@ class Dictionary {
findTerm(term) {
const results = [];
- return (this.termIndices[term] || []).map(index => {
- const [e, r, g, t] = this.terms[index];
- return {id: index, expression: e, reading: r, glossary: g, tags: t.split(' ')};
- });
+
+ for (const name in this.termDicts) {
+ const dict = this.termDicts[name];
+ const indices = dict.indices[term] || [];
+
+ results.push(
+ indices.map(index => {
+ const [e, r, t, ...g] = dict.defs[index];
+ return {id: index, expression: e, reading: r, glossary: g.join('; '), tags: t.split(' ')};
+ })
+ );
+ }
+
+ return results;
}
findKanji(kanji) {
- return (this.kanjiIndices[kanji] || []).map(index => {
- const [c, k, o, g] = def;
- return {id: index, character: c, kunyomi: k, onyomi: o, glossary: g};
- });
+ const results = [];
+
+ for (const name in this.termDicts) {
+ const def = this.termDicts[name][kanji];
+ if (def) {
+ const [c, k, o, g] = def;
+ results.push({id: index, character: c, kunyomi: k, onyomi: o, glossary: g});
+ }
+ }
+
+ return results;
}
}