@Test public void testSplit() { System.out.println("split"); String text = "THE BIG RIPOFF\n\nMr. John B. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid far too much for it. Did he mind? Adam Jones Jr. thinks he didn't. In any case, this isn't true... Well, with a probability of .9 it isn't. "; String[] expResult = { "THE BIG RIPOFF\n\nMr.", "John B.", "Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid far too much for it.", "Did he mind?", "Adam Jones Jr. thinks he didn't.", "In any case, this isn't true...", "Well, with a probability of .9 it isn't." }; BreakIteratorSentenceSplitter instance = new BreakIteratorSentenceSplitter(); String[] result = instance.split(text); assertEquals(expResult.length, result.length); for (int i = 0; i < result.length; i++) assertEquals(expResult[i], result[i]); }
@Override public String[] split(String text) { boundary.setText(text); ArrayList<String> sentences = new ArrayList<>(); int start = boundary.first(); for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) { sentences.add(text.substring(start, end).trim()); } String[] array = new String[sentences.size()]; for (int i = 0; i < array.length; i++) { array[i] = sentences.get(i); } return array; }
BreakIteratorSentenceSplitter implements SentenceSplitter { @Override public String[] split(String text) { boundary.setText(text); ArrayList<String> sentences = new ArrayList<>(); int start = boundary.first(); for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) { sentences.add(text.substring(start, end).trim()); } String[] array = new String[sentences.size()]; for (int i = 0; i < array.length; i++) { array[i] = sentences.get(i); } return array; } }
BreakIteratorSentenceSplitter implements SentenceSplitter { @Override public String[] split(String text) { boundary.setText(text); ArrayList<String> sentences = new ArrayList<>(); int start = boundary.first(); for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) { sentences.add(text.substring(start, end).trim()); } String[] array = new String[sentences.size()]; for (int i = 0; i < array.length; i++) { array[i] = sentences.get(i); } return array; } BreakIteratorSentenceSplitter();  BreakIteratorSentenceSplitter(Locale locale); }
BreakIteratorSentenceSplitter implements SentenceSplitter { @Override public String[] split(String text) { boundary.setText(text); ArrayList<String> sentences = new ArrayList<>(); int start = boundary.first(); for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) { sentences.add(text.substring(start, end).trim()); } String[] array = new String[sentences.size()]; for (int i = 0; i < array.length; i++) { array[i] = sentences.get(i); } return array; } BreakIteratorSentenceSplitter();  BreakIteratorSentenceSplitter(Locale locale); @Override String[] split(String text); }
BreakIteratorSentenceSplitter implements SentenceSplitter { @Override public String[] split(String text) { boundary.setText(text); ArrayList<String> sentences = new ArrayList<>(); int start = boundary.first(); for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) { sentences.add(text.substring(start, end).trim()); } String[] array = new String[sentences.size()]; for (int i = 0; i < array.length; i++) { array[i] = sentences.get(i); } return array; } BreakIteratorSentenceSplitter();  BreakIteratorSentenceSplitter(Locale locale); @Override String[] split(String text);  }