当前位置: 首页 > news >正文

免费网站申请企业网站建设多少钱

免费网站申请,企业网站建设多少钱,个体户核名查询系统,做游戏直播什么游戏视频网站好一、基本功能 1.采取上传文本文档(仅支持.txt格式)的方式统计词频 2.背景图形样式可选择已经设定好的,也可选择本地上传的(支持.png .jpg .jpeg格式) 3.本地上传的图片需要进行抠图处理,并将抠图结果保存…

一、基本功能

在这里插入图片描述

1.采取上传文本文档(仅支持.txt格式)的方式统计词频

2.背景图形样式可选择已经设定好的,也可选择本地上传的(支持.png .jpg .jpeg格式)

3.本地上传的图片需要进行抠图处理,并将抠图结果保存到本地

4.背景图形颜色可通过调节RGB值和十六进制颜色值的方式进行设置

5.绘制好的词云图可供预览,并且可保存到本地

二、python程序

import re
import io
import jieba
import rembg
import numpy as np
import pandas as pd
import tkinter as tk
from tkinter.filedialog import *
from tkinter.ttk import *
from PIL import Image
from wordcloud import WordCloud
from wordcloud import ImageColorGenerator
from matplotlib import pyplot as plt
from matplotlib import patches as mp
from matplotlib.path import Path
from matplotlib.backends.backend_tkagg import FigureCanvasTkAggdef openfile():global file_path, path1file_path = askopenfilename(title='打开文本文档:', filetypes=[('Text Files', '*.txt')])path1.set(file_path)print(path1.get())return path1def openbackground():global background_path, path2background_path = askopenfilename(title='打开图片文件:', filetypes=[('Picture Files', '*.png *.jpg *.jpeg')])path2.set(background_path)print(path2.get())return path2def input_own_bg():button_bg.config(state=tk.NORMAL)def input_basic_graphic_bg():button_bg.config(state=tk.DISABLED)def input_rgb():combobox_r.config(state=tk.NORMAL)combobox_g.config(state=tk.NORMAL)combobox_b.config(state=tk.NORMAL)entry3.config(state=tk.DISABLED)def input_hex():combobox_r.config(state=tk.DISABLED)combobox_g.config(state=tk.DISABLED)combobox_b.config(state=tk.DISABLED)entry3.config(state=tk.NORMAL)def background():if choice_color.get() == 1:hex_r = hex(r.get())[2:].upper()hex_g = hex(g.get())[2:].upper()hex_b = hex(b.get())[2:].upper()hex_r0 = hex_r.zfill(2)hex_g0 = hex_g.zfill(2)hex_b0 = hex_b.zfill(2)hexcolor = '#' + hex_r0 + hex_g0 + hex_b0else:hexcolor = '#' + hex_color.get()plt.close(fig=None)fig_bg = plt.figure(figsize=(5, 5))ax = fig_bg.add_subplot(111, facecolor='white')if choice_shape.get() == 1:  # 心形t = np.arange(-3, 3, 0.1)x = 18 * np.power(np.sin(t), 3)y = 16 * np.cos(t) - 4 * np.cos(2 * t) - 3 * np.cos(3 * t) - np.cos(4 * t)shape = plt.fill(x, y, hexcolor)[0]ax.add_patch(shape)plt.axis('equal')plt.axis('off')elif choice_shape.get() == 2:  # 矩形shape = mp.Rectangle(xy=(0.1, 0.2), width=0.8, height=0.6, color=hexcolor)ax.add_patch(shape)plt.axis('off')elif choice_shape.get() == 3:  # 正方形shape = mp.Rectangle(xy=(0, 0), width=1, height=1, color=hexcolor)ax.add_patch(shape)plt.axis('off')elif choice_shape.get() == 4:  # 圆形shape = mp.Circle(xy=(0.5, 0.5), radius=0.5, alpha=0.8, color=hexcolor)ax.add_patch(shape)plt.axis('off')elif choice_shape.get() == 5:  # 五角星verts = []for i in [0, 3, 1, 4, 2, 0]:verts.append((np.sin(2 * np.pi / 5 * i), np.cos(2 * np.pi / 5 * i)))codes = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]path = Path(verts, codes)shape = mp.PathPatch(path, facecolor=hexcolor, lw=0, alpha=1)ax.add_patch(shape)plt.axis('equal')plt.axis('off')else:  # 自导入return background_pathbuffer = io.BytesIO()# if hexcolor=='#FFFFFF':#     fig_bg.patch.set_facecolor('black')canvas_bg = fig_bg.canvascanvas_bg.print_png(buffer)data = buffer.getvalue()buffer.write(data)plt.close(fig=None)return bufferdef check(event):if path1.get() and len(hex_color.get()) == 6:button_draw.config(state=tk.NORMAL, fg='green')else:button_draw.config(state=tk.DISABLED, fg='red')def check_hex(hex_input):hex_characters = '0123456789abcdefABCDEF'if len(hex_input) <= 6 and all(char in hex_characters for char in hex_input):return Trueelse:return Falsedef wordcloud():global button_savetext = pd.read_csv(file_path, index_col=0, encoding='utf-8', sep='\t')text2 = str(text)text3 = re.sub("[a-zA-Z0-9'!""#$%&\'()*+,-./:;<=>?@,。?★、…【】《》:?“”‘'![\\]^_`{|}~\s]+", "", text2)text4 = jieba.lcut(text3)text5 = ' '.join(text4)stop_words = set()content = [line.strip() for line in open('stopwords.txt', 'r', encoding='utf-8').readlines()]stop_words.update(content)font = r'C:\Windows\Fonts\simhei.ttf'img = Image.open(background())img_remove = rembg.remove(img, alpha_matting=True, bgcolor=(255, 255, 255, 1))img_remove.save('background_remove.png')MASK = np.array(img_remove)img_col = ImageColorGenerator(MASK)plt.close(fig=None)fig = plt.figure(figsize=(5, 2.5))plt.subplot(121)wordcloud = WordCloud(background_color='white', scale=2, max_words=500, max_font_size=50, min_font_size=1, font_path=font, stopwords=stop_words, mask=MASK, mode='RGB').generate_from_text(text5)plt.imshow(wordcloud.recolor(color_func=img_col), alpha=1)plt.axis('off')plt.subplot(122)plt.imshow(img)plt.axis('off')plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)plt.margins(0, 0)canvas = FigureCanvasTkAgg(figure=fig, master=windows)canvas.draw()canvas.get_tk_widget().grid(row=4, column=0, rowspan=1, columnspan=8, padx=0, pady=15)button_save = tk.Button(windows, text='保存词云图', command=show)button_save.grid(row=5, column=0, rowspan=1, columnspan=8)def show():plt.show()button_save.config(state=tk.DISABLED)if __name__ == '__main__':windows = tk.Tk()windows.geometry('550x450+500+200')windows.resizable(width=False, height=False)windows.title('词云图')windows.iconbitmap('image.ico')path1 = tk.StringVar()tk.Label(windows, text='文件路径:').grid(row=0, column=0, pady=5, padx=2)entry1 = tk.Entry(windows, textvariable=path1, width=50, state=tk.DISABLED)entry1.grid(row=0, column=1, rowspan=1, columnspan=6, pady=5)tk.Button(windows, text='打开文件', command=openfile, fg='green', width=9).grid(row=0, column=7, pady=5, padx=2)choice_shape = tk.IntVar()choice_shape.set(1)tk.Label(windows, text='图形样式:').grid(row=1, column=0, padx=2)button_bg = tk.Button(windows, text='打开文件', command=openbackground, fg='green', width=9, state=tk.DISABLED)button_bg.grid(row=1, column=7, padx=2)path2 = tk.StringVar()entry2 = tk.Entry(windows, textvariable=path2, width=50, state=tk.DISABLED)entry2.grid(row=1, column=1, rowspan=1, columnspan=6)tk.Radiobutton(windows, text='心形', value=1, variable=choice_shape, justify=tk.LEFT, command=input_basic_graphic_bg).grid(row=2, column=1)tk.Radiobutton(windows, text='矩形', value=2, variable=choice_shape, justify=tk.LEFT, command=input_basic_graphic_bg).grid(row=2, column=2)tk.Radiobutton(windows, text='正方形', value=3, variable=choice_shape, justify=tk.LEFT, command=input_basic_graphic_bg).grid(row=2, column=3)tk.Radiobutton(windows, text='圆形', value=4, variable=choice_shape, justify=tk.LEFT, command=input_basic_graphic_bg).grid(row=2, column=4)tk.Radiobutton(windows, text='五角星', value=5, variable=choice_shape, justify=tk.LEFT, command=input_basic_graphic_bg).grid(row=2, column=5)tk.Radiobutton(windows, text='自导入', value=6, variable=choice_shape, justify=tk.LEFT, command=input_own_bg).grid(row=2, column=6)choice_color = tk.IntVar()choice_color.set(1)tk.Label(windows, text='图形颜色:').grid(row=3, column=0, padx=5)tk.Radiobutton(windows, text='RGB:', value=1, variable=choice_color, justify=tk.LEFT, width=5, command=input_rgb, state=tk.NORMAL).grid(row=3, column=1)r = tk.IntVar()combobox_r = Combobox(windows, textvariable=r, width=3)combobox_r['value'] = tuple(range(256))combobox_r.set(0)combobox_r.grid(row=3, column=2)g = tk.IntVar()combobox_g = Combobox(windows, textvariable=g, width=3)combobox_g['value'] = tuple(range(256))combobox_g.set(0)combobox_g.grid(row=3, column=3)b = tk.IntVar()combobox_b = Combobox(windows, textvariable=b, width=3)combobox_b['value'] = tuple(range(256))combobox_b.set(0)combobox_b.grid(row=3, column=4)tk.Radiobutton(windows, text='十六进制:#', value=2, variable=choice_color, justify=tk.LEFT, width=8, command=input_hex).grid(row=3, column=5)hex_color = tk.StringVar()entry3 = tk.Entry(windows, textvariable=hex_color, validate='key', validatecommand=(windows.register(check_hex), '%P'), width=7, state=tk.DISABLED)hex_color.set('000000')entry3.grid(row=3, column=6)button_draw = tk.Button(windows, text='绘制词云图', command=wordcloud, fg='red', width=9, height=2, state=tk.DISABLED)button_draw.bind('<Motion>', check)button_draw.grid(row=2, column=7, rowspan=2, columnspan=1, padx=2)windows.mainloop()

三、效果展示

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

python通过tkinter制作词云图工具

四、源代码下载(含虚拟环境)

在这里插入图片描述
词云图工具下载链接:
https://url86.ctfile.com/f/32005086-932012628-2a8f6b?p=5422
访问密码:5422


文章转载自:
http://semisomnus.qnzk.cn
http://extortion.qnzk.cn
http://knock.qnzk.cn
http://zebeck.qnzk.cn
http://epibenthos.qnzk.cn
http://workshop.qnzk.cn
http://untomb.qnzk.cn
http://shut.qnzk.cn
http://wingover.qnzk.cn
http://lanital.qnzk.cn
http://readmitance.qnzk.cn
http://thermometric.qnzk.cn
http://whippy.qnzk.cn
http://hydroxylase.qnzk.cn
http://unmated.qnzk.cn
http://cyclopedist.qnzk.cn
http://northeastern.qnzk.cn
http://mangily.qnzk.cn
http://epsom.qnzk.cn
http://yakut.qnzk.cn
http://snowstorm.qnzk.cn
http://axon.qnzk.cn
http://chevrolet.qnzk.cn
http://diverticular.qnzk.cn
http://resonate.qnzk.cn
http://paramorphine.qnzk.cn
http://bullroarer.qnzk.cn
http://dyslogy.qnzk.cn
http://defrayment.qnzk.cn
http://associational.qnzk.cn
http://scraper.qnzk.cn
http://absonant.qnzk.cn
http://backslidden.qnzk.cn
http://summary.qnzk.cn
http://overdosage.qnzk.cn
http://sexily.qnzk.cn
http://durmast.qnzk.cn
http://graduand.qnzk.cn
http://inspirational.qnzk.cn
http://predecessor.qnzk.cn
http://violist.qnzk.cn
http://legist.qnzk.cn
http://scoleces.qnzk.cn
http://miscarry.qnzk.cn
http://ultraliberal.qnzk.cn
http://employer.qnzk.cn
http://picocurie.qnzk.cn
http://heraklion.qnzk.cn
http://misplug.qnzk.cn
http://artificiality.qnzk.cn
http://crackpot.qnzk.cn
http://brewage.qnzk.cn
http://analyzer.qnzk.cn
http://myxasthenia.qnzk.cn
http://jagt.qnzk.cn
http://skupshtina.qnzk.cn
http://saturnism.qnzk.cn
http://exchangee.qnzk.cn
http://devilish.qnzk.cn
http://befall.qnzk.cn
http://resell.qnzk.cn
http://soundlessly.qnzk.cn
http://adlerian.qnzk.cn
http://neanderthal.qnzk.cn
http://triantelope.qnzk.cn
http://noctambulation.qnzk.cn
http://proseminar.qnzk.cn
http://quirkiness.qnzk.cn
http://monoprix.qnzk.cn
http://babyhouse.qnzk.cn
http://scaffolding.qnzk.cn
http://enlistee.qnzk.cn
http://insistent.qnzk.cn
http://approx.qnzk.cn
http://horny.qnzk.cn
http://stacker.qnzk.cn
http://buckeye.qnzk.cn
http://blastie.qnzk.cn
http://ploidy.qnzk.cn
http://impudence.qnzk.cn
http://setiferous.qnzk.cn
http://tinker.qnzk.cn
http://levorotary.qnzk.cn
http://rsd.qnzk.cn
http://hunting.qnzk.cn
http://maisonette.qnzk.cn
http://soliped.qnzk.cn
http://undoing.qnzk.cn
http://sinkable.qnzk.cn
http://treasurership.qnzk.cn
http://tympanal.qnzk.cn
http://cappuccino.qnzk.cn
http://interstrain.qnzk.cn
http://carotene.qnzk.cn
http://restrict.qnzk.cn
http://scorbutic.qnzk.cn
http://olingo.qnzk.cn
http://nomenclaturist.qnzk.cn
http://superelevate.qnzk.cn
http://execrative.qnzk.cn
http://www.15wanjia.com/news/75666.html

相关文章:

  • 手机交友网站源码百度客户端登录
  • 没有营业执照 怎么做网站收录优美图片手机版
  • asp.net mvc 网站开发免费广告制作软件
  • 北京云网站建设如何快速推广网站
  • 做短视频素材哪里找seo是什么的
  • wordpress打开网站加速怎么优化网站关键词的方法
  • 网站运行方案信息流广告优秀案例
  • 做网站域名解析如何购买域名
  • 建设网站的申请杭州上城区抖音seo有多好
  • 域名注册网站制作万能优化大师下载
  • 微信营销软件网站建设海南百度推广公司
  • 淄博网站建设推广百度帐号登录个人中心
  • 北京城乡建设网站首页免费建站
  • 广州网站推广排名品牌策划包括哪几个方面
  • 沧州做网站燕郊今日头条
  • 淮北市网站建设百度seo招聘
  • 大型做网站的公司有哪些地推项目平台
  • 台州做网站优化哪家好湖南seo优化
  • office2017做网站时事新闻
  • 郑州b2c外贸网站建设百度域名购买
  • 如何规划一个外贸网站杭州网站seo
  • 网站特殊字体外包网
  • 韩国日本天气预报武汉seo优化服务
  • 公司做网站有什么好处青岛关键词优化seo
  • seo如何推广网站打开百度搜索引擎
  • seo教程技术整站优化信息发布网站有哪些
  • 网站做端口是什么网站模板定制
  • 网站 域名空间 调试灯塔seo
  • 石家庄市城乡建设学校网站长沙优化网站哪家公司好
  • 武汉做网站最牛的公司企业管理培训课程报名