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

手机网站上线左右滑动优化seo教程

手机网站上线左右滑动,优化seo教程,佛山营销网站开发怎么选,免费二级域名分发网-------------词云图集合------------- WordCloud去掉停用词(fit_wordsgenerate)的2种用法 通过词频来绘制词云图(jiebaWordCloud) Python教程95:去掉停用词词频统计jieba.tokenize示例用法 将进酒—李白process_t…

-------------词云图集合-------------

WordCloud去掉停用词(fit_words+generate)的2种用法

通过词频来绘制词云图(jieba+WordCloud)

Python教程95:去掉停用词+词频统计+jieba.tokenize示例用法

将进酒—李白process_text词频统计,及词频可视化分析

使用wordcloud模块,绘制一个自定义的词云图形状

使用WordCloud模块中repeat参数,做一个关键字重复的词云图

关于词云图显示异常,出现乱码的解决办法

盘点WordCloud模块,词云图的相关知识点

Python源码05:使用Pyecharts画词云图图

在WordCloud中去掉停用词,可以通过设置stopwords参数来实现,也可以通过下面字典数据的过滤方法来去掉不想要的词语。停用词是指在文本中频繁出现但对文本含义贡献很小的词语,如虚词、助词、介词、连词等。下面写的2个例子,可以给大家参考一下。

1.W.generate通常结合stopwords过滤停用词的方法,运行代码就会生成如下图。可以看到原文本(杨过是欧阳锋的义子,他的黯然销魂掌,可以和郭靖的降龙十八掌媲美),文本里面的 是,和,的,它等需要都被去掉了。
在这里插入图片描述

# -*- coding: utf-8 -*-
# @Author : 小红牛
# 微信公众号:WdPython
import jieba
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt# 1.读取文本
text = '杨过是欧阳锋的义子,他的黯然销魂掌,可以和郭靖的降龙十八掌媲美。'
print('1.原文本:'.center(50, '-'))
print(text)
# 2.分词
cut_word = jieba.cut(text, cut_all=False)
cut_word = ' '.join(cut_word)
print('2.jieba分词后的内容:'.center(50, '-'))
print(cut_word)
# 3.准备停用词表
stopwords = set(STOPWORDS)
print('3.WordCloud自带的英文停用词表:'.center(50, '-'))
print(stopwords)
# 自定义添加停用词
stopwords.add('是')
stopwords.add('的')
stopwords.add('和')
stopwords.add('他')
stopwords.add('可以')# 4.创建WordCloud对象并生成词云,stopwords=stopwords,
w = WordCloud(background_color='WHITE', stopwords=stopwords, height=400,width=700, font_path='simkai.ttf')w.generate(cut_word)
# 5.保存词云图图片
w.to_file('cloud.png')
# 显示词云图
plt.imshow(w)
plt.axis('off')
plt.show()
print('词云图生成完成。')

输出内容:

----------------------1.原文本:----------------------
杨过是欧阳锋的义子,他的黯然销魂掌,可以和郭靖的降龙十八掌媲美。
------------------2.jieba分词后的内容:------------------
杨过 是 欧阳锋 的 义子 , 他 的 黯然销魂 掌 , 可以 和 郭靖 的 降龙十八掌 媲美 。
--------------3.WordCloud自带的英文停用词表:---------------
{"you'll", "doesn't", 'yourself', 'after', 'by', "we're", 'other', 'and', 'just', 'this', "when's", 'hence', 'own', 'ours', 'myself', "won't", 'otherwise', 'what', 'on', 'can', 'else', "we'll", 'k', 'him', "haven't", "they'll", "she's", "i'd", 'there', 'itself', 'of', "you've", "there's", 'herself', 'off', 'his', 'once', "that's", 'very', 'was', 'ever', 'would', 'until', 'why', 'me', 'had', "where's", 'does', 'over', 'shall', 'if', 'since', "what's", 'a', 'some', 'the', "shouldn't", 'we', 'where', 'any', 'an', 'she', 'them', "hadn't", "he'll", "he's", 'who', "it's", 'he', 'ourselves', 'also', 'you', 'most', 'were', "i'll", 'r', 'with', 'at', 'yourselves', 'have', 'when', 'www', "mustn't", 'about', 'up', 'did', "let's", 'are', 'few', 'be', 'being', 'too', 'their', 'cannot', 'more', 'to', "here's", "why's", 'having', "didn't", 'hers', 'no', 'in', 'under', 'how', 'again', "he'd", 'her', 'so', "they're", "she'll", 'against', 'however', 'my', "couldn't", "i'm", "wouldn't", "she'd", "aren't", 'been', 'above', 'before', 'those', "we'd", 'such', "hasn't", "isn't", 'not', 'only', 'http', "they'd", 'nor', 'because', 'i', "you'd", 'which', 'they', "who's", 'it', 'could', 'into', "can't", 'out', 'while', 'down', "how's", 'ought', 'am', "don't", 'each', 'himself', 'through', "i've", 'whom', 'from', 'is', 'therefore', 'themselves', 'our', 'all', 'but', 'same', "shan't", "you're", 'as', 'between', 'has', 'then', "we've", 'both', 'its', 'these', 'should', 'like', 'or', "they've", 'do', 'theirs', "weren't", 'below', 'yours', 'com', 'for', 'than', 'here', 'get', 'that', "wasn't", 'your', 'further', 'doing', 'during'}

2.通过w.fit_words(参数为字典类型)+Counter(参数可以是字符串,也可以是可迭代的对象,返回字典类型)+jieba(参数是字符串,返回是generator类型)。下面代码中会按照关键字+词频的阈值去自定义过滤,不符合条件的词频(和字典数据知识点的用法一样),以上2种处理过滤的结果是一样。个人觉得使用w.fit_words比W.generate生成词云图,要更直观一点,因为它可以根据词频的大小,在词云图上反应出字体的大小。简单说某个词频非常高,那么它的字号在词云图上显示的就越大。


# -*- coding: utf-8 -*-
# @Author : 小红牛
# 微信公众号:WdPython
import re
import jieba
from collections import Counter
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt# 1.读取文本
text = '杨过是欧阳锋的义子,他的黯然销魂掌,可以和郭靖的降龙十八掌媲美。'
# 使用正则,只取中文的字符,过滤英文数字,各种标点符号等等
text = re.findall('[\u4e00-\u9fff]+', text)
text = ''.join(text)
print('1.只取中文文本:'.center(50, '-'))
print(text)
# 2.分词
cut_word = jieba.cut(text, cut_all=False)
word_freq = Counter(cut_word)
print('2.过滤前的分词词频:'.center(50, '-'))
print(word_freq)# 自定义定义过滤条件
min_freq = 0  # 最小词频阈值
exclude_words = {'是', '的', '和', '可以', '他'}  # 要排除的词列表# 过滤词频字典
filtered_word_freq = {word: freq for word, freq in word_freq.items()if freq >= min_freq and word not in exclude_words}print('3.过滤后词频:'.center(50, '-'))
print(filtered_word_freq)# 4.创建WordCloud对象并生成词云
w = WordCloud(background_color='WHITE', height=400, width=700,font_path='simkai.ttf')w.fit_words(filtered_word_freq)
# 5.保存词云图图片
w.to_file('cloud.png')
# 显示词云图
plt.imshow(w)
plt.axis('off')
plt.show()
print('词云图生成完成。')

输出内容:

--------------------1.只取中文文本:---------------------
杨过是欧阳锋的义子他的黯然销魂掌可以和郭靖的降龙十八掌媲美
Building prefix dict from the default dictionary ...
Loading model from cache C:\Users\Ms-xiao\AppData\Local\Temp\jieba.cache
Loading model cost 1.151 seconds.
Prefix dict has been built successfully.
--------------------2.过滤前的词频:---------------------
Counter({'的': 3, '杨过': 1, '是': 1, '欧阳锋': 1, '义子': 1, '他': 1, '黯然销魂': 1, '掌': 1, '可以': 1, '和': 1, '郭靖': 1, '降龙十八掌': 1, '媲美': 1})
---------------------3.过滤后词频:---------------------
{'杨过': 1, '欧阳锋': 1, '义子': 1, '黯然销魂': 1, '掌': 1, '郭靖': 1, '降龙十八掌': 1, '媲美': 1}
词云图生成完成。

完毕!!感谢您的收看

----------★★历史博文集合★★----------

我的零基础Python教程,Python入门篇 进阶篇 视频教程 Py安装py项目 Python模块 Python爬虫 Json Xpath 正则表达式 Selenium Etree CssGui程序开发 Tkinter Pyqt5 列表元组字典数据可视化 matplotlib 词云图 Pyecharts 海龟画图 Pandas Bug处理 电脑小知识office自动化办公 编程工具 NumPy Pygame

http://www.khdw.cn/news/4489.html

相关文章:

  • 锦州做网站公司哪家好网址服务器查询
  • 网站搭建周期seo网站
  • wordpress显示版权东莞seo整站优化
  • 大学生网站开发文档今日热点新闻事件摘抄50字
  • 网站关键词优化多少钱搜索引擎优化的技巧有哪些
  • 合肥网站建设价格查询网站域名
  • 合肥网站建设兼职想要网站导航推广页
  • 石龙仿做网站站内营销推广方案
  • 兼职做网站挣钱么营销策划培训
  • 做树状图的网站深圳网络营销外包公司推荐
  • 网站备案成功后可以改吗百度产品大全
  • 北京网络建设公司上海谷歌seo推广公司
  • 去国外做非法网站吗优化大师下载安装
  • 如何自己建设商城网站百度做推广一般要多少钱
  • 无锡做网站需要多少钱东莞seo建站优化工具
  • 网站地图设计成品影视app开发
  • 什么网站比较少人做武汉搜索引擎营销
  • 云南网站推广重庆关键词自然排名
  • 做折扣的网站有哪些现在外贸推广做哪个平台
  • 网站关于我们怎么做搜索引擎排名优化是什么意思
  • wordpress 批量建站百度竞价排名名词解释
  • 云南做网站费用东莞市民最新疫情
  • 天堂呦呦衡阳seo优化首选
  • 中国最新消息最新疫情德州网站建设优化
  • 什么是一学一做视频网站好安卓优化大师app下载安装
  • 沈阳平台网站建设英语培训
  • 手机做网站多少钱qq群推广链接
  • 章丘做网站优化百度一下网页入口
  • 沧州做网站价格广东短视频seo营销
  • 南山品牌网站建设企业站长工具使用方法