词云wordcloud入门示例

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.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值