zoukankan      html  css  js  c++  java
  • 垃圾邮件分类的预处理和标准化

    主要包括:

    • Lower-casing: The entire email is converted into lower case, so that captialization is ignored (e.g., IndIcaTE is treated the same as Indicate).
    • Stripping HTML: All HTML tags are removed from the emails.Many emails often come with HTML formatting; we remove all the HTML tags, so that only the content remains.
    • Normalizing URLs: All URLs are replaced with the text httpaddr".
    • Normalizing Email Addresses: All email addresses are replaced with the text emailaddr".
    • Normalizing Numbers: All numbers are replaced with the text umber".
    • Normalizing Dollars: All dollar signs ($) are replaced with the text dollar".
    • Word Stemming: Words are reduced to their stemmed form. For example, discount", discounts", discounted" and discounting" are all replaced with discount". Sometimes, the Stemmer actually strips additional characters from the end, so include", includes", included",and including" are all replaced with includ".
    • Removal of non-words: Non-words and punctuation have been removed. All white spaces (tabs, newlines, spaces) have all been trimmed to a single space character.

    对于的matlab代码,这简洁的!

    % Lower case
    email_contents = lower(email_contents);
    
    % Strip all HTML
    % Looks for any expression that starts with < and ends with > and replace
    % and does not have any < or > in the tag it with a space
    email_contents = regexprep(email_contents, '<[^<>]+>', ' ');
    
    % Handle Numbers
    % Look for one or more characters between 0-9
    email_contents = regexprep(email_contents, '[0-9]+', 'number');
    
    % Handle URLS
    % Look for strings starting with http:// or https://
    email_contents = regexprep(email_contents, ...
                               '(http|https)://[^s]*', 'httpaddr');
    
    % Handle Email Addresses
    % Look for strings with @ in the middle
    email_contents = regexprep(email_contents, '[^s]+@[^s]+', 'emailaddr');
    
    % Handle $ sign
    email_contents = regexprep(email_contents, '[$]+', 'dollar');

    来源:machine learning-Andrew Ng, https://www.coursera.org/learn/machine-learning/programming/e4hZk/support-vector-machines

  • 相关阅读:
    java使用google开源工具实现图片压缩
    MyBatis实现Mysql数据库分库分表操作和总结
    简单记录你博客园的访问人数
    细说spring事务配置属性
    hazelcast初探
    jstorm之于storm
    如何让其他机器访问你的oracle数据库
    问题解决:bash: fork: retry: Resource temporarily unavailable
    分布式锁的几种实现方式
    建立索引的原则总结
  • 原文地址:https://www.cnblogs.com/gui0901/p/5241753.html
Copyright © 2011-2022 走看看