Skip to content

Commit

Permalink
Call t.decode() only when t is a unicode string in function levsim
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Apr 5, 2018
1 parent 27e76b8 commit 44e68f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gensim/models/levenshtein.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ def levsim(alpha, beta, t1, t2):
Answering", 2017 <http://www.aclweb.org/anthology/S/S17/S17-2051.pdf>`__.
"""
t1 = t1.decode() # make sure both strings are in unicode
t2 = t2.decode()
if isinstance(t1, unicode):
t1 = t1.decode() # make sure both strings are in unicode
if isinstance(t2, unicode):
t2 = t2.decode()
assert isinstance(t1, str) and isinstance(t2, str)
return alpha * (1 - distance(t1, t2) * 1.0 / max(len(t1), len(t2)))**beta


Expand Down

0 comments on commit 44e68f8

Please sign in to comment.