Я пытаюсь запустить пример моделирования GENSIM в Canopy Express и получить следующую ошибку в строке Sum().Ошибка GENSIM в Canopy Express
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: требуется целое число. Кажется, это нормально в обычном Python, но у Canopy есть проблема. Кажется, что Canopy рассматривает заявление о сумме, но я не уверен, как его обойти. Любые идеи, поскольку я только начинаю с Python и текстового анализа.
Спасибо. Это очень помогает, поскольку я новичок и просто пытаюсь изучить пакет. Я видел аналогичный вопрос, который указывал на выражение суммы, но не уточнил, как его решить. Ваш ответ предусматривает это. Еще раз спасибо. – user3890455