home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / i18n / wdbktbl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  4.0 KB  |  94 lines

  1. /*
  2. *****************************************************************************************
  3. *                                                                                       *
  4. * COPYRIGHT:                                                                            *
  5. *   (C) Copyright Taligent, Inc.,  1997                                                 *
  6. *   (C) Copyright International Business Machines Corporation,  1997-1998                    *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.                  *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure             *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                              *
  10. *                                                                                       *
  11. *****************************************************************************************
  12. *
  13. * File WDBKTBL.CPP
  14. *
  15. * Modification History:
  16. *
  17. *   Date        Name        Description
  18. *   02/18/97    aliu        Converted from OpenClass.  Made statics const.
  19. *****************************************************************************************
  20. */
  21.  
  22. // *****************************************************************************
  23. // This file was generated from the java source file WordBreakTable.java
  24. // *****************************************************************************
  25.  
  26. #include "wdbktbl.h"
  27.  
  28. // *****************************************************************************
  29. // class WordBreakTable
  30. //
  31. // The word break table implements a state machine that leads to the next
  32. // transition state from the current one and is used by BreakIterator for 
  33. // character, word or sentence.  To better illustrate the use of transition
  34. // tables, the  following example shows a very simplified version of the 
  35. // word break table that deals with only kNB  (not a blank char) and kB
  36. // (a blank char) character categories. The state machine of the word break 
  37. // table would look like,
  38. //
  39. //    Diagram 1 : the state machine for kNB and kB
  40. //
  41. //                         kNB
  42. //                         ----
  43. //            kNB   +----+/    \
  44. //           ------>|SI+1|      |
  45. //          /       +----+<----/ 
  46. //    +----+         kB|          kNB     +-------+
  47. // 0->|stop|           V   -------------> |SI_stop|
  48. //    +----+\------>+----+/               +-------+
  49. //                  |SI+2|<----\
  50. //             kB   +----+      |
  51. //                        \----/
  52. //                          kB
  53. //
  54. //  Table 1 : flattened state table for Diagram 1
  55. //  ---------------------------------------------
  56. //  States       kB               kNB
  57. //    0         stop             stop
  58. //    1         SI+2             SI+1
  59. //    2         SI+2             SI_stop
  60. //
  61. // In the table, SI+n shows where the characters will be "marked" and led
  62. // to a different state if necessary.  For example, consider the string 
  63. // "This is a test.".
  64. // Iterating through the string shows the following,
  65. // (stop)->'T'(SI+1)->'h'(SI+1)->'i'(SI+1)->'s'(SI+1)->' '(SI+2)->i(SI_stop)
  66. // When a (SI_stop) is reached, we know that we have found a word break right 
  67. // after ' '.  
  68. //
  69. // The actual char, word and sentence break data is a lot more complicated 
  70. // than the above.  The character type showed here is only limited to kNB
  71. // and kB for ease of demonstration.  All the break tables are essentially
  72. // a flattened state table of their orginal state machine diagrams.
  73. //
  74. // *****************************************************************************
  75.  
  76. // -------------------------------------
  77.  
  78. WordBreakTable::WordBreakTable(int32_t cols, const WordBreakTable::Node data[], int32_t data_length)
  79.   : fData(data), fData_length(data_length), fCols(cols)
  80. {
  81. }
  82.  
  83. // -------------------------------------
  84.  
  85. const WordBreakTable::Node WordBreakTable::kMark_mask = (WordBreakTable::Node)0x80;
  86.  
  87. const WordBreakTable::Node WordBreakTable::kIndex_mask = (WordBreakTable::Node)0x7F;
  88.  
  89. const WordBreakTable::Node WordBreakTable::kInitial_state = 1;
  90.  
  91. const WordBreakTable::Node WordBreakTable::kEnd_state = 0;
  92.  
  93. //eof
  94.