public void TestClassify()
        {
            var wds = new SimpleWordsDataSource();
            var classifier = new BayesianClassifier(wds);

            var sentence = new[] { "This", "is", "a", "sentence", "about", "java" };

            Assert.AreEqual(IClassifierConstants.NEUTRAL_PROBABILITY, classifier.Classify(ICategorizedClassifierConstants.DEFAULT_CATEGORY, sentence), 0d);

            wds.SetWordProbability(new WordProbability("This", .5d));
            wds.SetWordProbability(new WordProbability("is", .5d));
            wds.SetWordProbability(new WordProbability("a", .5d));
            wds.SetWordProbability(new WordProbability("sentence", .2d));
            wds.SetWordProbability(new WordProbability("about", .5d));
            wds.SetWordProbability(new WordProbability("java", .99d));

            Assert.AreEqual(.96d, classifier.Classify(ICategorizedClassifierConstants.DEFAULT_CATEGORY, sentence), .009d);
        }
        public void TestCalculateOverallProbability()
        {
            var prob = 0.3d;
            var wp1 = new WordProbability("myWord1", prob);
            var wp2 = new WordProbability("myWord2", prob);
            var wp3 = new WordProbability("myWord3", prob);

            var wps = new[] { wp1, wp2, wp3 };
            var errorMargin = 0.0001d;

            var xy = (prob * prob * prob);
            var z = (1-prob)*(1-prob)*(1-prob);

            var result = xy/(xy + z);

            var classifier = new BayesianClassifier();

            Assert.AreEqual(result, classifier.CalculateOverallProbability(wps), errorMargin);
        }