6.3.0 Bidi implementation snag

From: Loren Brichter <loren.brichter_at_gmail.com>
Date: Fri, 18 Oct 2013 12:08:55 -0400

I'm finishing up an implementation of the 6.3.0 Bidi algorithm and hit a snag: currently passing all tests but one.

After much careful re-re-reading of the spec, I can't quite figure out where this thing is going wrong and would really appreciate some advice, or perhaps someone who knows that this test case is in fact incorrect (unlikely as that may be).

The particular test case is this:
0661 0009 0028 0662 0029;2;0;2 0 1 2 1;0 1 4 3 2
(line 184 of BidiCharacterTest.txt)

The "correct" levels are [2 0 1 2 1], however, this implementation resolved the levels to be [2 1 1 2 1]. A single incorrect level for the Segment Separator at index 1.

Below is a trace of the algorithm (apologies if this is not visible on your end in a monospaced font, it is much more readable that way). In stage [N1] the S at index 1 becomes R. This seems correct to me because the previous character at index 0 is AN (interpreted as R according to the spec) and the following character at index 2 is an R. Both preceding and following characters are the same direction, so the S becomes an R as well.

At stage [Resolving_Implicit_Levels], the R (previously S) at index 1 has an even level (0), so its level is increased by one (0->1). I'm not entirely sure why the test has the level staying at 0, unless I missed something else completely unrelated to these two stages mentioned.

Any advice would be greatly appreciated, thanks very much!

Loren

---
TRACE:
[Initializaton+The_Paragraph_Level]
       pe: 0
    index:    0    1    2    3    4 
character: 0661 0009 0028 0662 0029 
 matching:    -    -    -    -    - 
bidiclass:   AN    S   ON   AN   ON 
embedding:    0    0    0    0    0 
[Explicit_Levels_and_Directions]
 matching:    -    -    -    -    - 
bidiclass:   AN    S   ON   AN   ON 
embedding:    0    0    0    0    0 
[Preparations_for_Implicit_Processing]
 matching:    -    -    -    -    - 
bidiclass:   AN    S   ON   AN   ON 
embedding:    0    0    0    0    0 
[Resolving_Weak_Types]
 matching:    -    -    -    -    - 
bidiclass:   AN    S   ON   AN   ON 
embedding:    0    0    0    0    0 
[N0]
 matching:    -    -    4    -    - 
bidiclass:   AN    S    R   AN    R 
embedding:    0    0    0    0    0 
[N1]
 matching:    -    -    4    -    - 
bidiclass:   AN    R    R   AN    R 
embedding:    0    0    0    0    0 
[N2]
 matching:    -    -    4    -    - 
bidiclass:   AN    R    R   AN    R 
embedding:    0    0    0    0    0 
[Resolving_Neutral_and_Isolate_Formatting_Types]
 matching:    -    -    4    -    - 
bidiclass:   AN    R    R   AN    R 
embedding:    0    0    0    0    0 
[Resolving_Implicit_Levels]
 matching:    -    -    4    -    - 
bidiclass:   AN    R    R   AN    R 
embedding:    2    1    1    2    1 
Received on Fri Oct 18 2013 - 12:18:57 CDT

This archive was generated by hypermail 2.2.0 : Fri Oct 18 2013 - 12:18:58 CDT