我正在跟踪有关使用anaconda的深度学习的教程: https://www.youtube.com/watch?v=ICL7VRKvS_A&list=PLzMcBGfZo4-ndH9FoC4YWHGXG5RZekt-Q&index=4
它抱怨的那一行:(根据michotross的建议编辑)
words = [stemmer.stem(w.lower()) for w in words if w != "?" and w is not None]
显示的错误是:
Traceback (most recent call last):
File "C:/Users/HP X360/PycharmProjects/Mach_Lrn/bot.py", line 30, in <module>
words = [stemmer.stem(w.lower()) for w in words if w != "?" and w is not None]
File "C:/Users/HP X360/PycharmProjects/Mach_Lrn/bot.py", line 30, in <listcomp>
words = [stemmer.stem(w.lower()) for w in words if w != "?" and w is not None]
TypeError: stem() missing 1 required positional argument: 'word'
我对编码还很陌生,有点谷歌,但是我已经复制了视频中使用的教程中的文本,因此正在寻求一些帮助,这将是不胜感激的:)
安娜x
答案 0 :(得分:0)
将其更改为此:
words = [stemmer.stem(w.lower()) for w in words if w.lower() != "?" and w.lower() is not None]
如果您想查看传递给stemmer.stem的内容,请从列表理解转换为常规循环:
stemmed_words = []
for w in words:
try:
stemmed_words.append(stemmer.stem(w.lower()))
except:
print('WORD ->', w.lower(), '<-')
答案 1 :(得分:0)
已解决-是先前代码中的错字。