Python 官方文档:入门教程 => 点击学习
目录一、特效预览二、程序原理三、程序源码什么是 词云 词云 其实就是就是对网络文本中出现频率较高的〝关键词〞予以视觉上的突出,形成〝关键词云层〞或〝关键词
什么是 词云
词云 其实就是就是对网络文本中出现频率较高的〝关键词〞予以视觉上的突出,形成〝关键词云层〞或〝关键词渲染〞从而过滤掉大量的文本信息
词云 也是数据可视化的一种形式。给出一段文本,根据关键词的出现频率而生成的一幅图像,人们只要扫一眼就能够明白其文章主旨。
词云图:
你学废了嘛
#!/usr/bin/env python
# encoding: utf-8
import jieba
import numpy as np
import PIL.Image as Image
from Wordcloud import WordCloud
class wordCloud:
'''
This is a main Class, the file contains all documents.
One document contains paragraphs that have several sentences
It loads the original file and converts the original file to new content
Then the new content will be saved by this class
'''
def __init__(self):
self.bg_img = 'assets/picture.jpeg'
self.word_path = 'assets/word.txt'
def hello(self):
'''
This is a welcome speech
:return: self
'''
print('*' * 50)
print(' ' * 20 + '词云制作')
print(' ' * 5 + 'Author: autofelix Date: 2022-01-17 13:14')
print('*' * 50)
return self
def run(self):
'''
The program entry
'''
with open(self.word_path, 'r') as f:
word = f.read()
cut_word = ' '.join(jieba.cut(word))
color_mask = np.array(Image.open(self.bg_img))
word_cloud = WordCloud(
# 设置字体,不指定就会出现乱码
font_path='/System/Library/Fonts/PingFang.ttc',
# 设置背景色
background_color='white',
# 词云形状
mask=color_mask,
# 允许最大词汇
max_words=120,
# 最大号字体
max_font_size=2000
).generate(cut_word)
word_cloud.to_file('word_cloud.jpg')
im = word_cloud.to_image()
im.show()
if __name__ == '__main__':
wordCloud().hello().run()
到此这篇关于利用Python 制作词云特效详情的文章就介绍到这了,更多相关python 制作词云特效内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: 利用python 制作词云特效详情
本文链接: https://www.lsjlt.com/news/144931.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模
0