public final ParserModel train ( final TrainingParameters params , final TrainingParameters taggerParams , final TrainingParameters chunkerParams ) { if ( getParserFactory ( ) == null ) { throw new IllegalStateException ( "The ParserFactory must be instantiated!!" ) ; } if ( getTaggerFactory ( ) == null ) { throw new IllegalStateException ( "The TaggerFactory must be instantiated!" ) ; } ParserModel trainedModel = null ; ParserEvaluator parserEvaluator = null ; try { trainedModel = ShiftReduceParser . train ( this . lang , this . trainSamples , this . rules , params , this . parserFactory , taggerParams , this . taggerFactory , chunkerParams , this . chunkerFactory ) ; final ShiftReduceParser parser = new ShiftReduceParser ( trainedModel ) ; parserEvaluator = new ParserEvaluator ( parser ) ; parserEvaluator . evaluate ( this . testSamples ) ; } catch ( final IOException e ) { System . err . println ( "IO error while loading training and test sets!" ) ; e . printStackTrace ( ) ; System . exit ( 1 ) ; } System . out . println ( "Final Result: \n" + parserEvaluator . getFMeasure ( ) ) ; return trainedModel ; }
Train a parser model from the Treebank data .