def generateTopic(self,method=TopicMethod.LDA,numTopics=10):
corpus=[self.dictionary.doc2bow(article.wordList) for article in Article.objects.only("wordList")]
if method==TopicMethod.LDA:
instance=ldamodel.LdaModel(corpus,id2word=self.dictionary,num_topics=numTopics)
elif method==TopicMethod.LSI:
instance=models.LsiModel(corpus,id2word=self.dictionary,num_topics=numTopics)
dstCorpus=instance[corpus]
return dstCorpus
评论列表
文章目录