Exemplo n.º 1
0
def t21(pa):
    wordcloud = p.WordCloud('大公司福利', width=1300, height=620)
    wordcloud.add("",
                  next(pa),
                  next(pa),
                  word_size_range=[20, 100],
                  is_toolbox_show=False)
    return wordcloud
Exemplo n.º 2
0
 def visual_cloud_pye(self, savePath):
     names = list(self.data.keys())[-self.TOP:]
     joinFilms = list(self.data.values())[-self.TOP:]
     wordcloud = pye.WordCloud(width=1440, height=720)
     wordcloud.add("",
                   names,
                   joinFilms,
                   word_size_range=[20, 60],
                   is_toolbox_show=False)
     wordcloud.render(savePath)
Exemplo n.º 3
0
    def visual_cloud_pye(self, savePath):
        name_list = self.data[0][:self.TOP]

        value_list = [10000 - 200 * i for i in range(self.TOP)]
        wordcloud = pye.WordCloud(width=1440, height=720)
        wordcloud.add("",
                      name_list,
                      value_list,
                      word_size_range=[20, 60],
                      is_toolbox_show=False)
        wordcloud.render(savePath)
Exemplo n.º 4
0
def nickname_wc(wc_title, nickname_name, nickname_num):
    '''微信好友名生成词云'''
    # 不对好友名称进行分词,直接生成词云
    wc = pyecharts.WordCloud(title=wc_title, width=1200, height=800)
    wc.add('', nickname_name, nickname_num, shape='circle')
    wc_file_name = './' + wc_title + '.html'
    try:
        wc.render(path=wc_file_name)
        print('%s已保存至%s' % (wc_title, wc_file_name))
    except Exception as e:
        logging.debug(u'Error:%s' % e)
        pass
Exemplo n.º 5
0
def signatureCloud(self, chatroom=None):  # 签名词云
    path = self.savedir + 'signatureCloud.html'
    if chatroom:
        cmd = 'signaturCloud %s' % chatroom
        myLogging(self.cmdFile, self.nickName, infoType='cmd', other=cmd)
        try:
            chatroom == self.instance.search_chatrooms(
                name=chatroom)[0]['NickName']
        except Exception as reason:
            self.instance.send('在您的通讯录中没有找到该群[%s]' % chatroom)
            myLogging(self.errFile,
                      self.nickName,
                      infoType='err',
                      other=cmd,
                      info=reason)
            return
        memberList = self.getChatroomMembers(chatroom)['MemberList']
        sigList = [each['Signature'] for each in memberList]
        subtitle = self.nickName + ':' + chatroom
    else:
        cmd = 'signaturCloud'
        myLogging(self.cmdFile, self.nickName, infoType='cmd', other=cmd)
        sigList = [each['Signature'] for each in self.frdInfoList]
        subtitle = self.nickName

    primaryList = re.findall('\w+', ' '.join(sigList))
    wordString = re.sub(r'emoji[\d\w]*|span|class', '', ' '.join(primaryList))
    finalList = [
        each for each in list(jieba.cut(wordString)) if len(each) >= 2
    ]
    words = list(set(finalList))
    amount = [finalList.count(each) for each in words]
    wordCloud = pyecharts.WordCloud('微信好友个性签名词云图', subtitle)
    shape = random.choice([
        'circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle',
        'pentagon', 'star'
    ])
    wordCloud.add('', words, amount, word_size_range=[12 - 60], shape=shape)
    wordCloud.render(path)
    self.instance.send('@fil@%s' % path)
    os.remove(path)
    myLogging(self.cmdFile,
              self.nickName,
              infoType='cmd',
              status='success',
              other=cmd)
Exemplo n.º 6
0
def create_WdCloud():
    name = [
        'Sam S Club', 'Macys', 'Amy Schumer', 'Jurassic World',
        'Charter Communications', 'Chick Fil A', 'Planet Fitness',
        'Pitch Perfect', 'Express', 'Home', 'Johnny Depp', 'Lena Dunham',
        'Lewis Hamilton', 'KXAN', 'Mary Ellen Mark', 'Farrah Abraham',
        'Rita Ora', 'Serena Williams', 'NCAA baseball tournament',
        'Point Break'
    ]
    value = [
        10000, 6181, 4386, 4055, 2467, 2244, 1898, 1484, 1112, 965, 847, 582,
        555, 550, 462, 366, 360, 282, 273, 265
    ]
    wordcloud = pyecharts.WordCloud(width=1300, height=620)
    wordcloud.add("", name, value, word_size_range=[20, 100])
    # wordcloud.render('wd-cloud.html')
    page.add(wordcloud)
Exemplo n.º 7
0
    for name in names_data:
        if name in content_negative[i][0]:
            name_negative.append(name)
name_negative = list(set(name_negative))
negative_content += '\n重要舆情新闻涉及到的股票为:\n'
for name in name_negative:
    negative_content += (name + ',')
f = open('data\\' + end_date[:10] + '舆情晨报新闻.txt', 'w',
         encoding='utf-8')  # 保存文件
f.write(negative_content)
f.close()
print(negative_content)
# 标签汇总
delete_words = [
    '投资', '股票', '经济', '时政', '宏观经济', '时政外交', '财经', '金融', '公司', '国内宏观', '国外宏观',
    '国际社会', '分析师', '银行', '基金', '保险', '环比', '同比', '董事会', '股东'
]  # 去除无意义的词汇,相当于停用词
for w in delete_words:
    try:
        del words_score_dict[w]
    except KeyError:
        continue
sorted_words_score = sorted(words_score_dict.items(),
                            key=lambda d: d[1],
                            reverse=True)
print(sorted_words_score)
words, scores = zip(*sorted_words_score)
word_cloud = pyecharts.WordCloud(width=1600, height=1000)
scores = [math.sqrt(score) for score in scores]  # 调整权重以画图显示的更好
word_cloud.add("", words, scores, shape="circle")
word_cloud.render('data\\' + end_date[:10] + '舆情晨报词云.html')  # 保存文件
Exemplo n.º 8
0
麦克斯韦电磁理论经验定律包括:
静电学的库仑定律,涉及磁场的定律,关于电流的磁场的安培定律,法拉第电磁感应定律。
麦克斯韦把这四个定律予以综合,导出麦克斯韦方程,该方程组系统而完整地概括了电磁场的基本规律,
并预言了电磁波的存在。麦克斯韦提出的涡旋电场和位移电流假说的核心思想是:变化的磁场可以激发涡旋电场,
变化的电场可以激发涡旋磁场;电场和磁场不是彼此孤立的,它们相互联系、相互激发组成一个统一的电磁场。
下面我们通过制作感应天线体,来验证电磁场的存在。如图所示:电偶极子是一种基本的辐射单元,
它是一段长度远小于波长的直线电流元,线上的电流均匀同相,一个作时谐振荡的电流元可以辐射电磁波,
故又称为元天线,元天线是最基本的天线。电磁感应装置的接收天线可采用多种天线形式,相对而言性能优良,
但又容易制作,成本低廉的有半波天线、环形天线、螺旋天线等。 
"""

word_list = jieba.lcut(text)
# print(word_list)

extract_tags = jieba.analyse.extract_tags(text)
print(extract_tags)

word_dict = {}
for word in word_list:
    if word in extract_tags:
        word_dict[word] = word_dict.get(word, 0) + 1
print(word_dict)

chart = pyecharts.WordCloud("...")
chart.add("",
          word_dict.keys(),
          word_dict.values(),
          word_size_range=[15, 100],
          rotate_step=30)
chart
Exemplo n.º 9
0
def generate_wordcloud(keywords_counts,path_name):
	wordcloud =pec.WordCloud(path_name,width=1920, height=1080)
	# wordcloud.use_theme('dark')
	wordcloud.add("", keywords_counts.index, keywords_counts.values, word_size_range=[10, 200])
	wordcloud.render(path=path_name)
Exemplo n.º 10
0
def gen_word_cloud(word_list,path_name):
	wordcloud = pec.WordCloud(width=1280,height=720)
	wordcloud.add('keywords',word_list.index,word_list.values,word_size_range=[20,100],shape = 'diamond')
	wordcloud.render(path=path_name)
	print('done')
Exemplo n.º 11
0
def aboutMe(request):
    gauge = pyecharts.Gauge('', background_color='#f5f5f5')
    gauge.add('title',
              'Percent',
              80.66,
              scale_range=[0, 100],
              is_more_utils=True)
    gauge.show_config()
    result = gauge.render_embed()
    data = [("宿迁", 9), ("武汉", 10), ("重庆", 12), ("哈尔滨", 18), ("乌鲁木齐", 10),
            ("北京", 15), ("南京", 13)]
    geo = pyecharts.Geo("中国各城市PM2.5含量示意图",
                        "data from pm2.5",
                        title_color="#000",
                        title_pos="center",
                        background_color='#f5f5f5')
    attr, value = geo.cast(data)
    geo.add("",
            attr,
            value,
            type="effectScatter",
            is_random=True,
            effect_scale=5,
            is_more_utils=True)
    geo.show_config()
    result1 = geo.render_embed()
    attr = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
    v1 = [20, 33, 133, 124, 24, 313]
    v2 = [2.6, 12, 31, 241, 324, 134]
    bar = pyecharts.Bar('Bar Sample', background_color='#f5f5f5')
    bar.add("A", attr, v1, mark_line=["average"], mark_point=["min", "max"])
    bar.add("B",
            attr,
            v2,
            mark_line=["average"],
            mark_point=["min", "max"],
            is_more_utils=True)
    bar_result = bar.render_embed()
    pie = pyecharts.Pie('', background_color="#f5f5f5")
    pie.add("",
            attr,
            v1,
            is_lable_show=True,
            lable_text_color="#156ACF",
            is_more_utils=True)
    pie.show_config()
    pie_result = pie.render_embed()
    liquid = pyecharts.Liquid('', background_color="#000")
    liquid.add("", [0.66, 0.5], ['diamond'], ['#294D99', '#156ACF'],
               is_more_utils=True)
    liquid.show_config()
    liquid_result = liquid.render_embed()
    l3d = line3d()
    l3d_result = l3d.render_embed()
    name = [
        'afaaf', 'Tom han', 'ajf oafoa', 'auoj aoudh', 'ad da fa',
        'auohdahb da'
    ]
    value = [
        10000,
        1132,
        414,
        1313,
        3452,
        1413,
    ]
    wordcloud = pyecharts.WordCloud(width=800,
                                    height=400,
                                    background_color="#000")
    wordcloud.add("", name, value, word_size_range=[20, 100], rotate_step=50)
    wordcloud.show_config()
    w = wordcloud.render_embed()
    REMOTE_HOST = "https://pyecharts.github.io/assets/js"
    return render_to_response(
        'AboutMe.html', {
            'result': result,
            'result1': result1,
            'bar_result': bar_result,
            'pie_result': pie_result,
            'liquid_result': liquid_result,
            'l3d_result': l3d_result,
            'host': REMOTE_HOST,
            'script_list': l3d.get_js_dependencies(),
            'w': w
        })