Canopy Express에서 GENSIM 토픽 모델링 예제를 실행하고 Sum() 행에서 다음 오류를 얻으려고합니다.Canopy Express의 GENSIM 오류
from gensim import corpora, models, similarities
from itertools import chain
""" DEMO """
documents = ["Human machine interface for lab abc computer applications",
"A survey of user opinion of computer system response time",
"The EPS user interface management system",
"System and human system engineering testing of EPS",
"Relation of user perceived response time to error measurement",
"The generation of random binary unordered trees",
"The intersection graph of paths in trees",
"Graph minors IV Widths of trees and well quasi ordering",
"Graph minors A survey"]
# remove common words and tokenize
stoplist = set('for a of the and to in'.split())
texts = [[word for word in document.lower().split() if word not in stoplist]
for document in documents]
# remove words that appear only once
all_tokens = sum(texts, [])
tokens_once = set(word for word in set(all_tokens) if all_tokens.count(word) == 1)
texts = [[word for word in text if word not in tokens_once] for text in texts]
오류는 TypeError입니다. 정수가 필요합니다. 일반 파이썬에서는 괜찮아 보이지만 Canopy에는 문제가 있습니다. Canopy가 sum 문을 처리하는 방법 인 것 같습니다. 그러나 나는 그 문제를 해결하는 방법을 모르겠습니다. 어떤 아이디어라도 파이썬과 텍스트 분석으로 시작하고 있습니다.
감사합니다. 이것은 내가 초보자이며 패키지를 배우려고 노력할 때 많은 도움이됩니다. 나는 합계 성명서를 가리키는 유사한 질문을 보았지만 그것을 해결하는 방법을 상세히 설명하지는 않았다. 귀하의 대답은 그것을 제공합니다. 다시 감사합니다. – user3890455