計算 Pink Floyd 歌曲的相似度
在最後這個練習中,提供了英國樂團 Pink Floyd 的三首歌詞:'High Hopes'、'Hey You' 和 'Mother'。這些歌詞分別以 hopes、hey 和 mother 提供。
你的任務是計算 mother 與 hopes、以及 mother 與 hey 之間的成對相似度。
本練習屬於課程
Python 中文本特徵工程
練習說明
- 為
mother、hopes和hey建立Doc物件。 - 計算
mother與hopes之間的相似度。 - 計算
mother與hey之間的相似度。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create Doc objects
mother_doc = nlp(____)
hopes_doc = nlp(____)
hey_doc = nlp(hey)
# Print similarity between mother and hopes
print(mother_doc.____(hopes_doc))
# Print similarity between mother and hey
print(mother_doc.____(____))