<s> import argparse <EOL> import json <EOL> import logging <EOL> import os <EOL> from modellers . TreeTM import BuildLDA , RefineLDA , InspectLDA <EOL> def TrainTreeTM ( corpus_path , model_path , token_regex , num_topics , num_iters , is_quiet , force_overwrite , resume_training , inspect_only ) : <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> logger . addHandler ( logging . StreamHandler ( ) ) <EOL> logger . setLevel ( logging . INFO if is_quiet else logging . DEBUG ) <EOL> corpus_filename = '<STR_LIT>' . format ( corpus_path ) <EOL> if force_overwrite or not os . path . exists ( model_path ) : <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' , corpus_filename ) <EOL> logger . info ( '<STR_LIT>' , model_path ) <EOL> logger . info ( '<STR_LIT>' , token_regex ) <EOL> logger . info ( '<STR_LIT>' , num_topics ) <EOL> logger . info ( '<STR_LIT>' , num_iters ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> BuildLDA ( corpus_filename , model_path , tokenRegex = token_regex , numTopics = num_topics , numIters = num_iters ) <EOL> else : <EOL> if inspect_only : <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' , model_path ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> reader = InspectLDA ( model_path ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( reader . EntryID ( ) ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( reader . Iters ( ) ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( json . dumps ( reader . MustLinks ( ) , encoding = '<STR_LIT:utf-8>' , indent = <NUM_LIT:2> ) ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( json . dumps ( reader . CannotLinks ( ) , encoding = '<STR_LIT:utf-8>' , indent = <NUM_LIT:2> ) ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( json . dumps ( reader . KeepTerms ( ) , encoding = '<STR_LIT:utf-8>' , indent = <NUM_LIT:2> ) ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( json . dumps ( reader . RemoveTerms ( ) , encoding = '<STR_LIT:utf-8>' , indent = <NUM_LIT:2> ) ) <EOL> elif resume_training : <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' , model_path ) <EOL> logger . info ( '<STR_LIT>' , num_iters ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> RefineLDA ( model_path , numIters = num_iters ) <EOL> else : <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' ) <EOL> logger . info ( '<STR_LIT>' , model_path ) <EOL> def main ( ) : <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , type = str , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , type = str , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , type = str , default = r'<STR_LIT>' , help = '<STR_LIT>' , dest = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , type = int , default = <NUM_LIT:20> , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , type = int , default = <NUM_LIT:1000> , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , const = True , default = False , help = '<STR_LIT>' , action = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , const = True , default = False , help = '<STR_LIT>' , action = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , const = True , default = False , help = '<STR_LIT>' , action = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , const = True , default = False , help = '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> TrainTreeTM ( args . corpus_path , args . model_path , args . token_regex , args . topics , args . iters , args . quiet , args . overwrite , args . resume , args . read_only ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
