Bắt đầu ngayBắt đầu miễn phí

String operators with the Twitter data

You continue working with the tweets data where the text column stores the content of each tweet.

Your task is to turn the text column into a list of tokens. Then, using string operators, remove all non-alphabetic characters from the created list of tokens.

Bài tập này là một phần của khóa học

Sentiment Analysis in Python

Xem khóa học

Hướng dẫn bài tập

  • Import the word tokenizing function.
  • Create word tokens from each tweet.
  • Filter out all non-alphabetic characters from the created list, i.e. retain only letters.

Bài tập tương tác thực hành trực tiếp

Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.

# Import the word tokenizing package
____

# Tokenize the text column
word_tokens = [____(review) for review in tweets.text]
print('Original tokens: ', word_tokens[0])

# Filter out non-letter characters
cleaned_tokens = [[word for word in item if ____.____] for item in word_tokens]
print('Cleaned tokens: ', cleaned_tokens[0])
Chỉnh sửa và Chạy Mã