技术标签: 笔记
#!/usr/bin/env python
import jieba #分词包
import numpy #numpy计算包
import codecs #codecs提供的open方法来指定打开的文件的语言编码,它会在读取的时候自动转换为内部unicode
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams[‘figure.figsize’] = (10.0, 5.0)
from wordcloud import WordCloud#词云包
from wordcloud import WordCloud,ImageColorGenerator
df = pd.read_csv(“entertainment_news.csv”, encoding=‘utf-8’)
df = df.dropna()
print(df.shape)
content=df.content.values.tolist()
print(content[:1])
#jieba.load_userdict(u"data/user_dic.txt")
segment=[]
for line in content:
try:
segs=jieba.lcut(line)
for seg in segs:
if len(seg)>1 and seg!=’\r\n’:
segment.append(seg)
except:
print(“jieba exception:”,line)
continue
print(“segment:”,len(segment),segment[:2])
words_df=pd.DataFrame({‘segment’:segment})
print(“words_df:”,words_df.head())
stopwords=pd.read_csv(“stopwords.txt”,index_col=False,quoting=3,sep="\t",names=[‘stopword’], encoding=‘utf-8’)#quoting=3全不引用
print(“stopwords:”,stopwords.head())
words_df=words_df[words_df.segment.isin(stopwords.stopword)]
words_stat_groupby=words_df.groupby(by=[‘segment’])
print(type(words_stat_groupby))
words_stat=words_df.groupby(by=[‘segment’])[‘segment’].agg({“计数”:numpy.size})
print(“words_stat.head():”)
print(words_stat.head())
words_stat=words_stat.reset_index().sort_values(by=[“计数”],ascending=False)
print(“words_stat.head():”)
print(words_stat.head())
print("…")
from matplotlib.pyplot import imread
matplotlib.rcParams[‘figure.figsize’] = (15.0, 15.0)
from wordcloud import WordCloud,ImageColorGenerator
bimg=imread(‘timg.jpg’)
wordcloud=WordCloud(background_color=“white”,mask=bimg,font_path=‘data/simhei.ttf’,max_font_size=200)
word_frequence = {x[0]:x[1] for x in words_stat.head(1000).values}
wordcloud=wordcloud.fit_words(word_frequence)
bimgColors=ImageColorGenerator(bimg)
plt.axis(“off”)
plt.imshow(wordcloud.recolor(color_func=bimgColors))
plt.show()
文章浏览阅读114次。每日一谚:花点时间起个好名字,值得!有意想学习容器或Kubernets的童鞋可以了解一下我的慕课网实战课:k8s实战 - https://coding.imooc.com/class/2...
文章浏览阅读1.7k次。简述:run程序安装包实质上是一个安装脚本加要安装的程序。安装程序的过程就是把它拷贝到相应的目录。1、打包步骤1 > 打包前准备,确定所需要打包的运行文件及其依赖库,详情请参考 Ubuntu下的deb打包、安装与卸载 中1、打包前准备2 > 要打包文件目录结构如下,其中,usr/lib为运行程序LidarPlus的依赖库,usr/src/LidarPlus 运行程序目录。
文章浏览阅读545次。MasterinUnrealScriptE:/udnweb/udn script/udn.epicgames.com/Three/MasteringUnrealScriptFunctionsCH.html #第六章 –函数 UC文件MasterTestclassMasterTestextends simplegame; Amb
文章浏览阅读124次。修改网页在Console中输入document.body.contentEditable=‘true’;整个网页就像一个富文本编辑器,你可以对任何一块内容进行修改,例如改个支付宝余额之类、修改个粉丝数操作都可以。
文章浏览阅读519次。python调用本地powershell方法1、现在准备一个简陋的powershell脚本,功能是测试一个IP列表哪些可以ping通:复制代码 代码如下:function test_ping($iplist){foreach ($myip in $iplist){$strQuery = "select * from win32_pingstatus where address = '$myip'"..._python 远程调用 get-wmiobject -computer
文章浏览阅读2k次。set函数的用法:这是一个集合函数,这个函数可以处理很多的元素,这些元素可以去重,把相同的元素都去掉,剩下不一样的元素,而且还可以自动给这些元素来排序,从小到大的顺序来排序。这里我们先来举个例子:比如:#include #include using namespace std; int main() { set a; a.insert(1); a.insert(9); a.insert(6); a..._c语言set
文章浏览阅读3.6k次。#include "math.h"#include #include #include int psnr_calculate(const char *raw,const char * compressed, char *filewrite, const int w_srgan中计算psnr的代码
文章浏览阅读1k次。DivCSS布局实例:很实用的图文混排CSS列表 - 富有语义 CSS网页布局的一大特点就是列表元素的应用,在传统的表格布局中往往将列表元素作为表格来处理,这样的方式非但不具有语义还产生了许多不必要的代码。 今天我们共同学习一款“图文混排CSS列表”的制作。首先从分析一下此列表的特点,然后编写HTML代码,最终应用CSS样式实现最终的效果。列表的效果如图所示: 最顶部是栏_div 图文列表经典实例
文章浏览阅读45次。2019独角兽企业重金招聘Python工程师标准>>> ..._laravel5.2 email queue的 机制
文章浏览阅读2.2k次。ListNode* CreaList(){ int nValue; ListNode* Head = NULL; ListNode* ListIndex = NULL; while(cin >> nValue) { if (Head == NULL) { Head = new ListNode(); Head->nValue = nValue; ListInd_一个单向链表,输出该链表中倒数第k个节点
文章浏览阅读1.1k次。1.下载ZooKeeper 地址:http://mirror.bit.edu.cn/apache/zookeeper/ 2.上载压缩文件并解压tar -zxvf zookeeper-3.4.12.tar.gz解压后的文件3.新建zookeeper配置文件cd zookeeper-3.4.12 进入文件夹cd conf 进入配置文件vim命...
文章浏览阅读794次。今天看802协议簇,忽然想起,所谓协议,实际上是对网络分层的服务原语的实现。这句话记得在看计算机网络时就有,当时就觉得是真知灼见,可是今天突然自己重新有了这个想法,感觉不错就我看来,网络分层只不过是一种形式的接口设计,也就是说,对于网络通信这个特定领域的应用,人们已经发现这种接口设计是最佳的。但对于很多其他领域,还是可以有不同的接口设计的,或者是最佳设计并没有发现。网络服务原语其实就是接口sign_协议和接口