def write_topics(self, num_words=5, outfile=sys.stdout): """ Writes the topics to outfile. Parameters ---------- outfile : filepath or buffer Designates file to write to. num_words : int number of words to write with each topic """ with common.smart_open(outfile, 'w') as f: for t in xrange(self.num_topics): f.write('topic %s' % t + '\n') f.write(self.lda.print_topic(t, topn=num_words) + '\n')
def test_smart_open_2(self): with common.smart_open(StringIO(), "w") as f: self.assertTrue(isinstance(f, StringIO))
def test_smart_open_1(self): with common.smart_open(sys.stdout, "w") as f: self.assertTrue(isinstance(f, file))
def test_smart_open_2(self): with common.smart_open(StringIO(), 'w') as f: self.assertTrue(isinstance(f, StringIO))
def test_smart_open_1(self): with common.smart_open(sys.stdout, 'w') as f: self.assertTrue(isinstance(f, file))