def print_top_words_per_topic(data, top_n=10, do_print=True):
 msgs = []
 lists = []
 for (j, topic_to_word) in enumerate(data['topic_term_dists']):
  top = np.argsort(topic_to_word)[::(-1)][:top_n]
  prefix = ('Top words in topic %i ' % j)
  top_words = [data['vocab'][i].strip().replace(' ', '_') for i in top]
  msg = ' '.join(top_words)
  if do_print:
   print (prefix + msg)
  lists.append(top_words)
 return lists

def print_top_words_per_topic ( data , top_n = 10 , do_print = True ) : msgs = [ ] lists = [ ] for ( j , topic_to_word ) in enumerate ( data [ 'topic_term_dists' ] ) : top = np . argsort ( topic_to_word ) [ : : ( - 1 ) ] [ : top_n ] prefix = ( 'Top words in topic %i ' % j ) top_words = [ data [ 'vocab' ] [ i ] . strip ( ) . replace ( ' ' , '_' ) for i in top ] msg = ' ' . join ( top_words ) if do_print : print ( prefix + msg ) lists . append ( top_words ) return lists
given a pyldavis data array .