Showing
1 changed file
with
28 additions
and
0 deletions
utils/getTopicPageData.py
0 → 100644
| 1 | +from utils.getPublicData import * | ||
| 2 | + | ||
| 3 | +def getTopicLen(topic):# 统计特定话题下的评论数目 | ||
| 4 | + commentsList = getAllCommentsData() | ||
| 5 | + topic_len = 0 | ||
| 6 | + for i in commentsList: | ||
| 7 | + if i[9] == topic: | ||
| 8 | + topicLen+=1 | ||
| 9 | + return topic_len | ||
| 10 | + | ||
| 11 | +def getTopicPageCreatedAtCharData(topic):# 统计包含特定热词的评论在每个日期的数量,并返回日期和对应的评论数量 | ||
| 12 | + commentsList = getAllCommentsData() | ||
| 13 | + createdAt = {} | ||
| 14 | + for i in commentsList: | ||
| 15 | + if i[9]==topic: | ||
| 16 | + if i[1] in createdAt.keys(): | ||
| 17 | + createdAt[i[1]] += 1 | ||
| 18 | + else: | ||
| 19 | + createdAt[i[1]] = 1 | ||
| 20 | + return list(createdAt.keys()),list(createdAt.values()) | ||
| 21 | + | ||
| 22 | +def getCommentFilterData(topic):# 筛选包含特定热词的评论并返回这些评论的数据 | ||
| 23 | + commentsList = getAllCommentsData() | ||
| 24 | + commentData = [] | ||
| 25 | + for i in commentsList: | ||
| 26 | + if i[9] == topic: | ||
| 27 | + commentData.append(i) | ||
| 28 | + return commentData |
-
Please register or login to post a comment