pycloudtag_wordcloud 中英文标签云
https://study.163.com/course/courseMain.htm?courseId=1006383008&share=2&shareId=400000000398149(博主录制)

原创,机器学习,统计项目合作QQ:231469242,版权所有
GitHub 官网
https://github.com/amueller/word_cloud
Anaconda3,Python3
英文标签云
# -*- coding: utf-8 -*-
"""
Python3.0
Created on Sat Nov 26 08:54:26 2016
需要的安装包
pip install pytagcloud
pip install pygame
pip install simplejson
@author: daxiong
"""
import pytagcloud #wordcounts 是一个列表,元素是元组
wordcounts=[("python",5),("love",2),("work",1)]
tags = pytagcloud.make_tags(wordcounts)
pytagcloud.createtag_image(tags, 'cloud_large.png', size=(900, 600))

说明文档
中文标签云

# -*- coding: utf-8 -*-
"""
Created on Mon Aug 14 15:55:43 2017 @author: toby
""" from wordcloud import WordCloud
import matplotlib.pyplot as plt text = '''文案 文案
The 抱抱 Zen of LOVE 抱抱 Python, 快乐 by Tim Peters
公众号 公众号 Python 最好的 语言 语言
一辈子 is better LOVE than 一辈子.
喵小姐 is 爱你 than implicit.爱你 喵小姐
蟹先生 is 爱你 than complex.
一辈子 is 蟹先生 than complicated.
二中 is 喵小姐 我想你了 than nested. 二中 蟹先生
清湖 is 胜于 than 清湖.
思旺 counts. 想你
Special 喵小姐 我想你了 aren't special enough 思旺 break 思旺 rules.
别生气 practicality beats 厨艺好.
Errors should 我想你了 never pass 小龙虾 silently. 运营
别生气 explicitly 好不好. LOVE
In the face of ambiguity, 程序员 the 厨艺好 to guess.龙华 龙华
There 快乐 should be one-- 我想你了 and preferably 红烧肉 only one 小龙虾--obvious way to do it.运营
Although 共享单车 way may not 我想你了 be obvious at first unless you're Dutch. 新媒体 地铁
Now is better 红烧肉 than never.
程序员 Although 共享单车 is often 高铁 than 东莞 now. 高铁 地铁
If the implementation 想你 is hard to explain, it's a bad idea. 想你了
If 成都 implementation is 想你 easy to explain, it may be a good idea.
Namespaces are 端午one 端午 honking great idea -- 成都 do more of those! 想你了
深圳 晚安 深圳 新媒体
''' # the font from github: https://github.com/adobe-fonts
font = r'C:\Windows\Fonts\simfang.ttf'
wc = WordCloud(collocations=False, font_path=font, width=1400, height=1400, margin=2).generate(text.lower()) plt.imshow(wc)
plt.axis("off")
plt.show() wc.to_file('show_Chinese.png') # 把词云保存下来
爬虫+正则+标签云+pandas保存Excel

# -*- coding: utf-8 -*-
"""
Created on Mon Aug 14 08:57:21 2017 @author: toby
"""
import jieba
import pandas
import urllib
import re
from bs4 import BeautifulSoup
from wordcloud import WordCloud
import matplotlib.pyplot as plt
#引用微软的中文字体
font = r'C:\Windows\Fonts\simfang.ttf'
'''
#赛柏蓝
url="http://mp.weixin.qq.com/profile?src=3×tamp=1502674891&ver=1&signature=wDxrEoM1f5I3Js7rVZL7XeAOVS5q6FoHLVuMdM*iJLccLjB80A1BESmnMfk62BrS9Uz4VyJ05uzI8aJoW6r6Vw=="
#医药魔方
url="http://mp.weixin.qq.com/profile?src=3×tamp=1502690954&ver=1&signature=*jfLnFfVyfWmIcIyMN*R4*av27A-ubJUNLoiD2B17*Zqj9W*HPoPKdtFegntGr0Ft7jVfdMcW9tLMjBXf7r4vQ=="
''' url="http://mp.weixin.qq.com/profile?src=3×tamp=1502691348&ver=1&signature=piBaU5ZN*TbBiF41yhw-D4sDK9*mY8TOht4snXuo6Hrm3UKMe5I7wpU*zgCa2Bk3DS-joq3oSNOXboucANMwWg==" html = urllib.request.urlopen(url).read()
text = BeautifulSoup(html,"lxml").get_text()
#正则表达式规则
#标题名
regex = re.compile(r'\"title\"\:\"(.+?)\"')
#摘要
regex1 = re.compile(r'\"digest\"\:\"(.+?)\"')
#print(regex.findall(text))
#print(regex1.findall(text))
len1=len(regex.findall(text))
list_tilte=regex.findall(text)
list_digest=regex1.findall(text)
#把标题和摘要合并在一起
list_allWords=list_tilte+list_digest filename="nonesense_words.txt"
#list_noneSense_words=["赛柏蓝","出品","我们","一个","工作","问题","中国","大家"] #垃圾词库
def List_none_sense(filename):
file_noneSense_words=open(filename,'r')
list_noneSense_words=[]
for line in file_noneSense_words:
line_list=line.split()
for word in line_list:
list_noneSense_words.append(word)
return list_noneSense_words #判断一个单词是否在垃圾词表里
def none_sense_words_Judeg(word):
if word in list_noneSense_words:
return True
else:
return False #过滤停用词列表
def filter_none_sense_words(list1):
list2=[]
for i in list1:
#如果不在垃圾词库里或不是数字,汉字长度大于1
if none_sense_words_Judeg(i[0])==False and i[0].isdigit()==False and len(i[0])>1:
#print("remove",i)
list2.append(i)
return list2 def Fenci():
list_total=[]
for i in list_allWords:
seg_list = list(jieba.cut(i,cut_all=False))
list_total+=seg_list
#生成一个字典,每个单词排名
tf={}
for seg in list_total :
#print seg
seg = ''.join(seg.split())
if (seg != '' and seg != "\n" and seg != "\n\n") :
if seg in tf :
tf[seg] += 1
else :
tf[seg] = 1
return sorted(tf.items(),key=lambda item:item[1],reverse=True) #筛选排名大于三的,并且名词长度大于1
def more3_filter(list1):
list2=[]
for i in list1:
if i[1]>2 and len(i[0])>1:
list2.append(i)
return list2 #垃圾词表
list_noneSense_words=List_none_sense(filename)
list_words=Fenci()
#过滤停用词
list_words1=filter_none_sense_words(list_words)
list_words2=more3_filter(list_words1)
#前二十
list_words3=list_words2[:20]
for i in list_words3:
print (i) #写入数据到Excel,用pandas的df数据结构
df=pandas.DataFrame(list_words3)
df.to_excel("result.xlsx") #标签云传输的frequency必须是字典形式,所以要转换
list_words3=dict(list_words3) wc = WordCloud(collocations=False, font_path=font, width=1400, height=1400, margin=2).generate_from_frequencies(list_words3) plt.imshow(wc) plt.axis("off")
plt.show()
wc.to_file('show_Chinese.png') # 把词云保存下来
https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149(博主视频教学主页)

pycloudtag_wordcloud 中英文标签云的更多相关文章
- Android自定义控件之自定义ViewGroup实现标签云
前言: 前面几篇讲了自定义控件绘制原理Android自定义控件之基本原理(一),自定义属性Android自定义控件之自定义属性(二),自定义组合控件Android自定义控件之自定义组合控件(三),常言 ...
- 原生js文字标签云上下滚动播放
效果:http://hovertree.com/texiao/js/25/ 效果图: 代码如下: <!DOCTYPE html> <html> <head>< ...
- pycloudtag 标签云
原创,转载请标明 QQ:231469242 # -*- coding: utf-8 -*- """Python3.0 Created on Sat Nov 26 08:5 ...
- 用CSS制作伪标签云
performance testing stress testing conformance testing acceptane testing smoke testing regression te ...
- 基于纯 CSS3 技术实现美观的标签云效果
标签云是博客的标配功能,能够清晰的呈现博客的各个关键词和主题.在这个效果中,您将学习如何使用 CSS3 技术创建一个效果精美的标签云效果. 作为实验项目,使用了 CSS3 渐变,阴影和最重要的的 CS ...
- css3实践之摩天轮式图片轮播+3D正方体+3D标签云(perspective、transform-style、perspective-origin)
本文主要通过摩天轮式图片轮播的例子来讲解与css3 3D有关的一些属性. demo预览: 摩天轮式图片轮播(貌似没兼容360 最好用chrome) 3D正方体(chrome only) 3D标签云(c ...
- 在hexo静态博客中利用d3-cloud来展现标签云
效果: http://lucyhao.com/tags/ hexo自带的tag cloud的标签展现不太美观,想能够展现出“云”效果的标签.在网上找到了d3-cloud这个项目,github地址:ht ...
- python3生成标签云
标签云是现在大数据里面最喜欢使用的一种展现方式,其中在python3下也能实现标签云的效果,贴图如下: -------------------进入正文--------------------- 首先要 ...
- 3D球状标签云(兼容IE8)
看见一个很有趣的标签云,3D球状,兼容 IE 8,亲测可用!其他版本没有测试.觉得挺有意思就拿来记录下来,学习学习,本文下方会放出我看的文章地址,先看一下效果: 接下来是代码,html + css + ...
随机推荐
- OGG学习笔记02
实验环境:源端:192.168.1.30,Oracle 10.2.0.5 单实例目标端:192.168.1.31,Oracle 10.2.0.5 单实例 1.模拟源数据库业务持续运行 2.配置OGG前 ...
- Python单元测试框架unittest重要属性 与 用例编写思路
前言 本文为转载,原文地址作者列举python unittest这个测试框架的主要属性和 测试用例思路 unittest单元测试框架不仅可以适用于单元测试,还可以适用WEB自动化测试用例的开发与执行, ...
- mysql sleep 死锁例子
表结构 CREATE TABLE `orders` ( `order_id` int(11) NOT NULL, `order_addr` varchar(255) DEFAULT NULL ) EN ...
- 开源you-get项目爬虫,以及基于python+selenium的自动测试利器
写在前面 爬虫和自动测试,对于python来说是最合适不过也是最擅长的. 开源的项目也很多,例如you-get项目https://github.com/soimort/you-get.盗链和爬虫神器. ...
- AxMath_V2.5.0.0安装和激活
目录 1. 相关推荐 2. 按 3. AxMath 功能与特色 4. 软件介绍 4.1. 编辑与排版 4.2. 科学计算功能 4.3. 输出与发布 4.4. 运行环境 4.5. 破解说明 5. 安装步 ...
- Linux命令行——scp命令
原创声明:本文系博主原创文章,转载或引用请注明出处. scp 一般格式: scp [option] src dst 1. src和dst格式为: [user@]host:/path/to/file ...
- mysqltuner对数据库的优化
主要用于对mysql配置及my.cnf配置检查,提供详细信息,为进一步优化mysql做参考. 下载地址: (1)http://mysqltuner.com/ (2)脚本获取# wget -c http ...
- 箭头函数中可改变this作用域,回调函数用箭头函数this指向page,自定义事件用箭头函数this指向undefined
1.回调函数中,用箭头函数改变this的作用域 success: (res)=>{ this.setData({ //此时,this指向page页面 ... }) } 2.自定义事件中,如果使用 ...
- hive三种调用方式
一.hive -e ‘sql语句’ (shell命令) 适合比较短的sql语句调用,优点是可以直接在shell中调用静音模式 -S 在执行HiveQL过程中,不在显示器输出MR的执行过程hive -S ...
- guava的一些用法
package guavaTest; import com.google.common.base.CharMatcher; import com.google.common.base.Joiner; ...