我正在尝试运行以下代码但是出现语法错误。我看不出我对argsort做错了什么?我正在使用python 3。
def display_topics(H, W, feature_names, documents, no_top_words, no_top_documents):
for topic_idx, topic in enumerate(H):
print ("Topic %d:" % (topic_idx))
print (" ".join([feature_names[i]
for i in topic.argsort()[:-no_top_words - 1:-1]])
top_doc_indices = np.argsort(W[:,topic_idx])[::-1][0:no_top_documents]
for doc_index in top_doc_indices:
print (documents[doc_index])
我在指定的行上收到以下错误:
File "<ipython-input-42-1ad798bb95c3>", line 6
top_doc_indices = np.argsort(W[:,topic_idx]),[::-1],[0:no_top_documents]
^
SyntaxError: invalid syntax