Arrays gettinf错误';元组';对象没有属性';拆分';
我尝试使用lda获取主题。但是在这段代码中,当我尝试将具有类似单词的主题分组在一起时,我会遇到此错误。 对于l.split(“+”)中的t:Arrays gettinf错误';元组';对象没有属性';拆分';,arrays,python-3.x,list,lda,Arrays,Python 3.x,List,Lda,我尝试使用lda获取主题。但是在这段代码中,当我尝试将具有类似单词的主题分组在一起时,我会遇到此错误。 对于l.split(“+”)中的t: AttributeError:“tuple”对象没有属性“split”您只能拆分字符串 试一试 否则,不要使用元组 def generateTopics(corpus, dictionary): # Build LDA model using the above corpus lda = models.ldamodel.LdaModel(c
AttributeError:“tuple”对象没有属性“split”您只能拆分字符串 试一试 否则,不要使用元组
def generateTopics(corpus, dictionary):
# Build LDA model using the above corpus
lda = models.ldamodel.LdaModel(corpus, id2word=dictionary, num_topics=50)
corpus_lda = lda[corpus]
# Group topics with similar words together.
tops = set(lda.show_topics(50))
top_clusters = []
for l in tops:
top = []
for t in l.split(" + "):
top.append((t.split("*")[0], t.split("*")[1]))
top_clusters.append(top)
str(l).split(" + ")