def testFCount(self): c = Classifier(getwords) c.incf("hello", "Good") c.incf("hello", "Good") c.incf("hello", "Bad") self.assertEqual(c.fcount("hello", "Good"), 2) self.assertEqual(c.fcount("hello", "Bad"), 1) self.assertEqual(c.fcount("wurst", "Bad"), 0)
def testTrain(self): c = Classifier(getwords) item = "Hello hello world, my name is Python." cat = "Good" c.train(item, cat) self.assertEqual(c.catcount("Good"), 1) self.assertEqual(c.fcount("hello", "Good"), 1) self.assertFalse(c.fc.has_key("my"))