public static void main ( String args [ ] ) { if ( args . length != 4 ) { displayHelp ( ) ; System . exit ( 1 ) ; } try { JVnSenSegmenter senSegmenter = new JVnSenSegmenter ( ) ; senSegmenter . init ( args [ 1 ] ) ; String option = args [ 2 ] ; if ( option . equalsIgnoreCase ( "-inputfile" ) ) { senSegmentFile ( args [ 3 ] , args [ 3 ] + ".sent" , senSegmenter ) ; } else if ( option . equalsIgnoreCase ( "-inputdir" ) ) { //segment only files ends with .txt File inputDir = new File ( args [ 3 ] ) ; File [ ] childrent = inputDir . listFiles ( new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { return name . endsWith ( ".txt" ) ; } } ) ; for ( int i = 0 ; i < childrent . length ; ++ i ) { System . out . println ( "Segmenting sentences in " + childrent [ i ] ) ; senSegmentFile ( childrent [ i ] . getPath ( ) , childrent [ i ] . getPath ( ) + ".sent" , senSegmenter ) ; } } else displayHelp ( ) ; } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; return ; } }
main method of JVnSenSegmenter to use this tool from command line .