def main():
  parser = argparse.ArgumentParser()  
  parser.add_argument('dataName', type=str,
        help='name of python script that produces data to analyze.')
  parser.add_argument('allocModelName', type=str,
        help='name of allocation model. {MixModel, DPMixModel}')
  parser.add_argument('obsModelName', type=str,
        help='name of observation model. {Gauss, ZMGauss}')
  parser.add_argument('algName', type=str,
        help='name of learning algorithms to consider, {EM, VB, moVB, soVB}.')
  parser.add_argument('--jobname', type=str, default='defaultjob',
        help='name of experiment whose results should be plotted')
  parser.add_argument('--topW', type=int, default=10,
        help='the number of top words printed for a given topic')        
  parser.add_argument('--taskids', type=str, default=None,
        help="int ids for tasks (individual runs) of the given job to plot." + \
              'Ex: "1" or "3" or "1,2,3" or "1-6"')
  parser.add_argument('--savefilename', type=str, default=None,
        help="absolute path to directory to save figure")
  parser.add_argument('--iterid', type=int, default=None)
  args = parser.parse_args()


  rootpath = os.path.join(os.environ['BNPYOUTDIR'], args.dataName, \
                              args.allocModelName, args.obsModelName)
  jobpath = os.path.join(rootpath, args.algName, args.jobname)

  if not os.path.exists(jobpath):
    raise ValueError("No such path: %s" % (jobpath))
  
  taskids = PlotELBO.parse_task_ids(jobpath, args.taskids)

  Data = loadData(jobpath)

  if args.savefilename is not None and len(taskids) > 0:
    try:
      args.savefilename % ('1')
    except __HOLE__:
      raise ValueError("Missing or bad format string in savefilename %s" %  
                        (args.savefilename)
                      )
     
  for taskid in taskids:
    taskpath = os.path.join(jobpath, taskid)
    if args.iterid is None:
      prefix = "Best"
    else:
      prefix = "Iter%05d" % (args.iterid)
    hmodel = bnpy.ioutil.ModelReader.load_model(taskpath, prefix)
    # Print top words across all topics
    learnedK = hmodel.allocModel.K
    savefid = taskpath + "/top_words.txt"
    fid = open(savefid,'w+')
    for k in xrange(learnedK):
        lamvec = hmodel.obsModel.comp[k].lamvec
        elamvec = lamvec / lamvec.sum()
        topW_ind = np.argsort(elamvec)[-args.topW:]
        for w in xrange(args.topW):
            word = str(Data.vocab_dict[topW_ind[w]])
            fid.write( word + ", " )
        fid.write("...\n")
    fid.close()
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/viz/PrintTopics.py/main