Filter final templates in analysis - #491
Draft
jtmaxwell3 wants to merge 6 commits into
Draft
Conversation
jtmaxwell3
marked this pull request as draft
August 28, 2026 20:54
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.
Hermit Crab tries all possible interleavings of templates and affix process rules during analysis even if the templates are final. This is expensive if there are a lot of final templates and affix process rules that could apply to a word. Sometimes it takes minutes or hours to parse a word because of this.
There is code in SynthesisAffixProcessRule.Apply that prevents derivational affixes from applying to final templates during synthesis, but it is skipped if the input’s root is partial:
The corresponding analysis code can’t filter final templates being unapplied after derivational affixes because it doesn’t know whether the root is partial yet. However, if nothing in the grammar is final then we can filter final templates if they are unapplied after a non-template affix. To support this, I added the properties Morpher.IsFinal, MorphemicMorphologicalRule.IsFinalTemplate and Word.IsLastUnappliedRuleNonTemplate. I also added AffixStateKey.IsLastUnappliedRuleNonTemplate.
This change is