LemmInflect
raw JSON → 0.2.3 verified Fri May 01 auth: no python maintenance
A Python module for English lemmatization and inflection (generating inflected forms from lemmas). It provides a lookup-based and rule-based approach for verbs, nouns, adjectives, and adverbs. Current version: 0.2.3 (last release April 2022). Release cadence is low.
pip install lemminflect Common errors
error lemminflect doesn't handle 'ran' as past tense of 'run' ↓
cause LemmInflect relies heavily on a lookup dictionary. Some irregular forms may be missing or have gaps.
fix
Use fallback to a rule-based lemmatizer (e.g., NLTK's WordNetLemmatizer) or add custom mappings.
error getInflection('fly', 'VBD') returns an empty tuple ↓
cause The word lemma 'fly' is stored but the past tense form 'flew' might be missing from the inflections dictionary in some cases.
fix
Check if the lemma exists: getLemma('fly', 'VB') should return 'fly'. Then try getInflection with the correct lemma. If still empty, consider using getAllInflections('fly') to see all known forms.
Warnings
gotcha POS tags must be in Penn Treebank format (e.g., 'VB', 'VBD', 'NN', 'JJ', etc.) not Universal Dependencies. Using wrong tags returns empty results silently. ↓
fix Use PTB tags: VB (verb base), VBD (past), VBG (gerund), VBN (past participle), VBP (present non-3rd), VBZ (present 3rd), NN (noun), NNS (plural noun), JJ (adjective), JJR (comparative), JJS (superlative), RB (adverb), RBR (comparative adverb), RBS (superlative adverb).
gotcha The function returns an empty list/tuple if the word is unknown or the lemma cannot be found. It does not raise exceptions. ↓
fix Always check the return value: e.g., result = getLemma('word', 'NN'); if result: ... else: handle unknown.
deprecated The module is not actively maintained; last release 0.2.3 was in 2022. No support for newer spaCy versions or Python 3.12+ out of the box. ↓
fix Consider using spaCy's built-in lemmatizer or the 'simplemma' library for active development.
Imports
- getLemma
from lemminflect import getLemma - getInflection
from lemminflect import getInflection - getAllInflections
from lemminflect import getAllInflections - getAllLemmas
from lemminflect import getAllLemmas - isTagBaseForm
from lemminflect import isTagBaseForm
Quickstart
from lemminflect import getLemma, getInflection
# Lemmatize a word
lemma = getLemma('flies', 'VERB')
print(f"Lemma: {lemma}") # Output: 'fly'
# Inflect a lemma to a specific form
inflected = getInflection('fly', 'VBD')
print(f"Inflected: {inflected}") # Output: ('flew',)
# Note: POS tags are Penn Treebank-like (NN, VB, JJ, etc.)