Remove gensim dependency to fix Python 3.14 build - #27
Merged
rsgoncalves merged 2 commits intoJun 23, 2026
Conversation
text2term only uses two functions from gensim: `strip_non_alphanum` and `strip_multiple_whitespaces`. Both are trivial regex substitutions. Inlining them removes the heavy gensim dependency (which pulls in numpy, scipy, smart-open, etc. and fails to build on Python 3.14 due to native extensions). The inlined implementations are exact equivalents of the gensim originals (gensim's versions just call `utils.to_unicode(s)` first, which is a no-op for str input on Python 3).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
==========================================
+ Coverage 86.74% 86.80% +0.06%
==========================================
Files 16 16
Lines 1305 1311 +6
Branches 208 208
==========================================
+ Hits 1132 1138 +6
Misses 118 118
Partials 55 55 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gensimdependency by inlining the two trivial regex functions that text2term actually uses from it (strip_non_alphanumandstrip_multiple_whitespaces)re.subcalls — the gensim originals just add ato_unicode()call which is a no-op forstrinput on Python 3Changes
text2term/onto_utils.py: Replacefrom gensim.parsing import ...with two local function definitions using the same regex patternspyproject.toml: Removegensim~=4.3.2from dependencies