

def ImportMalletLDA(app_name, model_path, corpus_path, database_path, is_quiet, force_overwrite):
    logger = logging.getLogger('termite')
    logger.addHandler(logging.StreamHandler())
    logger.setLevel((logging.INFO if is_quiet else logging.DEBUG))
    app_path = 'apps/{}'.format(app_name)
    corpus_filename = '{}/corpus.txt'.format(corpus_path)
    database_filename = '{}/corpus.db'.format(database_path)
    logger.info('--------------------------------------------------------------------------------')
    logger.info('Import an ITM topic model as a web2py application...')
    logger.info('           app_name = %s', app_name)
    logger.info('           app_path = %s', app_path)
    logger.info('         model_path = %s', model_path)
    logger.info('    corpus_filename = %s', corpus_filename)
    logger.info('  database_filename = %s', database_filename)
    logger.info('--------------------------------------------------------------------------------')
    if (force_overwrite or (not os.path.exists(app_path))):
        with CreateApp(app_name) as app:
            app_database_filename = '{}/corpus.db'.format(app.GetDatabasePath())
            app_corpus_filename = '{}/corpus.txt'.format(app.GetDataPath())
            app_sentences_filename = '{}/sentences.txt'.format(app.GetDataPath())
            logger.info('Copying [%s] --> [%s]', database_filename, app_database_filename)
            shutil.copy(database_filename, app_database_filename)
            logger.info('Copying [%s] --> [%s]', corpus_filename, app_corpus_filename)
            shutil.copy(corpus_filename, app_corpus_filename)
            logger.info('Extracting [%s] --> [%s]', corpus_filename, app_sentences_filename)
            SplitSentences(corpus_filename, app_sentences_filename)
            app_model_path = '{}/treetm'.format(app.GetDataPath())
            logger.info('Copying [%s] --> [%s]', model_path, app_model_path)
            shutil.copytree(model_path, database_filename)
            db_path = app.GetDatabasePath()
            with Corpus_DB(db_path) as corpus_db:
                with BOW_DB(db_path, isInit=True) as bow_db:
                    bow_computer = BOW_ComputeStats(bow_db, corpus_db, app_corpus_filename, app_sentences_filename)
                    bow_computer.Execute()
                with LDA_DB(db_path, isInit=True) as lda_db:
                    treetm_reader = TreeTMReader(lda_db, app_model_path)
                    treetm_reader.Execute()
                    lda_computer = LDA_ComputeStats(lda_db, corpus_db)
                    lda_computer.Execute()
                with ITM_DB(db_path, isInit=True) as itm_db:
                    itm_computer = ITM_ComputeStats(itm_db, corpus_db)
                    itm_computer.Execute()
    else:
        logger.info('    Already available: %s', app_path)

dataset/ETHPy150Open uwdata/termite-data-server/bin/read_treetm.py ImportMalletLDA/VarMisuse@306/619 `app_model_path`->`database_filename`