Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e141ffe

Browse files
Merge pull request chatopera#54 from Shaun-Chen/master
Fixed chatopera#51 return editor distance with empty vectors(again)
2 parents a9e86a4 + 4ade9bd commit e141ffe

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

synonyms/synonyms.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,18 @@ def _similarity_distance(s1, s2):
226226
'''
227227
compute similarity with distance measurement
228228
'''
229-
g = 0.0
229+
# g = 0.0
230230
try:
231231
g = cosine(_flat_sum_array(_get_wv(s1)), _flat_sum_array(_get_wv(s2)))
232232
except: pass
233+
234+
try:
235+
g_nan_num = np.isnan(g).sum()
236+
if g_nan_num == 100:
237+
g = 0.0
238+
except:
239+
pass
240+
233241
u = _nearby_levenshtein_distance(s1, s2)
234242
# print("g: %s, u: %s" % (g, u))
235243
if u >= 0.99:

0 commit comments

Comments
 (0)