添加云图

master
cflsxjw 5 months ago
parent 61cc66975c
commit ffe5a1a7be

@ -7,4 +7,8 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PackageRequirementsSettings">
<option name="removeUnused" value="true" />
<option name="modifyBaseFiles" value="true" />
</component>
</module>

@ -1,19 +1,65 @@
# 102201638
# 一、PSP表格
| **PSP2.1** | **Personal Software Process Stages** | **预估耗时(分钟)** | **实际耗时(分钟)** |
|:----------------------------------------|--------------------------------------|--------------|--------------|
| Planning | 计划 | | |
| · Estimate | · 估计这个任务需要多少时间 | | |
| · Estimate | · 估计这个任务需要多少时间 | 30 | 30 |
| Development | 开发 | | |
| · Analysis | · 需求分析 (包括学习新技术) | | |
| · Design Spec | · 生成设计文档 | | |
| · Design Review | · 设计复审 | | |
| · Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | | |
| · Design | · 具体设计 | | |
| · Coding | · 具体编码 | | |
| · Code Review | · 代码复审 | | |
| · Test | · 测试(自我测试,修改代码,提交修改) | | |
| · Analysis | · 需求分析 (包括学习新技术) | 240 | 240 |
| · Design Spec | · 生成设计文档 | 120 | 120 |
| · Design Review | · 设计复审 | 30 | 30 |
| · Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 30 | 30 |
| · Design | · 具体设计 | 180 | 180 |
| · Coding | · 具体编码 | 1200 | 1200 |
| · Code Review | · 代码复审 | 120 | 120 |
| · Test | · 测试(自我测试,修改代码,提交修改) | 180 | 180 |
| Reporting | 报告 | | |
| · Test Report | · 测试报告 | | |
| · Size Measurement | · 计算工作量 | | |
| · Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | | |
| | · 合计 | | |
| · Test Report | · 测试报告 | 240 | 240 |
| · Size Measurement | · 计算工作量 | 60 | 60 |
| · Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | 60 | 60 |
| | · 合计 | 2490 | 2490 |
# 二、任务要求的实现
## (2.1)项目设计与技术栈
### 主要流程
- 初步查询有关教程,了解工具
- 进行弹幕爬虫编写
- 云图生成
### 技术栈
- 使用Python3脚本语言
- 网页数据请求requests
- 数据解析beautiful soup 4
- 数据筛选:正则表达式(re)
- 云图生成jieba(单词提取) wordcloud(图生成)
## (2.2)爬虫与数据处理
- 获取搜索结果bv(视频号)列表
- 由bv列表获取cid(视频弹幕文件号)
- 获取弹幕列表
- 筛选符合关键词的弹幕
## (2.3)数据统计接口部分的性能改进
![性能分析图](https://ice.frostsky.com/2024/09/18/0598527397075b182d1fee0792ed6c9f.png)
>消耗最大的函数是request函数可见网络请求及传输对性能影响最大
## (2.4)数据结论的可靠性
原始数据相当少,无法得到有效的结论
## (2.5)数据可视化界面的展示
![云图](https://ice.frostsky.com/2024/09/18/1f4dd603eca288ada9b91881ba205546.png)
>云图使用wordcloud创建
# 三、心得体会
本次作业锻炼了解决问题的能力,对实际项目的开发流程有了初步的认识,提升了学科素养

@ -2,6 +2,10 @@ import re
import requests
import json
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import jieba
# 获取搜索结果
@ -78,4 +82,14 @@ def comments_filter(rules, comments_list):
if re.match(pattern, comment):
if not res.__contains__(comment):
res.append(comment)
return res
return res
def gen_wordcloud(filtered_text):
source = []
for word in filtered_text:
source += jieba.lcut(word)
source = ' '.join(source)
wordcloud = WordCloud(font_path="./font.ttf", background_color='white', scale=1.5).generate(source)
plt.imshow(wordcloud)
plt.axis('off')
plt.show()

Binary file not shown.

@ -1,3 +1,8 @@
from crawlerCore import *
rules=[r'[^a-z]*AI[^a-z]*']
print(comments_filter(rules, get_comments(get_cid(get_search_result_bv("2024巴黎奥运会",300)))))
filtered_text = comments_filter(rules, get_comments(get_cid(get_search_result_bv("2024巴黎奥运会",300))))
print(filtered_text)
filtered_text.remove('福州大学紫金地矿薛锡熊别找唐氏ai弹幕了') # ??? :P
gen_wordcloud(filtered_text)

@ -1,8 +1,6 @@
beautifulsoup4==4.12.3
bs4==0.0.2
certifi==2024.8.30
charset-normalizer==3.3.2
idna==3.10
requests==2.32.3
soupsieve==2.6
urllib3==2.2.3
matplotlib~=3.9.2
wordcloud~=1.9.3
jieba~=0.42.1
Loading…
Cancel
Save