我是怎麼分析一萬篇AO3文章的

寫在前面:

沸沸揚揚的227看來是告一段落了,這件事對我和豆醬的影響就是發現能發聲引起大家的討論和關注還是一件很有意思的事情,所以決定慢慢開始經營自己的號.基本保證每週更新一次.那我就儘量發揮我的優勢,跟大家講講代碼,聊聊技術.首先就把我在227文章和視頻的技術都和大家講個透徹.這裡總共是四大部分:

  1. 基於 selenium 的爬蟲,已經寫過一期文章,還會有一篇;
  2. 基於詞頻統計的數據分析,就是本文;
  3. 基於深度學習的 NLP 文本分類器;
  4. 基於OpenCV 的圖像視頻製作.

這就夠一個月了.新手初來乍到,謝謝大家支持.有什麼感興趣的可以評論或私信.我也會根據大家關係的東西寫哦~



對文本進行分析

上一篇文章中已經對相關庫進行簡要介紹,這裡我只列舉文本分析時使用到的庫.

BeautifulSoup: Html 標籤解析器 jieba: 中文分詞工具 wordcloud: 詞雲生成器 matplotlib: 科學繪圖庫 numpy: python數學運算庫 PIL: python圖像處理庫

matplotlib 使用時要注意中文顯示問題,matplotlib默認並不支持中文顯示,需要進行一些配置.

具體步驟是:

  1. 通過 matplotlib.matplotlib_fname() 命令找到 matplotlib 路徑;
  2. 將字體放在字體文件夾下,並修改配置文件
  3. 去掉 font.family , axes.unicode_minus 和 font.sans-serif 前的註釋符#,
  4. 在 font.sans-serif 中添加字體名稱(這裡是 simhei),把 axes.unicode_minus 的值改為 False.
  5. 刪掉 matplotlib 的緩存目錄

在使用 Jupyter notebook 時,需要注意添加魔法命令 %pylab inline.

<code>import sys
import re
import os
import time
from tqdm import tqdm

import numpy as np
# import pandas as pd
from bs4 import BeautifulSoup
import jieba #分詞
from wordcloud import WordCloud #詞雲
import matplotlib.pyplot as plt
import pylab
pylab.rcParams['font.family'] = 'simhei'
from PIL import Image
import time

%pylab inline/<code>

配置一些函數

然後定義幾個通用函數,包括:

  • 從文件中按行讀取(任意)詞;
  • 在文本中查找是否有敏感詞並返回;
  • 去除常用詞;
  • 創建詞雲.

提示一下大家,讀取詞表和檢查敏感詞的計數部分是有Bug的,如果詞表有重複的詞,則敏感詞會多記一次.這個在未來藉助 NLP 生成句子檢測器的工作中已經修復了.請大家注意一下.相關視頻已經放在 B站 和 頭條西瓜 有興趣的小夥伴可以去看

<code>#讀取詞表
def read_words_list(path):
with open(path) as f:
lines = f.readlines()

strlist = []
for l in lines:
if '#' != l[0] and '' != l.strip():
l = l.strip()
strlist.append(l)
return strlist

#查找敏感詞
def check_sens_words(text, sens_words):
ttext = text.strip()
sw_buf = [] #敏感詞
for sw in sens_words:
n = ttext.count(sw) #敏感詞出現次數
if n>0:
sw_buf.append([sw,n])
return sw_buf

#去除常用詞
def remove_stop_words(text, stop_words):
#保存過濾詞數量的字典
swords_cnt = {}

while " " in text: #去掉多餘空格

text = text.replace(' ', ' ')
for key, words in stop_words.items():
swords_cnt[key] = np.zeros(len(words)) #創建向量
for i,stpwd in enumerate(words):
if (stpwd) in text:
text = text.replace(' '+stpwd+' ', ' ')
# swords_cnt[key][i] += text.count(stpwd)
swords_cnt[key][i] += 1
return text, swords_cnt

#創建詞雲
def create_word_cloud(text, max_words, img_path=None):
wc = WordCloud(
font_path="./simhei.ttf",
max_words=max_words,
width=max_words*4,
height=max_words*4,
)
wordcloud = wc.generate(text)
#寫詞雲圖片
if img_path is not None:
wordcloud.to_file(img_path)
return wordcloud/<code>

讀取過濾詞和敏感詞

設置一些路徑和全局字典.這裡要提醒大家,使用的是jupyter做數據分析這種臨時的項目可以這麼玩.如果是正經的項目或者工程開發.千萬要寫配置文件進參數配置,而不是寫死在代碼裡.否則你會被同事和老闆diss的.

<code>#讀取過濾詞和敏感詞
stop_words_path = 'stop_words.txt'
bodypart_words_path = "stop_words_bodypart.txt"
color_words_path = "stop_words_color.txt"
motion_words_path = "stop_words_motion.txt"
orientation_words_path = "stop_words_orientation.txt"
role_name_words_path = "stop_words_role_name.txt"
site_words_path = "stop_words_site.txt"
thing_words_path = "stop_words_ting.txt"
title_words_path = "stop_words_title.txt"

stop_words = {}
stop_words["default"] = read_words_list(stop_words_path)
stop_words["bodypart"] = read_words_list(bodypart_words_path)
stop_words["color"] = read_words_list(color_words_path)
stop_words["motion"] = read_words_list(motion_words_path)
stop_words["orientation"] = read_words_list(orientation_words_path)
stop_words["role_name"] = read_words_list(role_name_words_path)
stop_words["site"] = read_words_list(site_words_path)
stop_words["thing"] = read_words_list(thing_words_path)
stop_words["title"] = read_words_list(title_words_path)

sens_words_path = 'sensitive_words.txt'
sens_words = read_words_list(sens_words_path)/<code>

數據分析函數

主要就是用正則表達式去除特殊標點,另外jieba分詞也是在這裡使用的

<code>#文本分析
def analyze_text(text):
#去標點符號
article_str = re.sub(r"[0-9\\s+\\.\\!\\/_,$%^*()?;;:-【】+\"\\']+|[+——!,;::。?、~@#¥%……&*()]+", " ", text)

#整理詞雲
article_str = " ".join(jieba.cut(article_str,cut_all=False, HMM=True))
#記總數
article_str_cnt = len(article_str.split())
#檢查敏感詞
sub_sens_word_buf = check_sens_words(article_str, sens_words)

#去除過濾詞
article_str, s_cnt = remove_stop_words(article_str, stop_words)

return article_str, article_str_cnt, s_cnt, sub_sens_word_buf/<code>

配置AO3的文章分析

這裡還是使用BeautifulSoup進行分析。我希望通過相應html標籤找到:

  • 分級文本(rating)
  • 點擊量(hits)
  • 發佈日期(published)
  • 正文(article)

本來還想提取主角信息來方面濾掉主角名稱。但是發現主角名似乎是js代碼獲取,並不好獲取,就放棄了。為了方便文章分析,用正則表達式吧有標點都替換成空格,並把正文中的 p 標籤和 br 標籤都替換為空格。後期在做NLP提取句子的時候,這裡有改動.增加了獲取的信息並且用標點預分割出句子.等寫到那裡的時候再跟大家說明,這裡Mark一下.

<code>base_path = "fulltext/"
ao3_pbar = tqdm(os.listdir(base_path))/<code>


<code>#提取ao3文章
def extract_ao3_work(html, stop_words, sens_words):
soup = BeautifulSoup(html, 'html.parser')
#提取分級標籤
rating_dd = soup.find('dd', attrs={'class': 'rating tags'}) #找到分級標籤
rating_a = rating_dd.find('a', attrs={'class': 'tag'}) #找到對應的a標籤
rating = rating_a.string #獲得標籤文字

stats_dd = soup.find('dl', attrs={'class': 'stats'})
#提取點擊量
hits_dd = stats_dd.find('dd', attrs={'class': 'hits'}) #找到分級標籤
try:
hits = int(hits_dd.string)
except AttributeError:
hits = 0


#提取發佈日期
published_dd = stats_dd.find('dd', attrs={'class': 'published'}) #找到分級標籤
date_str = published_dd.string

#提取文章
article_div = soup.find('div', attrs={'role': 'article'}) #找到文章標籤
article_userstuff = article_div.find('div', attrs={'class': 'userstuff'})
article_str = str(article_userstuff)
article_str = article_str.replace("
","")
article_str = article_str.replace("

","")
article_str = article_str.replace("
","")
article_str = article_str.replace("

"," ")
article_str = article_str.replace(""," ")
article_str = article_str.replace(" "," ")
article_str = article_str.replace("
"," ")

# print(article_str)
# time.sleep(3)
return rating, hits, date_str, article_str/<code>

在運行迭代前還要配置一些全局變量存儲需要分析的信息,還是那句老話,正經項目注意規範,不要這麼幹!

普及一下:首先如果公司或者參與的項目有相關的指導和規範就按照指導規範來.

如果沒有,儘量遵循以下原則:

  • 死數字儘量改為常量或宏(Python 沒有宏)並注意命名區分(通常是全大寫);
  • 常量儘可能通過配置文件傳入;
  • 儘量少用全局變量,使用類(class)把方法和變量封裝在一起;
  • 全局變量命名也需要區分(通常是全大寫);

在 python 語法裡 命名前面加"_"才是局部變量,通常創建的都是全局變量,而大家一般沒這個書寫習慣,特別是在使用 Jupyter 時,如果不 Restart 很容易混淆,需要特別注意.

<code>all_article_str = "" #所有文字
all_article_str_cnt = 0
sens_word_str = "" #包含的所有敏感詞
rating_article_dict = {} #按照分級保存的文字
rating_sens_word_dict = {} #按照分級保存的包含敏感詞
stop_cnt = {} #過濾詞的計數
for key, words in stop_words.items():
stop_cnt[key] = np.zeros(len(words)) #創建向量
date_cnt_dict = {} #發表時間字典,按月統計/<code>

對AO3文章進行拆分處理

這裡開始對文章進行依次處理.獲取後面生成圖表所需要的數據.具體步驟代碼中都有註釋,操作也比較簡單,各位自己看吧.

對於 python 的初學者囉嗦兩句:

  1. 認真學習 for 循環的精髓,善用 enumerate zip 等方法, range效率低且low;
  2. 善用字典和列表.列表和numpy的切片功能要掌握清楚,如果從C++等語言轉過來,你就知道Python這些功能真的是神方便;
  3. 分清軟拷貝和硬拷貝,不論那種語言這個都很重要.
<code>for work in ao3_pbar:
work_path = os.path.join(base_path,work)
with open(work_path) as f:
work_str = f.read() #讀取文章
rating, hits, date_str, article_str = extract_ao3_work(work_str, stop_words, sens_words)
article_str, artstr_cnt, sub_stop_cnt, sub_sens_word_buf = analyze_text(article_str)
all_article_str += article_str #所有文章文字融合
all_article_str_cnt += artstr_cnt #所有詞語數量加和

#統計日期2020-01-01,按月
date_elem = date_str.split("-")
month_date = date_elem[0]+"-"+date_elem[1]
if not date_cnt_dict.__contains__(month_date): #不存在分級則創建一個
date_cnt_dict[month_date] = 0
date_cnt_dict[month_date] += 1

#為每個過濾詞添加計數
for sc, sub_sc in zip(stop_cnt.values(), sub_stop_cnt.values()):
sc += sub_sc

#所有敏感詞融合
for swlist in sub_sens_word_buf:
for s in range(swlist[1]):
sens_word_str += swlist[0] + " "

#按標籤分類文章
if not rating_article_dict.__contains__(rating): #不存在分級則創建一個
# 文本,總詞數,文章數,總點擊量,無敏感詞文章數
rating_article_dict[rating] = ["",0,0,0,0]

# 敏感詞集合,總敏感詞數
rating_sens_word_dict[rating] = ["",0]

rating_article_dict[rating][0] += article_str + " "
rating_article_dict[rating][1] += artstr_cnt
rating_article_dict[rating][2] += 1
rating_article_dict[rating][3] += hits

sens_word_cnt = 0 #敏感詞計數
for swlist in sub_sens_word_buf:
for s in range(swlist[1]): #敏感詞重複也計入
rating_sens_word_dict[rating][0] += swlist[0] + " "
rating_sens_word_dict[rating][1] += 1
sens_word_cnt += 1

#敏感詞小於一定數量
if sens_word_cnt < 5:
rating_article_dict[rating][4] += 1/<code>

分級標籤佔比

AO3總體中文文章比例:大眾向2萬8千篇;青少2萬4千篇;成人8萬1千篇;激烈4萬8千篇;未分級6萬3千篇。對比抽取樣本的比例和總體比例,樣本分佈還是基本滿足均勻分佈的。

截止發文時間,AO3有共有中文文章:244595篇,抽取中文文章數量:12066篇

詳細的內容說明大家去看我的頭條文章或者豆醬的知乎文章即可,我就不復述了.

代碼詳解: 在jupyter 中使用 plt 繪製圖片時經常遇到圖太小的問題.可以使用: plt.figure(figsize=(15,15)) 解決.這裡使用 餅圖 pie 來繪製,這個圖表比較簡單,就沒有做複雜的標籤.一些複雜操作,後面的圖我會分別和大家介紹.

<code>#分級標籤
tags = [k for k in rating_article_dict.keys()]
#數值:文章數 2
values = [v[2] for v in rating_article_dict.values()]

#繪製餅圖
plt.figure(figsize=(15,15))
plt.pie(x=values, labels=tags)
plt.show()

for t,v in zip(tags, values):
print(t+" "+str(v*100.0/np.sum(values))+"%")/<code>


我是怎麼分析一萬篇AO3文章的

寫作時間統計

我將中文文章寫作時間按月統計,注意這個曲線是當月發佈的數量,而不是累加值.

這裡在之前的爬蟲實踐中有個風險.由於爬蟲使用了 AO3 的搜索引擎,無法確保AO3是否使用了搜索優化算法來影響結果,造成偏差.如果有,那麼最容易受影響的就是時間統計. 解決這個問題的方法也比較簡單.使用 numpy 的 shuffle 打亂頁碼基本就可以避免這個問題.

首先獲取當前時間的年月,並且去掉,因為本月沒有過完,不能反應全月的數字.因為文章統計使用字典保存的,去除當前月的操作相當簡單.文章的寫作時間是離散的,並且月份是12進制,所以進行統計時,將年份作為整數,月份除以12作為小數部分作為統計即可.最後要注意按照時間順序使用 np.argsort (輸出的是下標順序) 進行排序,否則折線圖是亂的.

<code>#時間標籤處理
#刪掉當前月份發佈的文章以免影響趨勢判斷
mounth_now = time.strftime('%Y-%m',time.localtime(time.time()))
if rating_article_dict.__contains__(mounth_now):
print("Contain: "+mounth_now)
rating_article_dict.pop(mounth_now)
else:
print(mounth_now+" Not Contained ")
times = []
conts = []

for k,v in date_cnt_dict.items():
k_elem = k.split("-")
times.append(float(k_elem[0])+float(k_elem[1])/12)
conts.append(v)

sorted_times = []
sorted_conts = []
sortindex = np.argsort(times)
for i in range(len(times)):
sorted_times.append(times[sortindex[i]])
sorted_conts.append(conts[sortindex[i]])

plt.figure(figsize=(15,15))
plt.plot(sorted_times, sorted_conts)
plt.show()/<code>


我是怎麼分析一萬篇AO3文章的

無敏感詞文章統計

這張圖繪製的元素是比較多的.可以重點注意一下每個條形圖上的數字標籤是如何生成的. 另外就是圖例函數 plt.legend 中 loc=2 表示 左上角. best (0) 會在右上角遮住 Mature 的條形圖.

這裡的小 Tip 是關於字符串的格式化輸出,一般有3種: .format 百分號% 和 str()函數直接加.我一般用第一種和最後一種,看大家的喜好了.

<code>#分級標籤
tags = [k for k in rating_article_dict.keys()]
#數值:文章數 2 無敏感詞文章數 4
values0 = [v[4] for v in rating_article_dict.values()]
values1 = [v[2] for v in rating_article_dict.values()]

#畫條形圖
x = np.arange(len(tags))
bar_width = 0.3

plt.figure(figsize=(15,15))
plt.xticks(fontsize=18,rotation=-45)
plt.yticks(fontsize=30)
a = plt.bar(x, values0, 0.4, color='dodgerblue', label='無敏感詞文章數', align='center')
b = plt.bar(x + bar_width, values1, 0.4, color='orangered', label='總文章數', align='center')
# 設置標籤
for i,j in zip(a,b):
ih = i.get_height()
jh = j.get_height()
plt.text(i.get_x()+i.get_width()/3, ih, '{}|{:.3}%'.format(int(ih),float(ih)*100/float(jh)), ha='center', va='bottom')
plt.text(j.get_x()+j.get_width()/2, jh, '{}'.format(int(jh)), ha='center', va='bottom')

plt.xticks(x,tags)
plt.legend(loc=2)
plt.show()/<code>


我是怎麼分析一萬篇AO3文章的

敏感詞數量的分佈

敏感詞分佈繪圖沒什麼好說的,這裡被大家指出敏感詞庫有一些問題,後來經過我手工挑選做了一個新的敏感詞庫.並且包含了英文敏感詞.已經上傳到Github上,大家可以去下載.不怕瞎的可以閱讀一下.

暴力次品統計也是被大家詬病比較多的一個點.雖然我在文章中也提示了,但是按時引起了爭議.因此後續我改用了深度神經網絡訓練了一個NLP文本分類器專門鑑別

敏感句.並且把句子都摘出來做成了視頻.知乎不能上傳,有興趣的小夥伴可以到 B站 或者 頭條 去看.

<code>#分級標籤
tags = [k for k in rating_article_dict.keys()]
tags.append("All")
#數值:敏感詞數 除以 總詞數
values = [v[1]/s[1] for v,s in zip(rating_sens_word_dict.values(), rating_article_dict.values())]
values.append(len(sens_word_str.split())/all_article_str_cnt)
#畫條形圖
plt.figure(figsize=(15,15))
plt.xticks(fontsize=18,rotation=-45)
plt.yticks(fontsize=30)
plt.bar(tags, values)
for a,b in zip(tags, values):
plt.text(a, b+0.0001, '{:.3}%'.format(b*100), ha='center', va='bottom')/<code>


我是怎麼分析一萬篇AO3文章的

創建並顯示詞雲

詞雲顯示這裡比較出彩的就是敏感字替換了,先前我自己寫代碼時,詞雲已經被我替換的面目全非了.但是豆醬提出這樣不能夠對大家造成衝擊,於是直接使用拼音首字母替換了.其中一個有趣的工作就是用 utf8 編碼對很H的字進行替換.大家可以自己看看被 utf8 遮住的是什麼字.

<code>def harm_text(text, ignore=False):
if ignore:
return text
hrmonious = {}
#不需要請註釋下方
hrmonious['\\\\\\u5988'.encode('utf-8').decode('unicode_escape')] = 'M'
hrmonious['\\\\\\u5c04'.encode('utf-8').decode('unicode_escape')] = 'S'
hrmonious['\\\\\\u5a4a'.encode('utf-8').decode('unicode_escape')] = 'B'
hrmonious['\\\\\\u75f4'.encode('utf-8').decode('unicode_escape')] = 'C'
hrmonious['\\\\\\u4e73'.encode('utf-8').decode('unicode_escape')] = 'R'
hrmonious['\\\\\\u5978'.encode('utf-8').decode('unicode_escape')] = 'J'
hrmonious['\\\\\\u6027'.encode('utf-8').decode('unicode_escape')] = 'X'
hrmonious['\\\\\\u88f8'.encode('utf-8').decode('unicode_escape')] = 'L'
hrmonious['陰'] = 'Y'
hrmonious['\\\\\\u7a74'.encode('utf-8').decode('unicode_escape')] = 'X'
hrmonious['\\\\\\u8361'.encode('utf-8').decode('unicode_escape')] = 'D'
hrmonious['雞'] = 'J'
hrmonious['\\\\\\u830e'.encode('utf-8').decode('unicode_escape')] = 'J'
hrmonious['\\\\\\u6deb'.encode('utf-8').decode('unicode_escape')] = 'Y'
hrmonious['\\\\\\u6170'.encode('utf-8').decode('unicode_escape')] = 'W'
hrmonious['高'] = 'H'
hrmonious['愛'] = 'A'
hrmonious['頭'] = 'T'
hrmonious['內'] = 'N'
hrmonious['插'] = 'C'
hrmonious['情'] = 'Q'
hrmonious['春'] = 'C'
hrmonious['\\\\\\u9f9f'.encode('utf-8').decode('unicode_escape')] = 'G'
hrmonious['脫'] = 'T'
hrmonious['教'] = 'J'
hrmonious['做'] = 'D'

hrmonious['陽'] = 'Y'
hrmonious['潮'] = 'C'
hrmonious['呻'] = 'S'
hrmonious['摩'] = 'M'
hrmonious['交'] = 'J'
hrmonious['下'] = 'X'
hrmonious['抽'] = 'C'
hrmonious['感'] = 'G'
hrmonious['色'] = 'C'
hrmonious['液'] = 'Y'
hrmonious['調'] = 'T'
hrmonious['水'] = 'S'
hrmonious['按'] = 'A'
hrmonious['道'] = 'D'
hrmonious['叫'] = 'J'
hrmonious['激'] = 'J'
hrmonious['\\\\\\u68d2'.encode('utf-8').decode('unicode_escape')] = 'B'
hrmonious['體'] = 'T'
hrmonious['嫩'] = 'N'
hrmonious['肉'] = 'R'
hrmonious['絲'] = 'S'
hrmonious['吟'] = 'Y'
hrmonious['庭'] = 'T'
hrmonious['奶'] = 'N'
hrmonious['屁'] = 'P'
#不需要請註釋上方

for k,v in hrmonious.items():
text = text.replace(k,v)
return text

def code_utf8(dic):
for key in dic.keys():
uc = key.encode('unicode_escape').decode('utf-8')
print(key + " || " + uc + " || " + uc.encode('utf-8').decode('unicode_escape'))

#code_utf8(hrmonious)/<code>


<code>print("#創建文章所有詞雲")
all_wc = create_word_cloud(harm_text(all_article_str), 500) #"wordcloud.jpg"
plt.figure(figsize=(15,15))
plt.imshow(all_wc)
plt.axis("off")

plt.title("文章所有詞語的詞雲")
plt.show()
print("#創建文章所有敏感詞的詞雲")
sens_wc = create_word_cloud(harm_text(sens_word_str),100) #"sens_wordcloud.jpg"
plt.figure(figsize=(15,15))
plt.imshow(sens_wc)
plt.axis("off")
plt.title("文章敏感的詞雲")
plt.show()
print("#創建分級文章所有詞雲")
for k, word in rating_article_dict.items():
r_all_wc = create_word_cloud(harm_text(word[0]), 500) #k+"_wordcloud.jpg"
plt.figure(figsize=(15,15))
plt.imshow(r_all_wc)
plt.axis("off")
plt.title(k+" 的詞雲")
plt.show()
print("#創建分級文章敏感詞的詞雲")
for k, sens in rating_sens_word_dict.items():
r_sens_wc = create_word_cloud(harm_text(sens[0]), 100) #k+"_sens_wordcloud.jpg"
plt.figure(figsize=(15,15))
plt.imshow(r_sens_wc)
plt.axis("off")
plt.title(k+" 的敏感詞的詞雲")
plt.show()/<code>

這裡只放一張圖


我是怎麼分析一萬篇AO3文章的

點擊率對比

剩下的基本都是重複工作了,我就不再贅述,這裡就貼兩個代碼和圖了事.

<code>#分級標籤
tags = [k for k in rating_article_dict.keys()]
#數值:文章數 2 總點擊量 3
values = [v[3]/v[2] for v in rating_article_dict.values()]

#畫條形圖
plt.figure(figsize=(15,15))
plt.xticks(fontsize=18,rotation=-45)
plt.yticks(fontsize=30)
plt.bar(tags, values)
# for a,b in zip(tags, values):
# plt.text(a, b+0.0001, '{:.3}%'.format(b*100), ha='center', va='bottom')/<code>


我是怎麼分析一萬篇AO3文章的

主角統計

平臺喜歡的主角名稱,只取了排名Top30。

<code>#拆分數據
keys = list(stop_words['role_name'])
values = list(stop_cnt['role_name'])

#數據過多取排名靠前的數據
sub_keys = []
sub_values = []
sortindex = np.argsort(values)[::-1][:30]
for i in sortindex:
sub_keys.append(keys[i])
sub_values.append(values[i])

#畫條形圖
plt.figure(figsize=(15,15))
plt.xticks(fontsize=13,rotation=-70)
plt.yticks(fontsize=20)
plt.bar(sub_keys, sub_values)/<code>


我是怎麼分析一萬篇AO3文章的

橫向對比

最後的橫向對比實際就是拿了 《羊脂球》、《百年孤獨》、《紅樓夢》、《金瓶梅》 四篇文章進行一個對照.這裡代碼就是把前面的東西再跑一遍.只是點擊率,日期是無法統計的,分級標籤替換為書名,書的內容不需要html處理。其餘數據分析與上面一致。我就不再說明了.

我主要闡述一下這裡的問題:

4篇文章對比1萬2千多篇文章是沒有太大對比性的.很多小夥伴都提出了這個問題.這個也是文中最大的邏輯Bug.解決方案很簡單.取國內合規網文或同人文的語料,規模大致與這個1萬2千篇規模相當.按照上面的步驟跑一遍即可.我在文章中也有提到過四篇對比就是一個拋磚引玉的工作.

這個事情在當時,不論做不做都對文章結論影響不大所以就沒做大規模對比了.結果沒想到居然還被揪出來diss.再加上後來豆醬又15天不能說話.索性就把.NLP 句子識別做出來了.而且是弄了600篇直接把檢測句子貼出來.因為我們發現真的很少人去仔細看文.就是欺負大家看不到AO3的內容.

視頻在 B站 和 頭條西瓜 上都有.那個數據的代碼和技術分析我也會陸續發出來.(上班周更黨大家理解下)(PS:我上週就把深度學習的代碼push上去了,結果今天寫文檢查代碼庫的時候發現上傳錯了,把珍藏的殺手鐧搞上去了,不過估計也用不上了,我也不會撤掉,是啥大家自己去看吧.視頻相關的代碼我會在明天再整理一下上傳)



寫在最後

實際上我並不是從事數據分析專業工作的,做這些完全是正好想學習+玩,又正好碰上豆醬關注這個事情.不論227對大家有什麼影響,反正對我是受益良多的.

我也希望我能引起小夥伴們的興趣,一起加入學習探索.實際上編程開發的樂趣是一個創造和探索的樂趣.這與這個紛紛擾擾的社交世界是完全不同的體驗.也希望我做的工作除了引發更多口水外也能真正幫助到大家.


分享到:


相關文章: