指定 token 規則
在這個練習中,你會使用 tweets 資料集的 text 欄位。你的任務是用 CountVectorizer 將這個物件欄位向量化。你會在向量化器中套用不同的 token 規則。記住:透過指定 token 規則,你可以過濾掉特定字元。
CountVectorizer 已為你匯入。
本練習屬於課程
Python 情感分析
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Build and fit the vectorizer
vect = ____(____=r'\b[^\d\W][^\d\W]+\b').fit(tweets.text)
vect.transform(tweets.text)
print('Length of vectorizer: ', len(vect.get_feature_names()))