Change Add to PriorityUnion - #494
Draft
jtmaxwell3 wants to merge 1 commit into
Draft
Conversation
jtmaxwell3
marked this pull request as draft
September 4, 2026 15:37
ddaspit
requested changes
Sep 4, 2026
ddaspit
left a comment
Contributor
There was a problem hiding this comment.
It would be great if you could add a unit test to capture scenario you laid out.
@ddaspit reviewed 1 file and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on jtmaxwell3).
src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisAffixProcessRule.cs line 59 at r1 (raw file):
{ if (!_rule.RequiredSyntacticFeatureStruct.IsEmpty) outWord.SyntacticFeatureStruct.PriorityUnion(_rule.RequiredSyntacticFeatureStruct);
This change should also apply to compounding rules as well.
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.
I fixed a performance bug by changing AnalysisAffixProcessRule.Apply to use PriorityUnion instead of Add. Add acts like Union, PriorityUnion is more restrictive. Also, SynthesisAffixProcessRule uses PriorityUnion instead of Add in the other direction, so this makes AnalysisAffixProcessRule more parallel to SynthesisAffixProcessRule.
If I have a sequence of derivation rules that change the category like [CAT:A] => [CAT:B], [CAT:B] => [CAT:A], followed by [CAT:B] => [CAT:C], then the syntactic feature structure of the input of the third rule will be [CAT:{A, B}] if I use Add, and the third rule will not be filtered when it checks whether the input can unify with [CAT:B]. If I use PriorityUnion, then the syntactic feature structure of the input of the third rule will be [CAT:A], and the third rule will be filtered when it checks whether the input can unify with [CAT:B].
This performance bug only shows up when there are at least three derivational affixes. But words that are slow to parse try many long sequences of derivational affixes. Filtering these long sequences can make a big difference.
This change is