我正在使用twitter数据进行分析,但在分析之前,我想预处理数据。我试过nltk.word_tokenize(),但他们不删除标点符号,他们不理解san andreas和单个单词,但在推文中,有很多这样的单词。这是代码
def inital():
return 0
def get_vocab(lst):
vocab_count=defaultdict(inital)
i=0
for txt in lst:
if type(txt)!=float:
txt=txt.decode("utf8")
for words in nltk.word_tokenize(txt):
vocab_count[words]+=1
return vocab_count