private static Iterator < String > splitIntoDocs ( Reader r ) { if ( TREAT_FILE_AS_ONE_DOCUMENT ) { return Collections . singleton ( IOUtils . slurpReader ( r ) ) . iterator ( ) ; } else { Collection < String > docs = new ArrayList < String > ( ) ; ObjectBank < String > ob = ObjectBank . getLineIterator ( r ) ; StringBuilder current = new StringBuilder ( ) ; for ( String line : ob ) { if ( docPattern . matcher ( line ) . lookingAt ( ) ) { // Start new doc, store old one if non-empty if ( current . length ( ) > 0 ) { docs . add ( current . toString ( ) ) ; current = new StringBuilder ( ) ; } } current . append ( line ) ; current . append ( ' ' ) ; } if ( current . length ( ) > 0 ) { docs . add ( current . toString ( ) ) ; } return docs . iterator ( ) ; } }
end class CoNLLIterator