计算 Pink Floyd 歌曲的相似度
在这个最后的练习中,您将获得英国乐队 Pink Floyd 的三首歌的歌词,分别是 "High Hopes"、"Hey You" 和 "Mother"。这些歌词分别保存在 hopes、hey 和 mother 中。
您的任务是计算 mother 与 hopes、以及 mother 与 hey 之间的两两相似度。
本练习是课程的一部分
Python 中的 NLP 特征工程
练习说明
- 为
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.____(____))