Beispiel #1
0
        /// <summary>
        /// Initialize the SpamFilter based on the supplied text
        /// </summary>
        public void Load(TextReader goodReader, TextReader badReader)
        {
            _good = new Corpus(goodReader);
            _bad = new Corpus(badReader);

            CalculateProbabilities();
        }
Beispiel #2
0
        /// <summary>
        /// Initialize the SpamFilter based on the contents of the supplied Corpuseses
        /// </summary>
        public void Load(Corpus good, Corpus bad)
        {
            _good = good;
            _bad = bad;

            CalculateProbabilities();
        }
Beispiel #3
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            Corpus bad = new Corpus();
            Corpus good = new Corpus();
            bad.LoadFromFile("../../TestData/spam.txt");
            good.LoadFromFile("../../TestData/good.txt");

            _filter = new SpamFilter();
            _filter.Load(good, bad);

            txtOut.Text = String.Format("Good Count: {0} \nBad Count: {1} ",
                 _filter.Good.Tokens.Count,
                 _filter.Bad.Tokens.Count,
                 _filter.Prob.Count,
                 Environment.NewLine);
        }
        /// <summary>
        /// Initialize the SpamFilter based on a DataTable containing columns "IsSpam" and "Body".
        /// This is only useful to me the author, but hey, it's my code so I can do what I want!
        /// </summary>
        /// <param name="table"></param>
        public void Load(DataTable table)
        {
            _good = new Corpus();
            _bad  = new Corpus();

            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();
        }
Beispiel #5
0
        public void Load(DataTable table)
        {
            _good = new Corpus();
            _bad = new Corpus();

            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();
        }