Skip to content

Commit 07aff67

Browse files
committed
Backport PR #1319: use rapidfuzz instead of fuzzywuzzy
FuzzyWuzzy is GPLv2 licensed which would force you to licence the whole project under GPLv2. I had the same problem on one of my projects and so I wrote [rapidfuzz](https://github.com/rhasspy/rapidfuzz) which is implementing the same algorithm but is based on a version of fuzzywuzzy that was MIT Licensed and is therefor MIT Licensed aswell, so it can be used in here without forcing a License change. As a nice bonus it is fully implemented in C++ and comes with a few Algorithmic improvements making it between 5 and 100 times faster than FuzzyWuzzy. (actually even faster since python-Levenshtein was not used)
1 parent cf70138 commit 07aff67

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

nbgrader/converters/base.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sqlalchemy
66
import traceback
77

8+
from rapidfuzz import fuzz
89
from traitlets.config import LoggingConfigurable, Config
910
from traitlets import Bool, List, Dict, Integer, Instance, Type
1011
from traitlets import default
@@ -118,11 +119,6 @@ def init_notebooks(self):
118119
assignment_glob2 = self._format_source("*", self.coursedir.student_id)
119120
found = glob.glob(assignment_glob2)
120121
if found:
121-
# Normally it is a bad idea to put imports in the middle of
122-
# a function, but we do this here because otherwise fuzzywuzzy
123-
# prints an annoying message about python-Levenshtein every
124-
# time nbgrader is run.
125-
from fuzzywuzzy import fuzz
126122
scores = sorted([(fuzz.ratio(assignment_glob, x), x) for x in found])
127123
self.log.error("Did you mean: %s", scores[-1][1])
128124

nbgrader/exchange/exchange.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from dateutil.tz import gettz
1010
from dateutil.parser import parse
11+
from rapidfuzz import fuzz
1112
from traitlets.config import LoggingConfigurable
1213
from traitlets import Unicode, Bool, Instance, Type, default, validate, TraitError
1314
from jupyter_core.paths import jupyter_data_dir
@@ -177,11 +178,6 @@ def _assignment_not_found(self, src_path, other_path):
177178
self.log.fatal(msg)
178179
found = glob.glob(other_path)
179180
if found:
180-
# Normally it is a bad idea to put imports in the middle of
181-
# a function, but we do this here because otherwise fuzzywuzzy
182-
# prints an annoying message about python-Levenshtein every
183-
# time nbgrader is run.
184-
from fuzzywuzzy import fuzz
185181
scores = sorted([(fuzz.ratio(self.src_path, x), x) for x in found])
186182
self.log.error("Did you mean: %s", scores[-1][1])
187183

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"requests",
104104
"jsonschema",
105105
"alembic",
106-
"fuzzywuzzy"
106+
"rapidfuzz"
107107
]
108108
)
109109

0 commit comments

Comments
 (0)