Repository navigation
Stop synthesis trying affix allomorphs after the one analysis recorded - #560
johnml1135 wants to merge 1 commit into
Conversation
Analysis records which allomorph of each affix rule it unapplied, and synthesis only keeps output from that allomorph or an earlier one. Later allomorphs were still pattern-matched and built, then discarded. The loop in SynthesisAffixProcessRule.Apply now ends at the recorded allomorph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| recordedIndex = _rule.Allomorphs.IndexOf(recorded); | ||
| for (int i = 0; i < _rules.Count; i++) | ||
| { | ||
| if (recordedIndex >= 0 && i > recordedIndex) |
There was a problem hiding this comment.
FYI: F1. The cutoff and input.IsAllomorphApplicable(allo) (line 205) now decide the same thing, each reading _allomorphApps[_mruleAppIndex] separately. If IsAllomorphApplicable is later loosened (e.g. to accept free-fluctuation variants), the break silently drops output it would allow. Consider deriving one from the other, e.g. recordedIndex < 0 || i == recordedIndex at line 205.
Public API, target framework, package, machine.py parity: None verified. Findings: F1 new. Reviewed at f902cf8 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #560 +/- ##
==========================================
+ Coverage 74.57% 74.78% +0.21%
==========================================
Files 453 453
Lines 38342 38348 +6
Branches 5284 5287 +3
==========================================
+ Hits 28593 28679 +86
+ Misses 8583 8511 -72
+ Partials 1166 1158 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Quick summary
Synthesis now stops trying an affix rule's allomorphs once it passes the one analysis recorded. Parses are identical on every corpus measured; only work whose output was always discarded is removed. No public API changes. Only
SynthesisAffixProcessRule.Applyand an internalWordaccessor change.Where to look
AffixProcessRuleTestspin the cutoff and the earlier-allomorph cases.NotApplied/pattern entries for allomorphs after the recorded one, since they are no longer tried.Deliberately not included
Validation
dotnet test tests/SIL.Machine.Morphology.HermitCrab.Tests -c Release-- master 151 passed; branch 154 passed, 0 faileddotnet csharpier check .andpwsh scripts/comment-hygiene.ps1-- clean./local_check.sh --agent-strictnot run end to endIssue / porting context
Research: #490 (experiment E1).
Soundness argument
An output from allomorph
i > rfailsIsAllomorphApplicableand was never added.appliedAllomorphIndicesis copied into each output when it is built (UnionWithinWord.MorphologicalRuleApplied), so indices added afterrnever reachr's output. Allomorphsi <= rrun exactly as before, so the disjunctivebreakand the recorded indices are unchanged. With no recorded allomorph (null, or not in the list),recordedIndexstays -1 and the loop is untouched. Compounding and realizational rules do not use recorded allomorphs and are left alone. The new tests also check that the last allomorph recorded still applies and that an earlier environment-free allomorph still blocks later ones. With thebreakdisabled, two of the three fail.Measured effect (steps, never time)
Synthesis steps with the cutoff off and on, same words in both arms. "Total work" is analysis events plus synthesis steps. Analysis events and candidate counts were equal in both arms on every corpus, and the parse output was identical per word.
Synthesis is a small share of total work on real grammars (1.0% on Aweti, 9.0% on Mbugwe), so the real-grammar saving in total work is small. The gain is largest where an affix has a long list of environment-conditioned allomorphs (Turkic suffix sets, Bantu class prefixes). An environment-free allomorph already ends the loop; environment-bearing ones never did, so every one was applied. Each rule application cost
Aallomorph applications and now costsr + 1.Cost not in the step counters: one
IndexOfover the rule's allomorphs per rule application, at mostAreference comparisons.Pre-existing failures (not on master)
The full HermitCrab test project has no failures on this branch or on
origin/master(c245476). Failures seen in the research branch's runs came from the research branch, not this change:truncate-morphotactic*conformance fixtures (nondeterministic, fail without the cutoff) andFieldworksProducibilityLedgerTests(missingAllomorphNotApplicable, a merge interaction of #480 with #548). Neither exists on master.🤖 Generated with Claude Code
This change is