Deinflection fixes.

This commit is contained in:
Alex Yatskov 2016-03-25 21:55:22 -07:00
parent a1bab38a2d
commit d38c5390ee
2 changed files with 8 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -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;