aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-03-22 20:17:11 -0700
committerAlex Yatskov <alex@foosoft.net>2016-03-22 20:17:11 -0700
commita3189b4ca44572df9d6038d8ac6d97262e0ba0f0 (patch)
tree498c8096be5fcabee73a4d1f68576fce9a760376
parent495c12b6c27968837c135902b4446c3bba958590 (diff)
Fixes
-rw-r--r--ext/jp/translator.js22
1 files 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('食べました'));
});