示例#1
0
    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')
示例#2
0
    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')
示例#3
0
 def test_smart_open_2(self):
     with common.smart_open(StringIO(), "w") as f:
         self.assertTrue(isinstance(f, StringIO))
示例#4
0
 def test_smart_open_1(self):
     with common.smart_open(sys.stdout, "w") as f:
         self.assertTrue(isinstance(f, file))
示例#5
0
 def test_smart_open_2(self):
     with common.smart_open(StringIO(), 'w') as f:
         self.assertTrue(isinstance(f, StringIO))
示例#6
0
 def test_smart_open_1(self):
     with common.smart_open(sys.stdout, 'w') as f:
         self.assertTrue(isinstance(f, file))