Changeset 241

Show
Ignore:
Timestamp:
01/02/08 20:11:30 (1 year ago)
Author:
chris
Message:

Remove Cantillation Marks/Punctuation from Hebrew text
as requested by Nicolai.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lex/trunk/src/com/qwirx/lex/hebrew/HebrewConverter.java

    r236 r241  
    6767        for (int i = 0; i < input.length(); i++) 
    6868        { 
     69            String substr = input.substring(i); 
     70 
    6971            char c = input.charAt(i); 
    70             String substr = input.substring(i); 
    71  
    7272            char c2 = 0xffff; 
    7373            if (i < input.length() - 1) 
     
    9494            else if (c == 'A') { output.append("\u05b7"); } // Patah 
    9595            else if (c == 'B') { output.append("\u05d1"); } // Bet 
    96             else if (c == 'C') { output.append("\u05e9"); } // 05c1 // Shin, Shin Dot 
     96            else if (c == 'C') { output.append("\u05e9\u05c1"); } // Shin, Shin Dot 
    9797            else if (c == '#') { output.append("\u05e9"); } // S/hin with no dot 
    9898            else if (c == 'D') { output.append("\u05d3"); } // Dalet 
    9999            else if (c == 'E') { output.append("\u05b6"); } // Segol 
    100             else if (c == 'F') { output.append("\u05e9"); } // 05c2 // Shin, Sin Dot 
     100            else if (c == 'F') { output.append("\u05e9\u05c2"); } // Shin, Sin Dot 
    101101            else if (c == 'G') { output.append("\u05d2"); } // Gimel 
    102102            else if (c == 'H') { output.append("\u05d4"); } // He 
     
    126126 
    127127            // Cantillation Marks/Punctuation ala MC 
    128  
     128            // removed at Nicolai's request 2/1/08 
     129            /* 
    129130            else if (c == '0') 
    130131            { 
     
    171172            } 
    172173             
     174            else if (c == '5') 
     175            { 
     176                i++; 
     177                if      (c2 == '2') { output.append("\u05c4"); } // Puncta Extraordinaria above (not a revia!) 
     178                else if (c2 == '3') { output.append("\u0323"); } // Puncta Extraordinaria below; Ps 27:13 only 
     179                else { throw new IllegalArgumentException(substr); } 
     180            } 
     181 
    173182            else if (c == '6') 
    174183            { 
     
    216225                else if (c2 == '5') { output.append("\u05bd"); } // meteg, silluq (right) 
    217226                else { throw new IllegalArgumentException(substr); } 
     227            }*/ 
     228             
     229            else if (c >= '0' && c <= '9' && c2 >= '0' && c2 <= '9') 
     230            { 
     231                i++; // skip both 
    218232            } 
    219233             
     
    228242 
    229243            // Other 
    230  
    231             else if (c == '5') 
    232             { 
    233                 i++; 
    234                 if      (c2 == '2') { output.append("\u05c4"); } // Puncta Extraordinaria above (not a revia!) 
    235                 else if (c2 == '3') { output.append("\u0323"); } // Puncta Extraordinaria below; Ps 27:13 only 
    236                 else { throw new IllegalArgumentException(substr); } 
    237             } 
    238244 
    239245            else if (c == '*') { /* 0 */ } // asterisk indicates Qere/Ketiv 
     
    258264    public static String toTranslit(String input) 
    259265    { 
     266        input = input.toUpperCase().replaceAll("\\d\\d", ""); 
    260267        StringBuffer output = new StringBuffer(); 
    261268 
    262         input = input.replaceAll("\\d\\d", "").toUpperCase(); 
    263          
    264269        for (int i = 0; i < input.length(); i++) 
    265270        { 
    266271            String substr = input.substring(i); 
    267272            char c = input.charAt(i); 
    268              
     273            char c2 = 0xffff; 
     274            if (i < input.length() - 1) 
     275            { 
     276                c2 = input.charAt(i + 1); 
     277            } 
     278 
    269279            if (substr.matches("[BGDKPT]\\.[@AEIOUW;:].*")) 
    270280            { 
     
    272282                i++; // skip the dagesh (.) 
    273283            } 
    274             else if (substr.matches("[BCDFGJKLMNPQSTVWYZ]\\..*")) 
     284            else if (substr.matches("[BCDFGJKLMNPQSTVWYZ#]\\..*")) 
    275285            { 
    276286                if      (c == 'C') { output.append("šš"); } 
    277287                else if (c == 'F') { output.append("śś"); } 
     288                else if (c == '#') { output.append("ss"); } // ?? guess ?? 
    278289                else if (c == 'J') { output.append("yy"); } 
    279290                else if (c == 'V') { output.append("ťť"); } 
     
    297308            else if (c == 'F') { output.append("ś"); } 
    298309            else if (c == 'C') { output.append("Å¡"); } 
     310            else if (c == '#') { output.append("s"); } // ?? guess ?? 
    299311            else if (c == '@') { output.append("ā"); } 
    300312            else if (c == 'D' || c == 'G' || c == 'H' ||