File tree 2 files changed +11
-5
lines changed
python/input_methods/hallelujah
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -122,12 +122,18 @@ def getSuggestionOfSpellChecker(self, input):
122
122
alternatives = self .spellchecker .get_candidates (input )
123
123
alternatives .sort (key = lambda x : x [0 ], reverse = True )
124
124
candidates = [word for freq , word in alternatives ]
125
+ # If the input word is longer than 3 characters, add phonetic and Pinyin suggestions
125
126
if len (input ) > 3 :
126
- encoded_key = fuzzySoundex .phonetics (input )
127
- phonetic_candidates = self .fuzzySoundexEncodedDict .get (encoded_key , [])
128
- phonetic_candidates .sort (key = lambda word : damerau_levenshtein_distance (word , input ))
127
+ phonetic_candidates = []
128
+ try :
129
+ encoded_key = fuzzySoundex .phonetics (input )
130
+ phonetic_candidates = self .fuzzySoundexEncodedDict .get (encoded_key , [])
131
+ phonetic_candidates .sort (key = lambda word : damerau_levenshtein_distance (word , input ))
132
+ except Exception as e :
133
+ logger .error (f"Error generating phonetic key for '{ input } ': { e } " )
134
+ phonetic_candidates = [] # Ensure phonetic_candidates is an empty list if an error occurs
135
+
129
136
pinyin_candidates = self .pinyinDict .get (input , [])
130
- # logger.debug("phonetic_candidates {}", phonetic_candidates)
131
137
candidates = candidates [:3 ] + pinyin_candidates [:3 ] + phonetic_candidates
132
138
return candidates
133
139
Original file line number Diff line number Diff line change 1
- 1.3.11
1
+ 1.3.12
You can’t perform that action at this time.
0 commit comments