class InnerVoiceDataBaseBuilderTest(unittest.TestCase):
    def setUp(self):
        from database import InnerVoiceDataBaseBuilder

        self.builder = InnerVoiceDataBaseBuilder()

    def test_generateDataBase_empty(self):
        from database import InnerVoiceDataBase

        database = self.builder.generateDataBase()
        self.assertIsInstance(database,InnerVoiceDataBase)

        self.assertEqual(database.getAll(),[])


    def test_generateDataBase(self):
        from database import InnerVoiceDataBase

        self.builder.addTxtFile("innervoice_sample.txt")
        database = self.builder.generateDataBase()
        self.assertIsInstance(database,InnerVoiceDataBase)

        self.assertIn("aaa aaa",database.getAll())
        self.assertIn("aaa bbb",database.getAll())
        self.assertNotIn("aaa ccc",database.getAll())
Пример #2
0
if __name__ == "__main__":
    from jarvis import Jarvis
    from database import WordDataBaseBuilder
    from database import TrainingDataBaseBuilder
    from database import AbilitiesDataBaseBuilder
    from database import InnerVoiceDataBaseBuilder
    from interfaces import Console

    wd_builder = WordDataBaseBuilder()
    wd_builder.addTxtFile("learning_material/traning.txt")

    td_builder = TrainingDataBaseBuilder()
    td_builder.addTxtFile("learning_material/traning.txt")

    iv_builder = InnerVoiceDataBaseBuilder()
    iv_builder.addTxtFile("learning_material/inner_voices.txt")

    ab_builder = AbilitiesDataBaseBuilder()

    he = Jarvis()
    he.createWordsDataBase(wd_builder)
    he.createTrainingDataBase(td_builder)
    he.createAbilitiesDataBase(ab_builder)
    he.createInnerVoiceDatabase(iv_builder)
    he.train()

    console = Console()
    console.jarvis(he)
    console.start()

    he.start()
    def setUp(self):
        from database import InnerVoiceDataBaseBuilder

        self.builder = InnerVoiceDataBaseBuilder()