예제 #1
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);


            // Just for grins, we'll dump out some statistics about the data we just loaded.
            txtOut.Text = String.Format(@"{0} {1} {2}{3}"
                                        , _filter.Good.Tokens.Count
                                        , _filter.Bad.Tokens.Count
                                        , _filter.Prob.Count
                                        , Environment.NewLine);

            // ... and some probabilities for keys
            foreach (string key in _filter.Prob.Keys)
            {
                if (_filter.Prob[key] > 0.02)
                {
                    txtOut.AppendText(String.Format("{0},{1}{2}", _filter.Prob[key].ToString(".0000"), key, Environment.NewLine));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes the natural language class
        /// </summary>
        /// <param name="spamfile">Spam words definition text file</param>
        /// <param name="goodfile">Good words definition text file</param>
        public NaturalLanguage(string spamfile, string goodfile)
        {
            Corpus bad  = new Corpus();
            Corpus good = new Corpus();

            t = new Translator();

            bad.LoadFromFile(spamfile);
            good.LoadFromFile(goodfile);

            filter = new SpamFilter();
            filter.Load(good, bad);
        }