Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4111338

Method BreakIterator.getSentenceInstance() has a problem in zh.

XMLWordPrintable

    • 1.2beta4
    • sparc
    • solaris_2.6
    • Not verified

      JDK Version:1.2beta3-F, 1.1.6D
      Locale: zh
      Platform: Sun Ultra1
      OS: Solaris 2.6

      Under some conditions, BreakIterator.getSentenceInstance() has a problem in zh.
      For instance, if a sentence has a separator as ", and between two ", we have
      Chinese words and uper case of English letter, the method BreakIterator.getSentenceInstance() can not work correctly.
      Following is the test program.
      ===============================t10.java=======================================
      import java.util.*;
      import java.text.*;

      public class t10 {
      public static void main(String args[]) {
      new t10();
      }

      public t10() {
              BreakIterator boundary = BreakIterator.getSentenceInstance();
      String s = "…ñÊÁ¢þ‚‡‘˜“ÈñÐÈ:\"JAVAË´ÐÈÁŽƒ÷¤Í,¢½‡ßʲã­Ê‡ƒíÝˆž©´³\".";
      s = s + "\n" + "…ñÊÁ¢þ‚‡‘˜“ÈñÐÈú†í€JAVAË´ÐÈÁŽƒ÷¤Íú¼¢½‡ßʲã­Ê‡ƒíÝˆž©´³ííú";
      s = s + "\n" + "…ñÊÁ¢þ‚‡‘˜“ÈñÐÈú†í€“µÎJAVAË´ÐÈÁŽƒ÷¤Íú¼¢½‡ßʲã­Ê‡ƒíÝˆž©´³ííú";
      s = s + "\n" + "He said, \"I can go there.\"";
      boundary.setText(s);
      String result = "";
              try {
                  int start = boundary.first();
                  int end;
      int i = 1;
                  for (end = boundary.next(); end != BreakIterator.DONE;
                      start = end, end = boundary.next()) {
      result = result + "Sentence " + i + " is: ";
                      result = result + s.substring(start, end) + "\n";
      i ++;
                  }
              } catch (Exception ex) {
                  result = "not passed";
              }
              
      System.out.println("");
              System.out.println("Test method BreakIterator.getSentenceInstance():");
              System.out.println("Input text is:");
      System.out.println(s);
      System.out.println("");
      System.out.println("Output sentences are:");
      System.out.println(result);
      }
      }
      ================================================================================
      java t10

      Test method BreakIterator.getSentenceInstance():
      Input text is:
      9$R5=g2;IYHKT$QT:"JAVASoQT5D3vOV,=+;aR}FpR;3!Hm<~8oC|".
      9$R5=g2;IYHKT$QT#:!0JAVASoQT5D3vOV#,=+;aR}FpR;3!Hm<~8oC|!1!#
      9$R5=g2;IYHKT$QT#:!0KfWEJAVASoQT5D3vOV#,=+;aR}FpR;3!Hm<~8oC|!1!#
      He said, "I can go there."

      Output sentences are:
      Sentence 1 is: 9$R5=g2;IYHKT$QT:"JAVA
      Sentence 2 is: SoQT5D3vOV,=+;aR}FpR;3!Hm<~8oC|".

      Sentence 3 is: 9$R5=g2;IYHKT$QT#:!0JAVA
      Sentence 4 is: SoQT5D3vOV#,=+;aR}FpR;3!Hm<~8oC|!1!#

      Sentence 5 is: 9$R5=g2;IYHKT$QT#:!0KfWEJAVA
      Sentence 6 is: SoQT5D3vOV#,=+;aR}FpR;3!Hm<~8oC|!1!#

      Sentence 7 is: He said, "I can go there."



      jim.hu@prc 1998-02-11

            rgillamsunw Richard Gillam (Inactive)
            jhusunw Jim Hu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: