<s> import argparse , os . path <EOL> import nltk . data <EOL> from nltk_trainer import dump_object <EOL> from nltk_trainer . classification import multi <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , nargs = '<STR_LIT:+>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT:filename>' , default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , default = <NUM_LIT:1> , type = int , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , nargs = '<STR_LIT:+>' , default = [ ] , <EOL> help = '''<STR_LIT>''' ) <EOL> args = parser . parse_args ( ) <EOL> classifiers = [ ] <EOL> for name in args . classifiers : <EOL> if args . trace : <EOL> print '<STR_LIT>' % name <EOL> classifiers . append ( nltk . data . load ( name ) ) <EOL> combined = multi . AvgProbClassifier ( classifiers ) <EOL> labels = combined . labels ( ) <EOL> label_classifiers = { } <EOL> for h in args . hierarchy : <EOL> label , path = h . split ( '<STR_LIT::>' ) <EOL> if label not in labels : <EOL> raise ValueError ( '<STR_LIT>' % ( label , labels ) ) <EOL> label_classifiers [ label ] = nltk . data . load ( path ) <EOL> if args . trace : <EOL> print '<STR_LIT>' % ( label , label_classifiers [ label ] , path ) <EOL> if label_classifiers : <EOL> if args . trace : <EOL> '<STR_LIT>' % ( len ( label_classifiers ) , combined ) <EOL> combined = multi . HierarchicalClassifier ( combined , label_classifiers ) <EOL> fname = os . path . expanduser ( args . filename ) <EOL> dump_object ( combined , fname , trace = args . trace ) </s>
