forked from gunthercox/ChatterBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_chatterbot_corpus_training.py
53 lines (37 loc) · 1.62 KB
/
test_chatterbot_corpus_training.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from tests_django.base_case import ChatterBotTestCase
from chatterbot.trainers import ChatterBotCorpusTrainer
class ChatterBotCorpusTrainingTestCase(ChatterBotTestCase):
"""
Test case for training with data from the ChatterBot Corpus.
Note: This class has a mirror tests/training_tests/
"""
def setUp(self):
super().setUp()
self.trainer = ChatterBotCorpusTrainer(
self.chatbot,
show_training_progress=False
)
def tearDown(self):
super().tearDown()
self.chatbot.storage.drop()
def test_train_with_english_greeting_corpus(self):
self.trainer.train('chatterbot.corpus.english.greetings')
results = list(self.chatbot.storage.filter(text='Hello'))
self.assertGreater(len(results), 1)
def test_train_with_english_greeting_corpus_tags(self):
self.trainer.train('chatterbot.corpus.english.greetings')
results = list(self.chatbot.storage.filter(text='Hello'))
self.assertGreater(len(results), 1)
statement = results[0]
self.assertEqual(['greetings'], statement.get_tags())
def test_train_with_multiple_corpora(self):
self.trainer.train(
'chatterbot.corpus.english.greetings',
'chatterbot.corpus.english.conversations',
)
results = list(self.chatbot.storage.filter(text='Hello'))
self.assertGreater(len(results), 1)
def test_train_with_english_corpus(self):
self.trainer.train('chatterbot.corpus.english')
results = list(self.chatbot.storage.filter(text='Hello'))
self.assertGreater(len(results), 1)