# Update 2021.05.28 ## 改變點 1. 測試training data 長字影響 => 些微影響,選擇移除長字 train data 2. 調整 `url`/`account`/`phone number` 正則表示式偵測 3. 濾除符號 4. 打包程式測試 ## 移除長字測驗 移除 training data 中長度超過 10 的詞彙,並重 train model 與 保留長字 model 比較 ### Information * Test data: `new word dataset_add label_normal name_default_Ground truth_Corrected_prohibit_fixed_0525.csv` * remove long word model: `text_cnn_best_99.9_LR0.001_BATCH100_EPOCH100` * model: `text_cnn_best_99.81699346405229_LR0.001_BATCH100_EPOCH100` ### result | | 保留長字 | 移除長字 | | ----- | -------- | -------- | | model | `text_cnn_best_99.8` | `text_cnn_best_99.9` | | Accuracy | 0.9992 | 0.9984 | | error | 短: 44 (個) | 短:30 / 長:63 (個) | #### remove long word model * predict error number: 93 accuracy: 0.9984787018255578 ``` predict 0 1 2 3 4 5 correct 0 50675 8 1 4 1 3 1 25 3766 2 8 1 0 2 6 0 542 0 0 0 3 4 3 2 3216 2 0 4 7 0 0 3 2335 1 5 3 1 0 8 0 505 ``` #### 短字 predict error: 30個 ``` P: 0 L: 1 李晓峰 P: 0 L: 1 馿 P: 0 L: 1 一中一台 P: 0 L: 1 王雪冰 P: 0 L: 1 李文斌 P: 0 L: 1 李小鹏 P: 0 L: 1 回忆六四 P: 0 L: 1 毛贼 P: 0 L: 2 nmd P: 0 L: 2 撡 P: 0 L: 2 nmsl P: 0 L: 2 塞你公 P: 0 L: 2 shits P: 0 L: 2 shit P: 0 L: 4 脚交 P: 0 L: 4 足交 P: 0 L: 4 jj P: 0 L: 4 催情液 P: 1 L: 0 光阴似箭 P: 1 L: 0 性教官 P: 1 L: 0 q奸 P: 1 L: 5 coinn P: 2 L: 0 肮脏社徻 P: 3 L: 1 金 P: 3 L: 5 高价 P: 3 L: 1 清真 P: 5 L: 0 收货 P: 5 L: 0 黄金会员 P: 5 L: 0 卖软件 P: 4 L: 0 穴猡 ``` #### 長字 predict error: 63 個 ``` P: 0 L: 1 具有中国特色的魔鬼辞典 P: 0 L: 1 写给十七大人大代表一封信 P: 0 L: 1 传中共中央关于17大的人事安排意见 P: 0 L: 1 让国人愤怒的第二代身份证 P: 0 L: 1 gongchandang P: 0 L: 1 日本大使馆0R409游行 P: 0 L: 1 开除党籍 P: 0 L: 1 告中国人民解放军广大官兵书 P: 0 L: 1 让国人愤怒的第二代身分证 P: 0 L: 1 chairmanmao P: 0 L: 1 传说的胡曾联手是一种假象 P: 0 L: 1 从陈良宇倒台看中国政局走势 P: 0 L: 1 communistparty P: 0 L: 1 zhouyongkang P: 0 L: 1 tinyurl.com P: 0 L: 1 漠视生命自私到了极点的中共政权 P: 0 L: 1 史上最强阵容的中国国家领导人 P: 0 L: 3 记者原子弹的DIY制作 P: 0 L: 3 零风险 小投资 有胆量 P: 0 L: 3 diamorphine P: 0 L: 3 猪哥6合网中国网址联盟 P: 0 L: 4 一个妓女的年度总结报告 P: 0 L: 4 包养情妇12项吉尼斯排名 P: 0 L: 4 高树玛利亚ed2k:// P: 0 L: 5 警察我们是为人民服务的 P: 0 L: 5 一元硬币 版本为最新版本 P: 0 L: 5 "一元硬币" "游戏机上分" P: 1 L: 0 2006年十句最真实的谎言 P: 1 L: 0 不是易非毁责。志空服金生 P: 1 L: 0 急聘兼职打字员 P: 1 L: 0 军队干部转业复员工作文档汇编 P: 1 L: 0 马家爵的一句话让在场警察都落泪 P: 1 L: 3 工字汽狗,汽狗,麻醉枪 P: 1 L: 3 世界基督教统一神灵协会 P: 1 L: 3 冰毒的真正卖家 冰毒什麽价格 P: 2 L: 1 当代中国无耻语录排行榜 P: 2 L: 1 是束告项瓷,害电突网解 P: 2 L: 3 销售/专卖/买卖77式手枪 P: 2 L: 3 办证件文凭 高仿真假证件 P: 3 L: 0 时期打了几次我再次哦唯 P: 3 L: 0 关于对敌斗争中有关政政策界限汇编 P: 3 L: 0 关于做好定案材料工作的意见 P: 3 L: 0 索尼VGN-TX57CN P: 3 L: 1 公开信胡书记空中民主墙 P: 3 L: 1 解放军的最新式军服=>*@* P: 3 L: 1 恐怖分子 第一步 炸弹 P: 3 L: 1 确保党国家机密安全规定 P: 3 L: 1 对中共的姑息就是对死难者的残忍 P: 3 L: 1 《目睹中国改革开放28年之怪现状》 P: 3 L: 4 情色帖图成人漫画性爱图片 P: 3 L: 4 成人图片激情图片情色图片 P: 3 L: 4 AIKA (AV女優) P: 3 L: 5 765.brainchip.biz P: 3 L: 5 一元硬币 仿真度超过HD90版 P: 3 L: 5 热售英语四六级考试答案 P: 3 L: 5 一元硬币 最新版本 钢芯镀镍 P: 3 L: 5 一元硬币 "版本为最新版本" P: 3 L: 5 一元硬币 "游戏机上分" P: 3 L: 5 上网文凭QQ 教育服务 P: 4 L: 1 上海市劳动和社会保障局违规使用社保资金 P: 4 L: 3 冰毒的真正賣傢 冰毒什麼價格 P: 4 L: 3 出售冰毒黄牙签 冰糖 K粉 P: 5 L: 4 卫星天线接收器成人频道 ``` ### model (保留長字) * predict error number: 44 accuracy: 0.9992802460249951 ``` predict 0 1 2 3 4 5 correct 0 50675 8 1 4 1 3 1 25 3766 2 8 1 0 2 6 0 542 0 0 0 3 4 3 2 3216 2 0 4 7 0 0 3 2335 1 5 3 1 0 8 0 505 ``` #### Total: 44 個 ``` P: 0 L: 1 兵变 P: 0 L: 1 俄国 P: 0 L: 1 连胜德 P: 0 L: 1 耶稣 P: 0 L: 1 馿 P: 0 L: 1 中办发 P: 0 L: 1 郑建源 P: 0 L: 1 高官子女 P: 0 L: 1 浙江省 P: 0 L: 2 撡 P: 0 L: 2 我妳老爸 P: 0 L: 3 杀奸 P: 0 L: 3 追杀 P: 0 L: 3 轮奸 P: 0 L: 3 娱乐城 P: 0 L: 3 自爆 P: 0 L: 4 爱爱 P: 0 L: 4 星光伴我淫 P: 0 L: 4 兽性 P: 0 L: 4 体位 P: 0 L: 4 大波 P: 0 L: 4 自拍 P: 0 L: 4 渚 P: 0 L: 4 潮喷 P: 0 L: 4 原味 P: 0 L: 4 奶头 P: 0 L: 4 白石瞳 P: 0 L: 4 大屌 P: 0 L: 4 自摸 P: 0 L: 4 白石茉莉奈 P: 0 L: 4 星崎未来 P: 0 L: 5 荬 P: 1 L: 0 三二二攻台作战 P: 1 L: 2 pussy P: 2 L: 0 買幣 P: 3 L: 0 佛祖 P: 4 L: 0 梭哈 P: 4 L: 0 奸狡 P: 4 L: 0 鲍伊 P: 4 L: 0 奸徒 P: 4 L: 2 奸刁 P: 4 L: 2 奸夫淫妇 P: 5 L: 0 还有币 P: 5 L: 2 日他 ``` ### 結論 移除長字的 model 對整句長字判斷效果不好(預料之內), 但對短字的 predict error 以 `30` 為幅 優於 保留長字的 `44`, 故可以採用移除長字的版本(因為長字之後會拿去過 rule-base 及斷詞) ## 調整 url/account/phone number 正則表示式偵測 ### 原版 * account: `'[::]?[ ]?([a-zA-Z0-9]{6,})` * url: `'[a-zA-Z0-9]+.[a-zA-Z]+'` ### 調整後 * account: `[::VvxWvw微薇徽]+[\.\、\( ]*[ ]*[a-zA-Z0-9@]{6,}` (`::VvxWvw微薇徽.、 ` 後加六碼以上英數) * url: `'[a-zA-Z0-9]+\.[a-zA-Z]+'` (英數點英數 篩選出可能) * phone `[0-9]{11}` (11碼以上數字) ## 濾除符號 & 數字轉換 ### 濾除符號 在偵測完帳號/電話/網址後 將所有符號濾除再斷詞 ``` re.sub('\W+', '', message).replace("_", '') ``` ### 數字轉換 將全形或是數字上下標轉換完正常數字後 使 帳號/電話/網址 偵測抓的到  ## 打包程式測試 ### model * Train data: `new word dataset_add label_normal name_default_Ground truth_Corrected_prohibit_fixed_0528_remove long word.csv` * information ``` Training data: 60982 0 50635 1 3772 3 3180 4 2339 2 551 5 505 ``` * model: `text_cnn_best_99.88360655737705_LR0.001_BATCH100_EPOCH100` ### 流程 (方法D: 先掃 rule base 後再斷詞 predict) * 1.偵測 帳號/電話/url * 2.rule base 檢查 * 3.不在 rule base 的字,統一斷詞 -> predict (避免重複 predict 一樣的字) * 4.輸出 ### result (涉政/辱罵/違禁/色情/廣告) * model: `text_cnn_best_99.88360655737705_LR0.001_BATCH100_EPOCH100` * batch = 10 #### Time(單位:秒) | 類別 | 筆數 | colab | 打包(urlExtrator) | 打包(re) | no batch (re) | final | | ---- | ---- | ----- | ----------------- | -------- | ------------- | --- | | 涉政 | 1736 | 373 | 168 | 156 | 159 | 188 | | 辱罵 | 299 | 48 | 32 | 30 | 28 | 30 | | 違禁 | 1181 | 405 | 122 | 113 | 109 | 103 | | 色情 | 415 | 114 | 47 | 45 | 42 | 43 | | 廣告 | 5786 | 35 | 17 | 15 | 14 | 16 | #### Accuracy | 類別 | 筆數 | 5/23 | 打包(urlExtrator) | 打包(re) | final | | ---- | ---- | ---- | ----------------- | --------| --- | | 涉政 | 1736 | 0.77 | 0.911 | 0.911 | **0.942** | | 辱罵 | 299 | 0.82 | 0.906 | **0.906** | 0.903 | | 違禁 | 1181 | 0.80 | 0.922 | 0.922 | **0.959** | | 色情 | 415 | 0.61 | 0.812 | 0.812 | **0.884** | | 廣告 | 5786 | 0.99 | 0.996 | 0.997 | **0.997** | * 註 ``` [final 沒抓到的] n m l g b: 0 L S P: 0 FuckYou: 0 ``` #### Analysis ##### regular vs urlExtrator 相差七個 ``` 猴爷v.lei684872 (已修正 account regular expression) v.perhaps975 (已修正 account regular expression) -S.Li (url regular expression 會抓到) www.hotmail_hd.com (若有 '_',urlExtrator 抓不到) (以下3個 urlExtrator 抓不到) www.baidu.com.shadu.ttghjdgsdtesyt.gtuturt47kjgfs.bhbfgseiuufyftd.ukydrtsgkugiudutdcgch.yjfutdtdikhkjgkgj.j www.baidu.com.movie.google.com.v.21cn.fsgsddk566585fdjhdu559594hfghjdgkdcom.tudou.com.zhong- www-ksdx.com-com-www-sddxf.org- ``` ``` dataset amount after removing official messages: 1754 dataset amount after removing duplicate messages: 1736 涉政 spend time: 188.07523608207703 Predict 0 1 2 3 5 All label 1 22 1377 14 16 15 1444 3 5 28 0 259 0 292 All 27 1405 14 275 15 1736 Accuracy: 0.9423963133640553 Error amount: 100 / 1736 dataset amount after removing official messages: 5287 dataset amount after removing duplicate messages: 299 辱罵 spend time: 30.32499885559082 Predict 0 1 2 4 5 All label 2 12 6 270 10 1 299 All 12 6 270 10 1 299 Accuracy: 0.903010033444816 Error amount: 29 / 299 dataset amount after removing official messages: 1183 dataset amount after removing duplicate messages: 1181 違禁 spend time: 103.24421191215515 Predict 0 1 2 3 4 5 All label 3 11 5 1 1132 5 27 1181 All 11 5 1 1132 5 27 1181 Accuracy: 0.9585097375105842 Error amount: 49 / 1181 dataset amount after removing official messages: 415 dataset amount after removing duplicate messages: 415 色情 spend time: 43.73959398269653 Predict 0 1 2 3 4 5 All label 4 5 1 10 25 367 7 415 All 5 1 10 25 367 7 415 Accuracy: 0.8843373493975903 Error amount: 48 / 415 dataset amount after removing official messages: 10000 dataset amount after removing duplicate messages: 5786 廣告 spend time: 16.227789878845215 Predict 0 4 5 All label 5 14 1 5771 5786 All 14 1 5771 5786 Accuracy: 0.9974075354303491 Error amount: 15 / 5786 ``` ### 0/1 Test result 僅分類 0(正常) / 1 (ban) * Test dara: `all word test.csv` * 組成 ``` 涉政 / 辱罵 / 違禁 / 色情 / 廣告 + 三篇報導斷詞後當作正常資料 ``` #### Accuracy & Time ``` all word test spend time: 650.6240425109863 Predict 0 1 All label 0.0 2262 59 2321 1.0 68 9374 9442 All 2330 9433 11763 Accuracy: 0.9891193471608296 Error amount: 128 / 11764 ``` #### predict result file https://drive.google.com/drive/folders/1jjvKNSpWdfMXLMQScW-BT1DRbhyfLCTr?usp=sharing * all word test https://docs.google.com/spreadsheets/d/1x5LPGucxV4Q0UAtDRLgqteKkVsZg5n5hk4inMph-pXQ/edit?usp=sharing
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up