Skip to content

Commit

Permalink
moved base cases to top
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislit committed Feb 8, 2019
1 parent 509d563 commit f34502b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions abydos/distance/_meta_levenshtein.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ def dist_abs(self, src, tar):
.. versionadded:: 0.4.0
"""
if src == tar:
return 0.0
if not src:
return len(src)
if not tar:
return len(tar)

src_tok = self.params['tokenizer'].tokenize(src)
src_ordered = src_tok.get_list()
src_tok = src_tok.get_counter()
Expand Down Expand Up @@ -170,13 +177,6 @@ def dist_abs(self, src, tar):
def _dist(s_tok, t_tok):
return dists[(s_tok, t_tok)] * vws_dict[s_tok] * vwt_dict[t_tok]

if src == tar:
return 0
if not src:
return len(tar_ordered)
if not tar:
return len(src_ordered)

d_mat = np_zeros(
(len(src_ordered) + 1, len(tar_ordered) + 1), dtype=np_float
)
Expand Down

0 comments on commit f34502b

Please sign in to comment.