Deinflection fixes

This commit is contained in:
Alex Yatskov 2016-03-25 20:54:04 -07:00
parent 059b2eb4f2
commit a1bab38a2d
2 changed files with 12 additions and 4 deletions

View File

@ -36,6 +36,13 @@ function onMessage(request, sender, callback) {
} }
} }
function onInit() {
chrome.runtime.onMessage.addListener(onMessage);
const res1 = window.trans.findTerm('食べられない');
const res2 = window.trans.findTerm('作られている');
}
(() => { (() => {
const res = { const res = {
rules: 'jp/data/rules.json', rules: 'jp/data/rules.json',
@ -44,8 +51,5 @@ function onMessage(request, sender, callback) {
kanjidic: 'jp/data/kanjidic.json' kanjidic: 'jp/data/kanjidic.json'
}; };
window.trans = new Translator( window.trans = new Translator(res, onInit);
res,
() => chrome.runtime.onMessage.addListener(onMessage)
);
})(); })();

View File

@ -98,6 +98,10 @@ class Translator {
processTerm(groups, source, rules=[], root='') { processTerm(groups, source, rules=[], root='') {
for (const entry of this.dictionary.findTerm(root || source)) { for (const entry of this.dictionary.findTerm(root || source)) {
if (entry.id in groups) {
continue;
}
groups[entry.id] = { groups[entry.id] = {
expression: entry.expression, expression: entry.expression,
reading: entry.reading, reading: entry.reading,