Overview
Morphy is WordNet’s morphological analyzer that reduces inflected word forms to their base lemmas. bun_nltk provides both JavaScript and native implementations for finding dictionary base forms.Method
morphy
Reduces an inflected or variant word form to its base lemma found in WordNet.word: string- Inflected word form to analyzepos?: WordNetPos- Optional part of speech: “n” (noun), “v” (verb), “a” (adjective), or “r” (adverb)
string | null- Base lemma if found in WordNet, null otherwise
- Tries native morphological algorithm first via
wordnetMorphyAsciiNative() - Falls back to rule-based candidate generation
- Returns first candidate found in WordNet’s lemma index
- Without POS, tries all morphological rules across all parts of speech
- Always validates results against actual WordNet entries
Native Function
wordnetMorphyAsciiNative
Direct access to the native morphological analyzer (lower-level API).word: string- Word to analyzepos?: "n" | "v" | "a" | "r"- Optional part of speech
string- Base form (empty string if not found)
- Implemented in native code for performance
- Uses WordNet’s morphological database
- Returns empty string (not null) when no base form found
- Does NOT validate against WordNet entries (unlike
morphy()method) - Lower-level interface; prefer
WordNet.morphy()for most use cases
Morphological Rules
bun_nltk includes rule-based morphology as a fallback:Noun Rules
Verb Rules
Adjective Rules
Adverb Rules
Algorithm Flow
Themorphy() method follows this algorithm:
Usage Examples
Normalizing Text
Handling Irregular Forms
Comparing Lemmatization Approaches
Validating Lemmatization
Building Lemma Vocabulary
Performance Considerations
- Native First: Always tries native morphy first for best performance
- Caching: Consider caching morphy results for repeated lookups
- POS Filtering: Providing POS improves accuracy and speed
- Validation: Unlike native function,
morphy()validates against WordNet entries
Related
- Synsets - Query synsets (uses morphy internally)
- Porter Stemmer - Alternative rule-based stemming
- Loading - Load WordNet databases