SentenceSegmenter { public List<Sentence> splitPos(String text) { List<Sentence> sentences = new LinkedList<Sentence>(); for (Span s : sentenceDetector.sentPosDetect(text)) { sentences.add(new Sentence( text.substring(s.getStart(), s.getEnd()), s.getStart(), s .getEnd())); } return sentences; } SentenceSegmenter(); String[] split(String text); String[] split(Reader reader); List<Sentence> splitPos(String text); static void main(String[] args);  }
@Test public void testSplitPos() throws Exception { SentenceSegmenter segmenter = new SentenceSegmenter(); String text = "Diego Armando Maradona Franco is a former Argentine footballer. He has served as a manager and coach at other clubs as well as for the national team of Argentina. "; List<Sentence> sentences = segmenter.splitPos(text); System.out.println("text: "); System.out.println(text); System.out.println("sentences: "); int i = 0; for (Sentence s : sentences) { System.out.println(i + " ) " + s); i++; } int posSecondSentence = text.indexOf("He has"); System.out.println("pos: " + posSecondSentence); assertEquals(posSecondSentence, sentences.get(1).getStart()); }