def test_is_question(self): input1 = "how much is pish tegj glob glob ?" input2 = "how many Credits is glob prok Silver ?" input3 = "pish pish Iron is 3910 Credits" tars = TARS() self.assertTrue(tars.is_question(input1)) self.assertTrue(tars.is_question(input2)) self.assertFalse(tars.is_question(input3))
def test_learn(self): input1 = "glob is I" input2 = "glob glob Silver is 34 Credits" tars = TARS() tars.learn(input1) self.assertEquals(tars.get("NUMBERS", "glob"), "I") tars.learn(input2) self.assertEquals(tars.get("UNITS", "Silver"), 17)
def init_TARS(self): tars = TARS() with open("input.txt") as f: for line in f: not tars.is_question(line) and tars.learn(line) return tars