summaryrefslogtreecommitdiff
path: root/ext/bg/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-01 22:13:37 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-01 22:13:37 -0700
commit92e62c798d750766fe6631cc4b1e9d67efe788f6 (patch)
tree45bcd5f14e2537090a862782cf1117b967552ed8 /ext/bg/dictionary.js
parent7eadff3457690074c5c0140a6e9ffd6164021176 (diff)
WIP
Diffstat (limited to 'ext/bg/dictionary.js')
-rw-r--r--ext/bg/dictionary.js20
1 files changed, 4 insertions, 16 deletions
diff --git a/ext/bg/dictionary.js b/ext/bg/dictionary.js
index 30c34687..d1b9e6b1 100644
--- a/ext/bg/dictionary.js
+++ b/ext/bg/dictionary.js
@@ -26,7 +26,7 @@ class Dictionary {
this.kanjiIndices = {};
}
- addTermDict(terms) {
+ addTermData(terms) {
let index = this.terms.length;
for (const [e, r, g, t] in terms) {
this.storeIndex(this.termIndices, e, index);
@@ -35,7 +35,7 @@ class Dictionary {
}
}
- addKanjiDict(kanji) {
+ addKanjiData(kanji) {
let index = this.kanji.length;
for (const [c, k, o, g] in kanji) {
this.storeIndex(this.kanjiIndices, c, index++);
@@ -46,26 +46,14 @@ class Dictionary {
findTerm(term) {
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(' ')
- };
+ return {id: index, expression: e, reading: r, glossary: g, tags: t.split(' ')};
});
}
findKanji(kanji) {
return (this.kanjiIndices[kanji] || []).map(index => {
const [c, k, o, g] = def;
- return {
- id: kanji.charCodeAt(0),
- character: c,
- kunyomi: k,
- onyomi: o,
- glossary: g
- };
+ return {id: index, character: c, kunyomi: k, onyomi: o, glossary: g};
});
}