Skip to content

Commit

Permalink
Merge pull request chatopera#54 from Shaun-Chen/master
Browse files Browse the repository at this point in the history
Fixed chatopera#51 return editor distance with empty vectors(again)
  • Loading branch information
hailiang-wang committed Mar 9, 2018
2 parents a9e86a4 + 4ade9bd commit e141ffe
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion synonyms/synonyms.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,18 @@ def _similarity_distance(s1, s2):
'''
compute similarity with distance measurement
'''
g = 0.0
# g = 0.0
try:
g = cosine(_flat_sum_array(_get_wv(s1)), _flat_sum_array(_get_wv(s2)))
except: pass

try:
g_nan_num = np.isnan(g).sum()
if g_nan_num == 100:
g = 0.0
except:
pass

u = _nearby_levenshtein_distance(s1, s2)
# print("g: %s, u: %s" % (g, u))
if u >= 0.99:
Expand Down

0 comments on commit e141ffe

Please sign in to comment.