Skip to content

Fix bug in MergeEquivalentAnalyses - #493

Open
jtmaxwell3 wants to merge 1 commit into
masterfrom
fix-merge-equivalent-analyses
Open

Fix bug in MergeEquivalentAnalyses#493
jtmaxwell3 wants to merge 1 commit into
masterfrom
fix-merge-equivalent-analyses

Conversation

@jtmaxwell3

@jtmaxwell3 jtmaxwell3 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Comparing MergeEquivalentAnalyses to John Lambert's memoization code, I noticed that it was not computing equivalence correctly. So I borrowed AnalysisStateKey from the memoization code to fix the problem.


This change is Reviewable

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.51%. Comparing base (d734722) to head (4562502).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #493   +/-   ##
=======================================
  Coverage   73.51%   73.51%           
=======================================
  Files         451      451           
  Lines       37692    37692           
  Branches     5183     5183           
=======================================
  Hits        27708    27708           
  Misses       8845     8845           
  Partials     1139     1139           

☔ View full report in Codecov by Harness.
📢 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.

@ddaspit ddaspit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ddaspit reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on jtmaxwell3).


src/SIL.Machine.Morphology.HermitCrab/AnalysisStratumRule.cs line 155 at r1 (raw file):

                if (mergeEquivalentAnalyses)
                {
                    var key = AnalysisStateKey.PinAndKey(mruleOutWord);

wordCache and output don't agree on identity. Word.ValueEquals ignores SyntacticFeatureStruct, which the key includes. So analyses differing only in SyntacticFeatureStruct now get distinct keys, skip the merge, and are then dropped by output.Add.

Also, wordCache[key] = mruleOutWord runs before output.Add accepts it, so a rejected word stays canonical and swallows every later word with that key.

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