【发布时间】:2018-07-18 13:32:50
【问题描述】:
我正在尝试对废弃推文的 csv 文件进行标记。我将 csv 文件作为列表上传
with open('recent_tweet_purex.csv', 'r') as purex:
reader_purex = csv.reader(purex)
purex_list = list(reader_purex)
现在推文在列表中
["b'I miss having someone to talk to all night..'"], ["b'Pergunte-me
qualquer coisa'"], ["b'RT @Caracolinhos13: Tenho a
tl cheia dessa merda de quem vos visitou nas \\xc3\\xbaltimas horas'"],
["b'RT @B24pt: #CarlosHadADream'"], ['b\'"Tudo tem
um fim"\''], ["b'RT @thechgama: stalkear as curtidas \\xc3\\xa9 um caminho
sem volta'"], ["b'Como consegues fumar 3 purexs seguidas? \\xe2\\x80\\x94
Eram 2 purex e mix...'"]
我已经导入了 nltk 以及以下软件包
from nltk.tokenize import word_tokenize
import string
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import sent_tokenize
nltk.download('punkt')
我尝试过使用
purex_words = word_tokenize(purex_words)
to to tokenize 但我不断收到错误
有什么帮助吗?
【问题讨论】:
-
如果您告诉我们您遇到的错误将会更有帮助。
-
你应该展平列表。
-
NameError Traceback (最近一次调用最后一次)
in () ----> 1 purex_words = word.tokenize(purex_list) NameError: name 'word ' 未定义 -
@user9270834 错误说您调用的是
word.tokenize而不是word_tokenize。您有语法错误。将点 (.) 更改为下划线 (_)。 -
哦等等,我搞砸了解释我是怎么搞砸的