Fix bug in MergeEquivalentAnalyses - #493
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
ddaspit
left a comment
There was a problem hiding this comment.
@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.
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