@@ -2082,7 +2082,7 @@ def _morphy(self, form, pos, check_exceptions=True):
20822082 # Given an original string x
20832083 # 1. Apply rules once to the input to get y1, y2, y3, etc.
20842084 # 2. Return all that are in the database
2085- # 3. If there are no matches: (edited by ekaf) don't recurse, return an empty list.
2085+ # (edited by ekaf) If there are no matches return an empty list.
20862086
20872087 exceptions = self ._exception_map [pos ]
20882088 substitutions = self .MORPHOLOGICAL_SUBSTITUTIONS [pos ]
@@ -2096,7 +2096,7 @@ def apply_rules(forms):
20962096 ]
20972097
20982098 def filter_forms (forms ):
2099- result = []
2099+ result = [] # Return an empty list if we can't find anything
21002100 seen = set ()
21012101 for form in forms :
21022102 if form in self ._lemma_pos_offset_map :
@@ -2106,21 +2106,15 @@ def filter_forms(forms):
21062106 seen .add (form )
21072107 return result
21082108
2109- # 0. Check the exception lists
2110- if check_exceptions :
2111- if form in exceptions :
2112- return filter_forms ([form ] + exceptions [form ])
2113-
2114- # 1. Apply rules once to the input to get y1, y2, y3, etc.
2115- forms = apply_rules ([form ])
2109+ if check_exceptions and form in exceptions :
2110+ # 0. Check the exception lists
2111+ forms = exceptions [form ]
2112+ else :
2113+ # 1. Apply rules once to the input to get y1, y2, y3, etc.
2114+ forms = apply_rules ([form ])
21162115
21172116 # 2. Return all that are in the database (and check the original too)
2118- results = filter_forms ([form ] + forms )
2119- if results :
2120- return results
2121-
2122- # Return an empty list if we can't find anything
2123- return []
2117+ return filter_forms ([form ] + forms )
21242118
21252119 #############################################################
21262120 # Create information content from corpus
0 commit comments