示例#1
0
        /// <summary>
        /// Initialize the SpamFilter based on the contents of the supplied text control list.
        /// </summary>
        /// <param name="good">Text control list containing non-spam</param>
        /// <param name="bad">Text control list  containing spam</param>
        public void Load(TextControlList good, TextControlList bad)
        {
            _good = good;
            _bad  = bad;

            CalculateProbabilities();
        }
示例#2
0
        /// <summary>
        /// Initialize the SpamFilter based on the supplied text
        /// </summary>
        /// <param name="goodReader">File containing non-spam</param>
        /// <param name="badReader">File containing spam</param>
        public void Load(TextReader goodReader, TextReader badReader)
        {
            _good = new TextControlList(goodReader);
            _bad  = new TextControlList(badReader);

            CalculateProbabilities();
        }
示例#3
0
        /// <summary>
        /// Initialize the SpamFilter based on a DataTable containing columns "IsSpam" and "Body".
        /// </summary>
        /// <param name="table">The data table containing the data.</param>
        public void Load(DataTable table)
        {
            _good = new TextControlList();
            _bad  = new TextControlList();

            foreach (DataRow row in table.Rows)
            {
                bool   isSpam = (bool)row["IsSpam"];
                string body   = row["Body"].ToString();
                if (isSpam)
                {
                    _bad.LoadFromReader(new StringReader(body));
                }
                else
                {
                    _good.LoadFromReader(new StringReader(body));
                }
            }

            CalculateProbabilities();
        }