From 9ce77c40b566888e2cfc877cbd743d4e251d81b0 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 9 Nov 2013 10:45:25 -0800 Subject: [PATCH] Fixes to deinflector Former-commit-id: 6b7e2b5e0b4e181abe663c239302b0f9d031b5f8 --- yomi_base/japanese2/deinflect.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yomi_base/japanese2/deinflect.py b/yomi_base/japanese2/deinflect.py index 54c2354..4bb7213 100644 --- a/yomi_base/japanese2/deinflect.py +++ b/yomi_base/japanese2/deinflect.py @@ -62,6 +62,9 @@ class Deinflection: 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 @@ -105,8 +108,8 @@ class Deinflector: self.rules = json.load(fp) - def deinflect(self, term, validator=lambda term, tags: True): + def deinflect(self, term, validator): candidates = set() node = Deinflection(term) - node.deinflect(validator, self.rules, candidates) - return node.gather(), candidates + if node.deinflect(validator, self.rules, candidates): + return node.gather(), candidates