Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_load_corpus_indonesian(self):
files = corpus.list_corpus_files('chatterbot_corpus/data/indonesian')
corpus_data = list(corpus.load_corpus(*files))
self.assertTrue(len(corpus_data))
def test_load_corpus_telugu(self):
data_files = corpus.list_corpus_files('chatterbot.corpus.telugu')
corpus_data = corpus.load_corpus(*data_files)
self.assertTrue(len(list(corpus_data)))
def test_character_count(self):
"""
Test that no line in the corpus exceeds the maximum number of characters.
"""
files = corpus.list_corpus_files('chatterbot_corpus')
for dialog_corpus, _categories, _file_path in corpus.load_corpus(*files):
for conversation in dialog_corpus:
for text in conversation:
if len(text) > STATEMENT_TEXT_MAX_LENGTH:
self.fail(
'"{}" cannot be longer than {} characters'.format(
text,
STATEMENT_TEXT_MAX_LENGTH
)
def test_load_english_corpus_categories(self):
files = corpus.list_corpus_files('chatterbot_corpus/data/english/greetings.yml')
corpus_data = list(corpus.load_corpus(*files))
self.assertEqual(len(corpus_data), 1)
# Test that each conversation gets labeled with the correct category
for conversation in corpus_data:
self.assertIn('greetings', conversation[1])
def test_get_file_path(self):
"""
Test that a dotted path is properly converted to a file address.
"""
path = corpus.get_file_path('chatterbot.corpus.english')
self.assertIn(
os.path.join('chatterbot_corpus', 'data', 'english'),
path
)
def test_get_file_path(self):
"""
Test that a dotted path is properly converted to a file address.
"""
path = corpus.get_file_path('chatterbot.corpus.english')
self.assertIn(
os.path.join('chatterbot_corpus', 'data', 'english'),
path
)
def test_character_count(self):
"""
Test that no line in the corpus exceeds the maximum number of characters.
"""
files = corpus.list_corpus_files('chatterbot_corpus')
for dialog_corpus, _categories, _file_path in corpus.load_corpus(*files):
for conversation in dialog_corpus:
for text in conversation:
if len(text) > STATEMENT_TEXT_MAX_LENGTH:
self.fail(
'"{}" cannot be longer than {} characters'.format(
text,
STATEMENT_TEXT_MAX_LENGTH
)
def test_load_corpus_english_greetings(self):
file_path = os.path.join(corpus.DATA_DIRECTORY, 'english', 'greetings.yml')
data_files = corpus.list_corpus_files(file_path)
corpus_data = corpus.load_corpus(*data_files)
self.assertEqual(len(list(corpus_data)), 1)
def test_read_english_corpus(self):
corpus_path = os.path.join(
corpus.DATA_DIRECTORY,
'english', 'conversations.yml'
)
data = corpus.read_corpus(corpus_path)
self.assertIn('conversations', data)
def test_load_corpus_telugu(self):
files = corpus.list_corpus_files('chatterbot_corpus/data/telugu')
corpus_data = list(corpus.load_corpus(*files))
self.assertTrue(len(corpus_data))