Repository navigation
Wildcards stop before later elements, not only the next one (#427) (4.2.27) - #783
Merged
Merged
Conversation
….2.27)
With a wildcard pending, the matcher searched for an optional element past
the elements after it. In
the _xWILD _xWILD [opt match=(three)] _xWILD [one match=(bears)]
on "the big bears met three bears" the wildcard ran past the first "bears"
to reach "three". Now an optional element is absent if a later element (up to
and including the next required one) matches first, so the wildcard stops at
the first "bears". The optional element still wins a tie at the same node, a
bare wildcard among the later elements ends the look, and it works matching
leftward from a trigger too.
Interpreted: Pat::laterMatches, checked in matchRealRight/Left. Compiled:
Arun::later_matches (via stop_match) in match_left/right and
special_left/right. Same behaviour in both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #427.
Problem. While a wildcard was pending, the matcher searched for an optional element past the elements after it. In:
on "the big bears met three bears", the wildcard ran past the first "bears" to reach "three", and matched
big bears met. To get the intended match you had to repeat the later elements in a fail list:_xWILD [fail=(three bears)].Fix. An optional element is now absent if a later element matches first. "Later" means any element up to and including the next required one. So the wildcard stops at the first "bears" (
wild=big,threeabsent)._xWILDamong the later elements ends the look, because what it will cover isn't known yet.Pat::laterMatchesinmatchRealRight/Left. Compiled:Arun::later_matchesinmatch_left/rightandspecial_left/right, built on NLP++: Overly broad @PRE conditions fail #449'sstop_match, so it tests nodes exactly as the generated code does.On keeping
_xWILDvs. a new_xSMART(the issue suggested either). The change only affects one rule shape: a bare wildcard, then an optional element, then more elements. All 20 analyzers inanalyzers/(21 inputs, including parse-en-us) produce byte-identical output to 4.2.18, and so does the-DEVFull English Test. So this improves_xWILDitself.Testing
tests/smart-wildcard, with CI steps for Windows and Linux, covering the NLP++ multiple wildcards (enhancement) #427 case, an optional element that comes first, a tie, and leftward matching. 4.2.18 gives the old results for the NLP++ multiple wildcards (enhancement) #427 and leftward cases.🤖 Generated with Claude Code