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
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 解释器一系列语句属于特定代码块的方式,就像其他语言使用 {} 的方式一样。
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
推荐阅读
- lua - 将特定文件分配给脚本中的任何团队
- python - 遍历目录/子目录的目录,仅打印子目录名称
- javascript - 为什么在给定线性三次贝塞尔曲线时 p5.js bezierPoint() 函数会返回非线性值?
- php - 无法删除数据 laravel 8
- c# - ViewModel 中 Reference 对象的所有 ID 为 0 而 Post 方法
- javascript - 如何在javascript中检索家谱中嵌套子节点的每个节点?
- excel - Excel 唯一排名公式的反例 - 知道如何解决吗?
- python - Python替换双引号读取文件
- io - 将所有输出重定向到 Julia 中的文件
- php - SQLSTATE[HY093]: Invalid parameter number: 参数未定义,XAMPP 和 MySql