Repository navigation
Extend MergeEquivalentAnalyses to cover templates and rules - #569
jtmaxwell3 wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #569 +/- ##
==========================================
- Coverage 74.93% 74.89% -0.05%
==========================================
Files 454 454
Lines 38490 38554 +64
Branches 5322 5332 +10
==========================================
+ Hits 28843 28875 +32
- Misses 8495 8524 +29
- Partials 1152 1155 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| } | ||
| } | ||
|
|
||
| private IEnumerable<Word> ApplyTemplatesAndRules(Word input) |
There was a problem hiding this comment.
Minor: F6. No tests cover the new analysis path: the diff touches nothing under tests/. ApplyTemplatesAndRules, PopUnapplied, the ExpandAlternatives rewrite, and the compounding Source fix all change analysis output, and AGENTS.md asks for a focused test with each behavior change. At minimum, check that unordered parses give the same results with merging on and off, including a compound and a repeated affix.
There was a problem hiding this comment.
F6 still applies at 6d69bd1: the rewrite changes the merge path again (per-rule FilterResults, Source chains kept in merge mode, output taken from wordCache.Values), and nothing under tests/ changed. A focused test should check that parses match with merging on and off, for linear and unordered strata.
There was a problem hiding this comment.
F6 still applies at 275ca01: this push changes the merge path again (MaxAlternatives counted in FilterResults, an early syntactic-feature rejection in LexicalLookup, cached ExpandAlternatives), and the PR still changes nothing under tests/. A focused test should check that parses match with merging on and off, for Linear and Unordered strata.
There was a problem hiding this comment.
F6 still applies at 836df6f: this push changes the merge path again (duplicates are now dropped inside the cascades when merging is off, and ExpandAlternatives deduplicates by value), and the PR still changes nothing under tests/. A focused test should check that parses match with merging on and off, for Linear and Unordered strata.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Verdict: approve with fixes. Most important: F6 ( Counts: Critical 0, Important 1 open (F6), Low 0 open. Ran: Could not verify: I traced, but did not run, the claim that deduplicating inside the cascades with merging off loses no analysis. Public API, target framework, package, machine.py parity: unchanged since 6d69bd1. Findings: F1 addressed; F2 addressed; F3 addressed; F4 addressed; F5 addressed; F6 open; F7 addressed; F8 addressed; F9 addressed; F10 addressed; F11 addressed. Reviewed at 836df6f |
johnml1135
left a comment
There was a problem hiding this comment.
The approach holds up on grammars FieldWorks can produce, and the HermitCrab tests pass (176/176). Before it lands:
- Tests: merging is on by default and no test compares parse sets with
MergeEquivalentAnalysestrue vs false (Linear and Unordered strata, templates, compounding). PopUnappliedhas no callers, so itsExpandAlternativesbranch never runs (inline)._expandedAlternativeskeeps a set alive on every word in theSourcechain (inline).RuleCascade.Apply(TData)is no longer virtual (inline).- The
LexicalLookupsyntactic-feature pre-filter (Morpher.cs:450) is a separate change that also appears in #583 and #627. Please describe it here or leave it to #627.
| // Special case. | ||
| alternatives.Add(this); | ||
| } | ||
| else if (Source.MorphologicalRuleUnapplicationCount > MorphologicalRuleUnapplicationCount) |
There was a problem hiding this comment.
This branch needs PopUnapplied (line 359), which has no callers, so it never runs. If it did, it would drop the word's root, non-heads and realizational changes. Please remove both.
| private int _mruleAppCount = 0; | ||
| private readonly IList<Word> _alternatives = new List<Word>(); | ||
| private readonly ConcurrentBag<Word> _alternatives = new ConcurrentBag<Word>(); | ||
| private HashSet<Word> _expandedAlternatives = null; |
There was a problem hiding this comment.
This caches a set on every word in the Source chain, and returned parses keep the chain alive. Can it be computed per call, or shown to stay small?
| } | ||
|
|
||
| public abstract IEnumerable<TData> Apply(TData input); | ||
| public IEnumerable<TData> Apply(TData input) |
There was a problem hiding this comment.
Apply(TData) is no longer virtual, a breaking change for subclasses outside SIL.Machine. Keep it virtual, or note it in the release.
|
Originally, this pull request sped parsing up. But after the edge prefilter code was added, it slowed parsing down. |
This extends MergeEquivalentAnalyses to merge the results of individual templates and rules, not just the results of a stratum. If the templates and rules always produce a subset of the input during unapplication, then analysis should be polynomial in the length of the input instead of exponential, although readout for synthesis will still be exponential.
This change is