首页 > 解决方案 > 机器学习:如何找到缺失的信息

问题描述

def process_text(title):
nopunc = [char for char in text if char not in string.punctuation]
nopunc = ''.join(nopunc)
clean_texts = [word for word in nopunc.split() if word.lower() not in stopwords.words('english']
return clean_texts

  File "<ipython-input-34-7ad84bab21d6>", line 3
    nopunc = [char for char in text if char not in string.punctuation]
         ^
IndentationError: expected an indented block

我是机器学习的新手,谁能告诉我是什么导致了这个问题

标签: python

解决方案


尝试这个。缩进是一种告诉 Python 解释器一系列语句属于特定代码块的方式,就像其他语言使用 {} 的方式一样。

def process_text(title):

    nopunc = [char for char in text if char not in string.punctuation]
    nopunc = ''.join(nopunc)
    clean_texts = [word for word in nopunc.split() if word.lower() not in 
        stopwords.words('english']

    return clean_texts

推荐阅读