From a3189b4ca44572df9d6038d8ac6d97262e0ba0f0 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 22 Mar 2016 20:17:11 -0700 Subject: Fixes --- ext/jp/translator.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ext/jp/translator.js b/ext/jp/translator.js index c45d7174..542871a9 100644 --- a/ext/jp/translator.js +++ b/ext/jp/translator.js @@ -55,7 +55,15 @@ class Translator { for (let i = text.length; i >= 0; --i) { const term = text.slice(0, i); - const dfs = this.deinflector.deinflect(term, this.validator); + const dfs = this.deinflector.deinflect(term, t => { + const tags = []; + for (const d of this.dictionary.findTerm(t)) { + tags.push(d.tags); + } + + return tags; + }); + if (dfs === null) { this.processTerm(groups, term); } else { @@ -132,15 +140,6 @@ class Translator { return 0; } - - validator(term) { - const tags = []; - for (const d of self.dictionary.findTerm(term)) { - tags.push(d.tags); - } - - return tags; - } } const trans = new Translator(); @@ -151,6 +150,5 @@ trans.initialize({ enamdict: 'jp/data/enamdict.json', kanjidic: 'jp/data/kanjidic.json' }, function() { - // alert('Loaded'); - // alert(trans.dictionary.findTerm('猫')); + console.log(trans.findTerm('食べました')); }); -- cgit v1.2.3