In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about the method of extracting keywords from Python comments to make exquisite words and clouds. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Grab all comments
Comments: {'android': 545 times,' ios': 110 times, 'pc': 44 times,' uniapp': 1 times}
One small detail: of the devices that commented on me, the Android Apple ratio was 5:1.
Building prefix dict from the default dictionary... Loading model cost 0.361 seconds. Prefix dict has been built successfully.
1. Find the comment interface
Open chrome browser, developer mode
Click on the comment list (icon 1)
Click the interface link (icon 2)
View the response return value (the json format of the comment result)
2. Python get comments def get_comments (articleId): # determine the number of pages of comments main_res = get_commentId (articleId,1) pageCount = json.loads (main_res) ['data'] [' pageCount'] comment_list,comment_list2 = [], [] source_analy = {} for p in range (1mage CountCount1): res = get_commentId (articleId) P) try: commentIds = json.loads (res) ['data'] [' list'] for i in commentIds: commentId = I ['info'] [' commentId'] userName = I ['info'] [' userName'] nickName = I ['info'] [' nickName'] # # get the user name Source_dvs = I ['info'] [' commentFromTypeResult'] ['key'] # operating device content = I [' info'] ['content'] comment_list.append ([commentId] UserName, nickName, source_dvs, content]) comment_list2.append ("% s"% (userName) NickName)) if source_dvs not in source_analy.keys (): source_ analysis [source _ dvs] = 1 else: source_ analysis [source _ dvs] = source_ analysis [source _ dvs] + 1 # print (source_analy) except: print ('this page failed!') Print ('number of comments:' + str (len (comment_list) return source_analy, comment_list, comment_ List2 II, text segmentation, word cloud production 1, text analysis
Tomatoes use the stuttering participle, and wordcloud.
#-*-coding:utf8-*-import jiebaimport wordcloud
Code implementation:
Seg_list = jieba.cut (comments, cut_all=False) # precise mode word = '.join (seg_list) 2, generate word cloud
The background picture of the tomato is a heart-shaped picture.
Pic = mpimg.imread ('/ Users/pray/Downloads/aixin.jpeg')
Complete code:
Def word_cloud (articleId): source_analy, comment_list, comment_list2 = get_comments (articleId) print ("comments:", source_analy) comments =''for one in comment_list: comment = one [4] if' face' not in comment: comments = comments + comment seg_list = jieba.cut (comments Cut_all=False) # precise pattern word = '.join (seg_list) pic = mpimg.imread (' / Users/pray/Downloads/aixin.jpeg') wc = wordcloud.WordCloud (mask=pic, font_path='/Library/Fonts/Songti.ttc', width=1000, height=500, background_color='white') .generate (word) 3, preliminary results-ambiguity
Tomatoes found that the text is blurry and the edge of the image curve is not clear.
As a result, specify the resolution and straighten it up in HD.
# Save plt.savefig ('xin300.png', dpi=300) # specify resolution save 4, final effect-High definition without horse
These are all the contents of this article entitled "how to extract keywords from Python comments to make exquisite words". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.