Repository navigation
Simplify the two P2 scans and read original_type in both - #22
Merged
Merged
Conversation
Same simplification as the P2 scan in determine_paragraph_embedding_level: _resolve_fsi_direction now tests STRONG_TYPES once and returns LRI for L, RLI for R or AL, in place of two separate branches. Co-Authored-By: Claude <noreply@anthropic.com>
P2 looks at each character's Bidi_Class from the Unicode data. The scan in determine_paragraph_embedding_level read character_type, which only holds that value because no rule has run yet. It now reads original_type, like the same P2 scan in _resolve_fsi_direction (X5c), so it no longer depends on when it is called. Results are unchanged. Co-Authored-By: Claude <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.
Summary
Two small cleanups to the two P2 scans: the paragraph-level scan in
determine_paragraph_embedding_level(P2) and the scan after an FSI in_resolve_fsi_direction(X5c applies P2 to the text after the FSI). Results and output are unchanged.Changes
STRONG_TYPESonce in the FSI scan. This is the same simplification Name the first strong character in the Phase P verbose trace #21 made to the paragraph scan. The loop testsSTRONG_TYPESonce and then returnsLRIfor L andRLIfor R or AL. It used to test R/AL and L in two separate branches. The('R', 'AL')literal no longer appears inbidi.py.original_typein the paragraph scan. P2 looks at each character's Bidi_Class from the Unicode data. The scan readcharacter_type, which holds that value only because no rule has run yet. It now readsoriginal_type, as the FSI scan already did, so it no longer depends on when it is called. The verbose P2 line prints the same field.No docs changes are needed, since the verbose output is the same.
Testing
python tests/run_bidi_tests.py: 91,707 passed, 0 failedpython tests/run_bidi_type_tests.py: 770,241 passed, 0 failed🤖 Generated with Claude Code