Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2016294 | 1.2.0 | John Oconner | P3 | Resolved | Fixed | 1.2beta3 |
Name: bb33257 Date: 07/29/97
The following string:
aa.bb.
aa"bb"
aa'bb'
is broken by the word-break iterator (BreakIterator.
getWordInstance()) as follows:
aa.bb
.
aa"bb
"
aa'bb
'
This is probably correct for the apostrophe, but the other two
should probably break as follows:
aa
.
bb
.
aa
"
bb
"
======================================================================
The following app demonstrates the issue that a period at termination
of scentence is not handled properly. Internal periods are OK. Other
punctuation is OK (for example a '?' at the end).
import java.text.BreakIterator;
class WordBoundary {
// Creating and using text boundaries
public static void main(String args[]) {
String stringToExamine =
"Mr. Livingston, I presume.";
// print original text
System.out.println ("ORIGINAL TEXT:");
System.out.println(stringToExamine);
System.out.println("");
// print text with separators between words
BreakIterator wordBoundary = BreakIterator.getWordInstance();
wordBoundary.setText(stringToExamine);
System.out.println ("WITH WORD BOUNDARIES:");
printWithSeparators(wordBoundary, stringToExamine);
}
// Print a separator '|' at each boundary
public static void printWithSeparators(BreakIterator boundary, String source) {
int start = boundary.first();
int end = start;
while (end != BreakIterator.DONE) {
System.out.print(source.substring(start,end));
System.out.print('|');
start = end;
end = boundary.next();
}
System.out.println();
}
}
gregory.graham@Canada 1997-09-01
- backported by
-
JDK-2016294 Strange word breaking - word break not provided around period at end of string
-
- Resolved
-