@@ -0,0 +1,1741 @@
+import logging%0Aimport glob%0Afrom multiprocessing import Process%0A%0Afrom CPTCorpus import CPTCorpus%0Afrom CPT_Gibbs import GibbsSampler%0A%0A%0Adef run_sampler(corpus, nTopics, nIter, beta, out_dir):%0A    sampler = GibbsSampler(corpus, nTopics=nTopics, nIter=nIter,%0A                           alpha=(50.0/n), beta=beta, beta_o=beta,%0A                           out_dir=out_dir.format(nTopics))%0A    sampler._initialize()%0A    sampler.run()%0A%0A%0Alogging.basicConfig(format='%25(levelname)s : %25(message)s', level=logging.INFO)%0Alogger = logging.getLogger(__name__)%0A%0Alogger.setLevel(logging.DEBUG)%0A#logger.setLevel(logging.INFO)%0A%0A#files = glob.glob('/home/jvdzwaan/data/tmp/dilipad/gov_opp/*')%0Afiles = glob.glob('/home/jvdzwaan/data/tmp/test/*')%0A%0Acorpus_dir = '/home/jvdzwaan/data/tmp/generated/test_exp/corpus'%0Aout_dir = '/home/jvdzwaan/data/tmp/generated/test_exp/%7B%7D'%0A#out_dir = '/home/jvdzwaan/data/tmp/dilipad/test_perplexity/'%0A%0Acorpus = CPTCorpus(files, testSplit=20)%0Acorpus.filter_dictionaries(minFreq=5, removeTopTF=100, removeTopDF=100)%0Acorpus.save_dictionaries(directory=out_dir.format(''))%0Acorpus.save(out_dir.format('corpus.json'))%0A%0A#corpus = CPTCorpus.CPTCorpus.load('%7B%7Dcorpus.json'.format(out_dir),%0A#                                  topicDict='%7B%7D/topicDict.dict'.format(out_dir),%0A#                                  opinionDict='%7B%7D/opinionDict.dict'.format(out_dir))%0A%0AnIter = 200%0Abeta = 0.02%0A%0AnTopics = range(20, 201, 20)%0Alogger.info('running Gibbs sampler for %7B%7D configurations'.format(len(nTopics)))%0A%0Aprocesses = %5BProcess(target=run_sampler,%0A                     args=(corpus, n, nIter, beta, out_dir))%0A             for n in nTopics%5D%0A%0A# Run processes%0Afor p in processes:%0A    p.start()%0A%0A# Exit the completed processes%0Afor p in processes:%0A    p.join()%0A

Add script to run a series of experiments