Fix C runtime parser: register all case-variant sequences in lookahead - #205
Open
martingercke wants to merge 1 commit into
Open
Fix C runtime parser: register all case-variant sequences in lookahead#205martingercke wants to merge 1 commit into
martingercke wants to merge 1 commit into
Conversation
pgf_parsing_lookahead is a 'find all prefixes' binary search over concr->sequences that assumes a strict total order: on an exact match it registers exactly one sequence in state->lexicon_idx and recurses with length bounds that exclude any other sequence of the same length. With case-insensitive matching, a capitalized lexical sequence and its lowercase twin (e.g. "Schule"/"schule" in the German WordNet grammar) compare equal and sit adjacently - a tie. Only one of the twins got registered, decided by array-index parity. Lemmas indexed on the unregistered twin were never predicted, making those words unparseable (e.g. parse -cat=N "Schule"/"Brot"/"Stadt" failed with 'Unexpected token' although lookupMorpho finds them), while others (Birne, Haus) worked by luck. Fix: on an exact match, register the entire contiguous run of sequences that are equal under the comparator, then recurse strictly outside that run. No behavior change for unambiguous matches; lookupMorpho and linearization are untouched. Fixes GrammaticalFramework#204
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.
Fixes #204.
pgf_parsing_lookaheadregistered only one sequence per exact match. With case-insensitive matching, capitalized/lowercase twin sequences (e.g."Schule"/"schule"in the German WordNet grammar) compare equal, so only one of them enteredstate->lexicon_idx— decided by array-index parity. Lemmas indexed on the unregistered twin were unparseable (Schule,Brot,Stadt, … fail with "Unexpected token" althoughlookupMorphofinds them).This patch registers the entire contiguous run of comparator-equal sequences on an exact match (left/right scans via a small helper) and recurses strictly outside that run.
lookupMorphoand linearization untouched.1c086bed2(unmodified build before/after) with the German WordNet grammar compiled by the master-branch compiler: all affected words parse correctly after the fix; a regression battery (Food example grammar, German sentences, morphology lookups) is unchanged.