Fixing deinflection bugs
Former-commit-id: 6b5776ae9ea8243380a845289b61999641e6af00
This commit is contained in:
parent
d9e3e3619e
commit
c854826ed4
@ -32,9 +32,24 @@ class Deinflection:
|
|||||||
self.term = term
|
self.term = term
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
self.rule = rule
|
self.rule = rule
|
||||||
|
self.success = False
|
||||||
|
|
||||||
|
|
||||||
|
def validateTerm(self, validator):
|
||||||
|
for tags in validator(self.term):
|
||||||
|
if len(self.tags) == 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
for tag in self.tags:
|
||||||
|
if self.searchTags(tag, tags):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def deinflect(self, validator, rules, candidates):
|
def deinflect(self, validator, rules, candidates):
|
||||||
|
if self.validateTerm(validator):
|
||||||
|
child = Deinflection(self.term)
|
||||||
|
self.children.append(child)
|
||||||
|
|
||||||
for rule, variants in rules.items():
|
for rule, variants in rules.items():
|
||||||
for variant in variants:
|
for variant in variants:
|
||||||
tagsIn = variant['tagsIn']
|
tagsIn = variant['tagsIn']
|
||||||
@ -61,14 +76,6 @@ class Deinflection:
|
|||||||
if len(self.children) > 0:
|
if len(self.children) > 0:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for tags in validator(self.term):
|
|
||||||
if len(self.tags) == 0:
|
|
||||||
return True
|
|
||||||
|
|
||||||
for tag in self.tags:
|
|
||||||
if self.searchTags(tag, tags):
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def searchTags(self, tag, tags):
|
def searchTags(self, tag, tags):
|
||||||
for t in tags:
|
for t in tags:
|
||||||
@ -79,8 +86,8 @@ class Deinflection:
|
|||||||
def gather(self):
|
def gather(self):
|
||||||
if len(self.children) == 0:
|
if len(self.children) == 0:
|
||||||
endpoint = {
|
endpoint = {
|
||||||
'root': self.term,
|
'root': self.term,
|
||||||
'source': self.term,
|
'source': self.term,
|
||||||
'rules': [self.rule] if self.rule else list()
|
'rules': [self.rule] if self.rule else list()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user