fix: add is_base_form to FrenchLemmatizer to prevent over-lemmatizing infinitives#13965
Open
RudrenduPaul wants to merge 1 commit intoexplosion:masterfrom
Open
fix: add is_base_form to FrenchLemmatizer to prevent over-lemmatizing infinitives#13965RudrenduPaul wants to merge 1 commit intoexplosion:masterfrom
RudrenduPaul wants to merge 1 commit intoexplosion:masterfrom
Conversation
… infinitives French infinitives ending in -dre, -re, etc. (e.g. 'descendre', 'prendre') were incorrectly lemmatized to 'descendrer', 'prendrer' because suffix rules like 'e -> er' were applied to them after no match was found in the lookup tables. Fix: add is_base_form() to FrenchLemmatizer that returns True when the token morphology has VerbForm=Inf, and add a call to it at the top of rule_lemmatize (mirroring the parent Lemmatizer.rule_lemmatize pattern and the EnglishLemmatizer implementation). Infinitives are returned as-is without suffix rule application. Fixes explosion#7320 Built by Rudrendu Paul, developed with Claude Code
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.
Description
Fixes #7320
French infinitives ending in
-dre,-reetc. (e.g.descendre,prendre) were incorrectly lemmatized todescendrer,prendrerbecause suffix rules likee → erwere applied to them after no match was found in the lookup tables.Root cause:
FrenchLemmatizer.rule_lemmatizefully overrides the parent class method and does not callis_base_formbefore applying suffix rules. The parentLemmatizer.rule_lemmatizechecksis_base_formbefore the rules loop (line 190), but the French override skips that.Fix:
is_base_form()toFrenchLemmatizer— returnsTruewhenVerbForm=Infin the token's morphology (same pattern asEnglishLemmatizer)self.is_base_form(token)at the top ofFrenchLemmatizer.rule_lemmatize(after the space/eol early return), mirroring the parent class patternFrench infinitives are now returned as-is (lowercased) without suffix rule application.
Types of change
Checklist