summaryrefslogtreecommitdiff
path: root/ext/bg/js/deinflector.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-16 20:11:27 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-16 20:11:27 -0700
commit9ceef4649f07211079017d2cfcbc3756dd9a509b (patch)
tree8bc506f337a19e165e1391229c12e32480accd24 /ext/bg/js/deinflector.js
parentccf545919054be4dc2aa9efdc7cd914c867775a8 (diff)
Fixes to deinflection logic
Diffstat (limited to 'ext/bg/js/deinflector.js')
-rw-r--r--ext/bg/js/deinflector.js19
1 files changed, 4 insertions, 15 deletions
diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js
index 03f9d40a..3c24ae3a 100644
--- a/ext/bg/js/deinflector.js
+++ b/ext/bg/js/deinflector.js
@@ -32,7 +32,7 @@ class Deinflection {
}
for (const tag of this.tags) {
- if (this.searchTags(tag, tags)) {
+ if (tags.indexOf(tag) !== -1) {
return true;
}
}
@@ -43,7 +43,7 @@ class Deinflection {
deinflect(validator, rules) {
if (this.validate(validator)) {
- const child = new Deinflection(this.term);
+ const child = new Deinflection(this.term, this.tags);
this.children.push(child);
}
@@ -52,7 +52,7 @@ class Deinflection {
for (const v of variants) {
let allowed = this.tags.length === 0;
for (const tag of this.tags) {
- if (this.searchTags(tag, v.tagsIn)) {
+ if (v.tagsIn.indexOf(tag) !== -1) {
allowed = true;
break;
}
@@ -73,20 +73,9 @@ class Deinflection {
return this.children.length > 0;
}
- searchTags(tag, tags) {
- for (const t of tags) {
- const re = new RegExp(tag);
- if (re.test(t)) {
- return true;
- }
- }
-
- return false;
- }
-
gather() {
if (this.children.length === 0) {
- return [{root: this.term, rules: []}];
+ return [{root: this.term, tags: this.tags, rules: []}];
}
const paths = [];