diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-03-25 21:55:22 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-03-25 21:55:22 -0700 |
commit | d38c5390eeb85438ee00fd528212dce4b31b457e (patch) | |
tree | 83244816ce041701939e4171eb313348f48c5e95 /ext | |
parent | a1bab38a2dafcbf0657ea3e653980cc053006ce7 (diff) |
Deinflection fixes.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/jp/deinflector.js | 3 | ||||
-rw-r--r-- | ext/jp/translator.js | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/ext/jp/deinflector.js b/ext/jp/deinflector.js index 8c23de81..03f9d40a 100644 --- a/ext/jp/deinflector.js +++ b/ext/jp/deinflector.js @@ -75,7 +75,8 @@ class Deinflection { searchTags(tag, tags) { for (const t of tags) { - if (tag === t) { + const re = new RegExp(tag); + if (re.test(t)) { return true; } } diff --git a/ext/jp/translator.js b/ext/jp/translator.js index 79f8515a..aef20f19 100644 --- a/ext/jp/translator.js +++ b/ext/jp/translator.js @@ -117,25 +117,25 @@ class Translator { const sl1 = v1.source.length; const sl2 = v2.source.length; if (sl1 > sl2) { - return 1; - } else if (sl1 > sl2) { return -1; + } else if (sl1 < sl2) { + return 1; } const p1 = v1.tags.indexOf('P') >= 0; const p2 = v2.tags.indexOf('P') >= 0; if (p1 && !p2) { - return 1; - } else if (!p1 && p2) { return -1; + } else if (!p1 && p2) { + return 1; } const rl1 = v1.rules.length; const rl2 = v2.rules.length; if (rl1 < rl2) { - return 1; - } else if (rl2 > rl1) { return -1; + } else if (rl2 > rl1) { + return 1; } return 0; |