-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
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
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