递归到NLTK脚本的迭代转换

时间:2018-05-03 18:53:05

标签: python nltk

我想将代码转换为迭代代码,因为即使使用passby递归限制我也有递归错误

ps = PorterStemmer()
train_text = train["comment_text"]

train_corpus = []
for i in range(0, len(train_text)):
    data = re.sub("[^a-zA-Z]", ' ', train_text[i]).lower().split()
    data = [ps.stem(word) for word in data if not word in set(stopwords.words("english"))]
    data = ' '.join(data)
    train_corpus.append(data)

0 个答案:

没有答案