Skip to content

Commit

Permalink
Move StringZilla import into the function
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Feb 19, 2024
1 parent d8cec5f commit 61c407d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nltk/metrics/distance.py
Expand Up @@ -22,8 +22,6 @@
import operator
import warnings

import stringzilla as sz


def _edit_dist_init(len1, len2):
lev = []
Expand Down Expand Up @@ -91,7 +89,9 @@ def edit_distance(s1, s2, substitution_cost=1, transpositions=False):
# StringZilla currently doesn't support transpositions and cost-parameterized substitutions.
# It's C implementation is 10x faster than a pure Python implementation.
if not transpositions and substitution_cost == 1:
return sz.edit_distance_unicode(s1, s2)
from stringzilla import edit_distance_unicode as sz_edit_dist

return sz_edit_dist(s1, s2)

# set up a 2-D array
len1 = len(s1)
Expand Down

0 comments on commit 61c407d

Please sign in to comment.