public synchronized List < Sentence > sentences ( String text ) { requireValidHandle ( ) ; Libvoikko lib = getLib ( ) ; List < Sentence > result = new ArrayList < Sentence > ( ) ; if ( ! isValidInput ( text ) ) { result . add ( new Sentence ( text , SentenceStartType . NONE ) ) ; return result ; } byte [ ] textBytes = s2n ( text ) ; int textLen = textBytes . length - 1 ; SizeTByReference sentenceLenByRef = new SizeTByReference ( ) ; while ( textLen > 0 ) { int sentenceTypeInt = lib . voikkoNextSentenceStartCstr ( handle , textBytes , new SizeT ( textLen ) , sentenceLenByRef ) ; int sentenceLen = sentenceLenByRef . getValue ( ) . intValue ( ) ; SentenceStartType sentenceType = SentenceStartType . values ( ) [ sentenceTypeInt ] ; String tokenText = text . substring ( 0 , sentenceLen ) ; result . add ( new Sentence ( tokenText , sentenceType ) ) ; text = text . substring ( sentenceLen ) ; textBytes = s2n ( text ) ; textLen = textBytes . length - 1 ; } return result ; }
Split the given natural language text into a list of Sentence objects .