Skip to content

LT-22140: Add constraining compound rules via productivity restrictions#312

Merged
ddaspit merged 7 commits intomasterfrom
LT22140
Jul 18, 2025
Merged

LT-22140: Add constraining compound rules via productivity restrictions#312
ddaspit merged 7 commits intomasterfrom
LT22140

Conversation

@AndyBlack
Copy link
Copy Markdown
Collaborator

@AndyBlack AndyBlack commented Jun 19, 2025

Added MprFeatureSets for head and nonhead portions of compound rules

Added tests to see if a head/nonhead portion of a compound rule requires one or more productivity restrictions that at least one of those restrictions is present in the head/nonhead.

When analyzing and tracing, if such a requirement failed, add a failure message about needed nonhead productivity restrictions.

When synthesizing and tracing, if such a requirement failed, add a failure message about needed head productivity restrictions.


This change is Reviewable

@Enkidu93 Enkidu93 requested a review from ddaspit June 19, 2025 21:14
Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 18 of 18 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ddaspit)


src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/CompoundingRule.cs line 45 at r1 (raw file):

        public FeatureStruct NonHeadRequiredSyntacticFeatureStruct { get; set; }

        public MprFeatureSet HeadProdRestrictionsMprFeatureSet { get; set; }

I would rename this to HeadProdRestrictionsMprFeatures, so that it is consistent with existing names.


src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/CompoundingRule.cs line 68 at r1 (raw file):

        }

        public bool CompoundMprFeaturesMatch(MprFeatureSet ruleMprFeatures, MprFeatureSet stemMprFeatures)

I would prefer that this method was moved to the MprFeatureSet class.


src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/CompoundingRule.cs line 70 at r1 (raw file):

        public bool CompoundMprFeaturesMatch(MprFeatureSet ruleMprFeatures, MprFeatureSet stemMprFeatures)
        {
            if (ruleMprFeatures.Count > 0)

This method could be simplified to

return ruleMprFeatures.Count == 0 || ruleMprFeatures.Intersect(stemMprFeatures).Any();

src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs line 84 at r1 (raw file):

                            if (_morpher.TraceManager.IsTracing)
                            {
                                var tempInput = new Word(allo, null);

Would the following be a more correct representation of the input word?

Word tempInput = outWord.Clone();
tempInput.CurrentNonHead.RootAllomorph = allo;

src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs line 86 at r1 (raw file):

                                var tempInput = new Word(allo, null);
                                tempInput.CurrentTrace = input.CurrentTrace;
                                _morpher.TraceManager.MorphologicalRuleNotApplied(

I don't think this is the correct trace entry type. Do we need a new trace entry type to represent this case?


Machine.sln line 51 at r1 (raw file):

	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Debug|x64 = Debug|x64

Is there some reason why you added a configuration specifically for x64? I don't think it should be necessary.

@AndyBlack
Copy link
Copy Markdown
Collaborator Author

Thank you for the suggestions. Very helpful.
I did not mean to make any changes to machine.sln so that was a mistake to include it in the commit. I'll reverse that.
On this comment
[src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs line 86 at r1 (raw file):

var tempInput = new Word(allo, null);
tempInput.CurrentTrace = input.CurrentTrace;
_morpher.TraceManager.MorphologicalRuleNotApplied(

I don't think this is the correct trace entry type. Do we need a new trace entry type to represent this case?

Well, CompoundingRule implements IMorphologicalRule, right? Do we need to make a distinction here?

Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add support for these new properties to the XML config file?

Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @AndyBlack)


src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs line 86 at r1 (raw file):

Previously, AndyBlack (Andy Black) wrote…
var tempInput = new Word(allo, null);
tempInput.CurrentTrace = input.CurrentTrace;
_morpher.TraceManager.MorphologicalRuleNotApplied(

I don't think this is the correct trace entry type. Do we need a new trace entry type to represent this case?

Well, CompoundingRule implements IMorphologicalRule, right? Do we need to make a distinction here?

You are correct, but this is actually rule unapplication, since it occurs during the analysis phase. Calling MorphologicalRuleNotUnapplied might be more appropriate, but that is already called at the end if the rule doesn't produce any outputs. The case you are trying to log here is a bit different. You want to log the case where the rule doesn't unapply for a specific nonhead allomorph, because it doesn't match the MPR features. The rule might still unapply in other cases for the same input. As a result, this feels like a special trace entry type that doesn't fit any of the existing types.

@AndyBlack
Copy link
Copy Markdown
Collaborator Author

Yes, we need to add these to the XML config. Good point.
Thanks for making the need for a compound rule-specific case clear.
I'll plan to work on these next week.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 25, 2025

Codecov Report

❌ Patch coverage is 52.74725% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.75%. Comparing base (4dac237) to head (eb168e1).
⚠️ Report is 60 commits behind head on master.

Files with missing lines Patch % Lines
.../SIL.Machine.Morphology.HermitCrab/TraceManager.cs 0.00% 20 Missing ⚠️
...Crab/MorphologicalRules/AnalysisCompoundingRule.cs 35.00% 12 Missing and 1 partial ⚠️
...rab/MorphologicalRules/SynthesisCompoundingRule.cs 28.57% 9 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #312      +/-   ##
==========================================
- Coverage   70.79%   70.75%   -0.05%     
==========================================
  Files         390      390              
  Lines       32715    32806      +91     
  Branches     4604     4612       +8     
==========================================
+ Hits        23162    23213      +51     
- Misses       8489     8527      +38     
- Partials     1064     1066       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndyBlack
Copy link
Copy Markdown
Collaborator Author

@ddaspit Damien, could you review these latest changes, please? Thanks.

@AndyBlack AndyBlack requested a review from ddaspit July 11, 2025 19:56
Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good. You still need to revert the changes to Machine.sln.

Reviewed 13 of 13 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @AndyBlack)


Machine.sln line 51 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

Is there some reason why you added a configuration specifically for x64? I don't think it should be necessary.

There still seems to be a bunch of extra configurations for other projects in the solution. Can you revert all of the changes in this file? Thanks.

Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 12 of 12 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @AndyBlack)

Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @AndyBlack)

@ddaspit ddaspit merged commit af3037a into master Jul 18, 2025
4 checks passed
@ddaspit ddaspit deleted the LT22140 branch July 18, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants