文字前處理
在建立推薦系統或其他任何模型之前,必須先對文字做前處理。
這裡已載入一段福爾摩斯的文字。請用影片中介紹的各種技巧來前處理這段文字,為後續分析做好準備。
變數 text 節錄自 Arthur Conan Doyle 的 The Hound of the Baskervilles。
以下套件與函式已為你載入:
nltk、torch、get_tokenizer、PorterStemmer、stopwords。
本練習屬於課程
Deep Learning for Text with PyTorch
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Initialize and tokenize the text
tokenizer = ____("basic_english")
tokens = ____(____)
print(tokens)