This commit is contained in:
Alex Yatskov 2016-03-20 18:27:11 -07:00
parent 2d526b7ecd
commit c242e49c7f
3 changed files with 12 additions and 16 deletions

View File

@ -19,7 +19,7 @@
function getRangeAtCursor(e, lookAhead) { function getRangeAtCursor(e, lookAhead) {
const range = document.caretRangeFromPoint(e.clientX, e.clientY); const range = document.caretRangeFromPoint(e.clientX, e.clientY);
if (range === null) { if (range === null) {
return null return null;
} }
const node = range.startContainer; const node = range.startContainer;

View File

@ -23,7 +23,6 @@ class Deinflection {
this.term = term; this.term = term;
this.tags = tags; this.tags = tags;
this.rule = rule; this.rule = rule;
this.success = false;
} }
validate(validator) { validate(validator) {
@ -63,17 +62,15 @@ class Deinflection {
} }
} }
// FIX if (!allowed || !this.term.endsWith(kanaIn)) {
// if (!allowed || !this.term.endswith(kanaIn)) { continue;
// continue; }
// }
// FIX const term = self.term.slice(0, -kanaIn.length) + kanaOut;
// const term = self.term[:-kanaIn.length] + kanaOut; const child = new Deinflection(term, tagsOut, rule);
// const child = new Deinflection(term, tagsOut, rule); if (child.deinflect(validator, rules)) {
// if (child.deinflect(validator, rules)) { this.children.append(child);
// this.children.append(child); }
// }
} }
} }
@ -82,8 +79,7 @@ class Deinflection {
searchTags(tag, tags) { searchTags(tag, tags) {
for (const t of tags) { for (const t of tags) {
// FIX if (tag === t) {
if (re.search(tag, t)) {
return true; return true;
} }
} }
@ -123,7 +119,7 @@ class Deinflector {
} }
deinflect(term, validator) { deinflect(term, validator) {
const node = new Deinflection(term) const node = new Deinflection(term);
if (node.deinflect(validator, this.rules)) { if (node.deinflect(validator, this.rules)) {
return node.gather(); return node.gather();
} }

View File

@ -57,7 +57,7 @@ trans.initialize({
rules: 'jp/data/rules.json', rules: 'jp/data/rules.json',
edict: 'jp/data/edict.json', edict: 'jp/data/edict.json',
enamdict: 'jp/data/enamdict.json', enamdict: 'jp/data/enamdict.json',
kanjidic: 'jp/data/kanjidic.json', kanjidic: 'jp/data/kanjidic.json'
}, function() { }, function() {
alert('Loaded'); alert('Loaded');
// alert(trans.dictionary.findTerm('猫')); // alert(trans.dictionary.findTerm('猫'));