步骤 1:词云与特征创建
在整个练习中,您将使用 reviews 数据集的一个样本。它包含 review 和 score 两列。欢迎在 IPython Shell 中自行探索。
第一步,您将仅使用正向评价来构建词云。字符串 positive_reviews 已为您创建,它是由前 100 条正向评价拼接而成。
第二步,您将为每条评价创建一个新的长度特征,并把该特征添加到数据集中。
用于绘制词云的所有函数,以及来自 nltk 模块的 word_tokenize 函数,都已为您导入。
本练习是课程的一部分
Python 中的情感分析
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create and generate a word cloud image
cloud_positives = ____(background_color='white').____(positive_reviews)
# Display the generated wordcloud image
plt.___(cloud_positives, interpolation='bilinear')
plt.axis("off")
# Don't forget to show the final image
plt.show()