文本反垃圾是网络社区应用非常常见的任务。因为各种利益关系,网络社区通常都难以避免地会涌入大量*扰、色情、诈骗等垃圾信息,扰乱社区秩序,伤害用户体验。这些信息往往隐晦,多变,传统规则系统如正则表达式匹配关键词难以应对。通常情况下,文本反垃圾离不开用户行为分析,本章只针对文本内容部分进行讨论。
为了躲避平台监测,垃圾文本常常会使用火星文等方式对关键词进行隐藏。例如:
渴望 兂 极限 激情 恠 燃烧 加 涐 嶶 信 lovexxxx521
亲爱 的 看 頭潒 约
私人 企鹅 ⓧⓧⓧ㊆㊆⑧⑧⑧ 给 你 爽 你 懂 的
垃圾文本通常还会备有多个联系方式进行用户导流。识别异常联系方式是反垃圾的一项重要工作,但是传统的识别方法依赖大量策略,攻防压力大,也容易被突破。例如:
自啪 试平 n 罗辽 婊研 危性 xxxx447
自啪 试平 n 罗辽 婊研 危性 xxxxx11118
自啪 试平 n 罗辽 婊研 危性 xxxx2323
在这个实例中,我们将使用TensorLayer来训练一个垃圾文本分类器,并介绍如何通过TensorFlow Serving来提供高性能服务,实现产品化部署。这个分类器将解决以上几个难题,我们不再担心垃圾文本有多么隐晦,也不再关心它们用的哪国语言或有多少种联系方式。
第一步,训练词向量,相关代码在word2vec文件夹,执行步骤见word2vec/README.md。
第二步,训练分类器,相关代码在network文件夹,执行步骤见network/README.md。
第三步,与TensorFlow Serving交互,客户端代码在serving文件夹。