AS02 Reading PTT data#
在這個作業中,老師給了你一個檔案的資料是g0v所搜集的PTT資料,是2020-01-02當天發佈在Gosshiping版上的貼文及其留言。該檔案用jsonl的方式儲存,每一行是一個json格式的資料,包含了該篇貼文的標題、作者、發文時間、內容、留言等等資訊。你的任務是讀取該檔案,並且回答出該天發文數最多的作者是誰,以及該作者發了幾篇貼文等問題。
Q1. Read jsonl file (10 points)#
該資料集中共包含幾篇貼文?(10 points)。請撰寫程式碼讀取jsonl資料,並將該檔案讀取到一個list或dict中。理想上,每篇貼文會是一個dict,而在貼文中,會有一個key對應到的value是comments,該comments也是一個list,裡面包含所有該貼文的comment。
# your code here
Q2. Number of posts and comments (10 points)#
印出該資料集中,共有幾篇貼文、幾篇留言?(10 points)
# your code
# print(f"Number of posts: {...}, Number of comments: {...}")
Q3. Metadata of posts and comments (10 points)#
該資料集中的貼文共有哪些欄位?留言共有哪些欄位?10分
# your code here
# print(f"Variables of posts: {...}, Variables of comments: {...}")
Q4. Unique posts (10 points)#
該資料集中共有幾位貼文者?(注意,可能同一位版友會張貼超過一篇文章)10分
# your code here
# print(f"Unique post authors: {...}")
Q5. Top 1 commentors (10 points)#
留言數最高的留言者是誰?10分
# your code here
# print(f"The top-1 active commentors: {...} with {...} comments")
Q6. Top-10 commentors (10 points)#
留言數最高的前10大留言者是誰?其分別發布了多少篇留言?20分
Print out the top 10 authors with the most comments. The output format is as follows:
Top 1: commentor_name, 100 comments
Top 2: commentor_name, 99 comments
# your code here