def testFeedTermReturnsTerm(self): model = Model() term = Term().createFromString("test") result = model.feedTerm(term) self.assertIsInstance(result, Term, "Result is not a Term")
def test_checkpoint(self): model1 = Model(checkpointDir=MODEL_CHECKPOINT_DIR) term = Term().createFromString("fox") for _ in range(5): prediction = model1.feedTerm(term) self.assertTrue(len(prediction.bitmap)) model1.save() model2 = Model(checkpointDir=MODEL_CHECKPOINT_DIR) model2.load() prediction = model2.feedTerm(term) self.assertTrue(len(prediction.bitmap))
def test_training(self): term0 = Term().createFromString("the") term1 = Term().createFromString("fox") term2 = Term().createFromString("eats") term3 = Term().createFromString("rodent") model = Model() prediction = model.feedTerm(term0) self.assertFalse(len(prediction.bitmap)) for _ in range(5): model.feedTerm(term1) model.feedTerm(term2) model.feedTerm(term3) model.resetSequence() model.feedTerm(term1) prediction = model.feedTerm(term2) self.assertEqual(prediction.closestString(), "rodent")