开始使用免费开始使用

计算 Pink Floyd 歌曲的相似度

在这个最后的练习中,您将获得英国乐队 Pink Floyd 的三首歌的歌词,分别是 "High Hopes"、"Hey You" 和 "Mother"。这些歌词分别保存在 hopesheymother 中。

您的任务是计算 motherhopes、以及 motherhey 之间的两两相似度。

本练习是课程的一部分

Python 中的 NLP 特征工程

查看课程

练习说明

  • motherhopeshey 创建 Doc 对象。
  • 计算 motherhopes 的相似度。
  • 计算 motherhey 的相似度。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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.____(____))
编辑并运行代码