Exemplo n.º 1
0
  def testFeedTermReturnsTerm(self):
    model = Model()
    term = Term().createFromString("test")

    result = model.feedTerm(term)

    self.assertIsInstance(result, Term, "Result is not a Term")
Exemplo n.º 2
0
  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))
Exemplo n.º 3
0
  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))
Exemplo n.º 4
0
  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")
Exemplo n.º 5
0
  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")