Python:
#导入所需库
from wordcloud import WordCloud
f = open(r'text.txt','r').read()
wordcloud = WordCloud(background_color="white",width=1000, height=860, margin=2).generate(f)
# width,height,margin可以设置图片属性
# generate 可以对全部文本进行自动分词,但是对中文支持不好
# 可以设置font_path参数来设置字体集
#background_color参数为设置背景颜色,默认颜色为黑色
import matplotlib.pyplot as plt
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
wordcloud.to_file('test.png')
# 保存图片,但是在第三模块的例子中 图片大小将会按照 mask 保存
text.txt:
The e-tailing giant's engineers are quietly testing scanners that can identify an individual human hand as a way to ring up a store purchase, with the goal of rolling them out at its Whole Foods supermarket chain in the coming months, The Post has learned.
Employees at Amazon's New York offices are serving as guinea pigs for the biometric technology, using it at a handful of vending1 machines to buy such items as sodas2, chips, granola bars and phone chargers, according to sources briefed on the plans.
The high-tech3 sensors4 are different from fingerprint5 scanners found on devices like the iPhone and don't require users to physically6 touch their hands to the scanning surface.
Instead, they use computer vision and depth geometry to process and identify the shape and size of each hand they scan before charging a credit card on file.
The system, code-named "Orville," will allow customers with Amazon Prime accounts to scan their hands at the store and link them to their credit or debit7 card.