public final ParserModel train ( final TrainingParameters params , final InputStream taggerModel , final TrainingParameters chunkerParams ) { if ( getParserFactory ( ) == null ) { throw new IllegalStateException ( "The ParserFactory must be instantiated!!" ) ; } SequenceLabelerModel posModel = null ; try { posModel = new SequenceLabelerModel ( taggerModel ) ; } catch ( final IOException e1 ) { e1 . printStackTrace ( ) ; } ParserModel trainedModel = null ; ParserEvaluator parserEvaluator = null ; try { trainedModel = ShiftReduceParser . train ( this . lang , this . trainSamples , this . rules , params , this . parserFactory , posModel , 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 providing an already trained POS tagger .