private static void senSegmentFile ( String infile , String outfile , JVnSenSegmenter senSegmenter ) { try { BufferedReader in = new BufferedReader ( new InputStreamReader ( new FileInputStream ( infile ) , "UTF-8" ) ) ; BufferedWriter out = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( outfile ) , "UTF-8" ) ) ; String para = "" , line = "" , text = "" ; while ( ( line = in . readLine ( ) ) != null ) { if ( ! line . equals ( "" ) ) { if ( line . charAt ( 0 ) == ' ' ) { //skip comment line text += line + "\n" ; continue ; } para = senSegmenter . senSegment ( line ) . trim ( ) ; text += para . trim ( ) + "\n\n" ; } else { //blank line text += "\n" ; } } text = text . trim ( ) ; out . write ( text ) ; out . newLine ( ) ; in . close ( ) ; out . close ( ) ; } catch ( Exception e ) { System . out . println ( "Error in sensegment file " + infile ) ; } }
Segment sentences .