最近有部綜藝——《演員請就位》第二季,三天兩頭一個熱搜,真是無比熱鬧,因為那句「郭敬明導演你看我的演技能值一個S卡」的調侃,我就入了這檔綜藝的坑,你別說這綜藝槽點還挺多,特別是五位導師,他們的戲比演員的精彩多了。《演員請就位》目前為止已經播出了兩季,第一季在豆瓣為6.8分,共有4萬餘人評分,第二季目前評分低於第一季,評分僅6.2分。本文通過爬取《演員請就位》第二季豆瓣短評(好評、中評和差評皆有抽樣),進行可視化分析和情感分析,完整代碼後臺回復「演員請就位」即可免費獲取。
可視化分析導演比演員討論的更多通過對所有評論進行詞雲圖繪製,我們發現導演提及次數超過演員,這不是演員養成類綜藝嗎?導演的料居然比演員還多。另外,我們還可以看出大家對這部綜藝褒貶不一,演技、喜歡等好評詞佔據一定比例,同時給出噁心、垃圾等差評詞的觀眾也不乏少數。
差評佔比超半數從評論分類來看,差評佔比55%,中評佔比21%,好評佔比24%。更多的觀眾對《演員2》不敏感,主要源自看過《演員1》所帶來的高期待與現實的落差較大,另外,郭敬明對何昶希發S卡行為也招致了不少罵名。
大多數觀眾在半夜發評論從評論時間分布來看,晚上10點至12點評論人數佔比27.89%。
好評難以獲贊5星好評僅獲得觀眾828個贊,反而1星差評獲得了3776個點讚。
郭敬明被提及次數最多從觀眾詞雲中提取《演員請就位2》的主要人物,我們發現郭敬明被觀眾提及次數最多,達319次。另外,李誠儒由於其犀利的點評廣受觀眾的熱議,金句味同嚼蠟,味如雞肋,如此乏味一度刷爆網絡,提及次數甚至高於趙薇導演。
情感分值0.4左右,且凌晨達到峰值不久之前,百度正式發布情感預訓練模型 SKEP (Sentiment Knowledge Enhanced Pre-training for Sentiment Analysis)。通過利用情感知識增強預訓練模型,SKEP 在 14 項中英情感分析典型任務上全面超越 SOTA。本次運用該模型對所有《演員請就位2》評論進行打分,我們發現一天內觀眾情感分值在0.4分上下波動,僅在凌晨5點左右達到一個較高的積極傾向。
技術實現數據獲取以下給出核心代碼:
def get_page_info(start_num,type):
url="https://movie.douban.com/subject/"+ movie_id +"/comments?percent_type="+type+"&start="+str(start_num)+"&limit=20&status=P&sort=new_score&comments_only=1&ck=myI8"
print(url)
header = {
"Accept":"application/json, text/plain, */*",
"Accept-Language":"zh-CN,zh;q=0.9",
"Connection":"keep-alive",
"Host":"movie.douban.com",
"User-Agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
"Cookie":'ll="118217"; bid=RljS46FQccw; __yadk_uid=GlresR4DtEXMJYz7UEJiEiW1jZGdHxV1; __gads=ID=4369b0a5596d1a14:T=1582470136:S=ALNI_MYu_5GhYfBddurehU-ZyUkLIHkXmw; viewed="34838905"; _vwo_uuid_v2=D57B8780A6D0B07688BCF1679FC9CC7CE|f58c953da6640ed67cf0c62ed4f1a076; douban-fav-remind=1; __utmv=30149280.21954; dbcl2="219542653:qAjjgVFgfE0"; ck=phh8; ap_v=0,6.0; push_noty_num=0; push_doumail_num=0; __utma=30149280.949109129.1582468791.1602402156.1605346877.20; __utmc=30149280; __utmz=30149280.1605346877.20.14.utmcsr=accounts.douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/passport/setting; __utmb=30149280.2.10.1605346877; _pk_ref.100001.4cf6=%5B%22%22%2C%22%22%2C1605346877%2C%22https%3A%2F%2Fwww.douban.com%2F%22%5D; _pk_ses.100001.4cf6=*; __utma=223695111.777887215.1582468791.1602402156.1605346877.16; __utmb=223695111.0.10.1605346877; __utmc=223695111; __utmz=223695111.1605346877.16.11.utmcsr=douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/; _pk_id.100001.4cf6=fff8ec9a5e905564.1582468791.16.1605347953.1602402156.'
}
response=requests.get(url,headers=header)
req_parser = BeautifulSoup(response.content.decode('unicode_escape'),features="html.parser")
comments = req_parser.find_all('div',class_="comment-item")
if __name__ =="__main__":
movie_id = input("請輸入電影id:")
comments_list=[]
times=25
n=1
types=['h','m','l']
for i in range(times):
print(i)
start_num=i*20
for j in range(3):
comments = get_page_info(start_num,type=types[j])
數據清洗導入數據import pandas as pd
df = pd.read_csv("/菜J學Python/豆瓣/35163988.csv")
df = df[['user_name','comment_voted','comment_voted','movie_star','comment_time','comment']]
df.head(10)
欄位類型轉換df['comment_time'] = pd.to_datetime(df['comment_time'])
df["comment"] = df["comment"].astype('str')
機械壓縮去重#定義機械壓縮函數
def yasuo(st):
for i in range(1,int(len(st)/2)+1):
for j in range(len(st)):
if st[j:j+i] == st[j+i:j+2*i]:
k = j + i
while st[k:k+i] == st[k+i:k+2*i] and k<len(st):
k = k + i
st = st[:j] + st[k:]
return st
yasuo(st="菜J學Python真的真的真的很菜很菜")#應用壓縮函數
df["comment"] = df["comment"].apply(yasuo)
情感分析#pip3 install paddlepaddle -i https://mirror.baidu.com/pypi/simple
import paddlehub as hub
#這裡使用了百度開源的成熟NLP模型來預測情感傾向
senta = hub.Module(name="senta_bilstm")
texts = df['comment'].tolist()
input_data = {'text':texts}
res = senta.sentiment_classify(data=input_data)
df['pos_p'] = [x['positive_probs'] for x in res]
數據可視化df['comment'] = df['comment'].astype('str')
# 定義分詞函數
def get_cut_words(content_series):
# 讀入停用詞表
stop_words = []
with open("./stop_words.txt", 'r', encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
stop_words.append(line.strip())
# 添加關鍵詞
my_words = ['', '']
for i in my_words:
jieba.add_word(i)
# 自定義停用詞
my_stop_words = ['節目', '中國','一部']
stop_words.extend(my_stop_words)
# 分詞
word_num = jieba.lcut(content_series.str.cat(sep='。'), cut_all=False)
# 條件篩選
word_num_selected = [i for i in word_num if i not in stop_words and len(i)>=2]
return word_num_selected
# 繪製詞雲圖
text1 = get_cut_words(content_series=df['comment'])
stylecloud.gen_stylecloud(text=' '.join(text1), max_words=200,
collocations=False,
font_path='字酷堂清楷體.ttf',
icon_name='fas fa-video',
size=653,
#palette='matplotlib.Inferno_9',
output_name='./演員2詞雲圖.png')
Image(filename='./演員2詞雲圖.png')聲明
1.本數據分析只做學習研究之用途,提供的結論僅供參考;2.作者對影視行業了解有限,相關描述可能存在不當之處,請勿上綱上線。