我目前正在使用 python 中的 nltk 进行情绪分析项目。我无法让我的脚本从我的 csv 中传递文本行来执行标记化。但是,如果我一次在一个条目中传递文本,它就可以正常工作。当我尝试传入整个 csv 时,我收到一个持久性错误:'TypeError: expected string or bytes-like object'。这是我正在使用的打印数据框和 python 代码。解决此问题的任何帮助都会很棒。
abstract
0 Allergic diseases are often triggered by envir...
1 omal lymphopoietin (TSLP) has important roles ...
2 of atrial premature beats, and a TSLP was high...
3 deposition may play an important role in the ...
4 ted by TsPLP was higher than that mediated by ...
5 nal Stat5 transcription factor in that TSLP st...
data = pd.read_csv('text.csv', sep=';', encoding = 'utf-8')
x = data.loc[:, 'abstract']
print(x.head())
tokens = nltk.word_tokenize(x)
print(tokens)
附件是完整的堆栈跟踪错误。编辑:打印声明
编辑:输出