Skip to content

Commit

Permalink
Use factory to generate data instead of our own method
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Jan 31, 2018
1 parent 68e436b commit f8b2f7f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 46 deletions.
25 changes: 0 additions & 25 deletions chatterbot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,31 +171,6 @@ def get_response_time(chatbot):
return time.time() - start_time


def generate_strings(total_strings, string_length=20):
"""
Generate a list of random strings.
:param total_strings: The number of strings to generate.
:type total_strings: int
:param string_length: The length of each string to generate.
:type string_length: int
:returns: The generated list of random strings.
:rtype: list
"""
import random
import string

statements = []
for _ in range(0, total_strings):
text = ''.join(
random.choice(string.ascii_letters + string.digits + ' ') for _ in range(string_length)
)
statements.append(text)
return statements


def print_progress_bar(description, iteration_counter, total_items, progress_bar_length=20):
"""
Print progress bar
Expand Down
6 changes: 0 additions & 6 deletions docs/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ ChatBot response time
.. autofunction:: chatterbot.utils.get_response_time


Random string generation
------------------------

.. autofunction:: chatterbot.utils.generate_strings


Parsing datetime information
----------------------------

Expand Down
12 changes: 6 additions & 6 deletions tests/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .base_case import ChatBotSQLTestCase, ChatBotMongoTestCase
from chatterbot import ChatBot
from chatterbot import utils
from factory import Faker
import sys
import logging

Expand All @@ -16,7 +17,8 @@
level=logging.INFO
)

STATEMENT_LIST = utils.generate_strings(10)
# Generate a list of random sentences
STATEMENT_LIST = Faker('sentences', nb=10).generate({})


class BenchmarkingMixin(object):
Expand Down Expand Up @@ -96,14 +98,13 @@ def test_synset_distance_comparisons(self):
]
})

self.assert_response_duration(1.9, kwargs)
self.assert_response_duration(3.5, kwargs)

def test_english_corpus_training(self):
"""
Test the amount of time it takes to train with the English corpus.
"""
import unittest
raise unittest.SkipTest('TODO: This test needs to be written.')
self.skipTest('TODO: This test needs to be written.')


class MongoBenchmarkingTests(BenchmarkingMixin, ChatBotMongoTestCase):
Expand Down Expand Up @@ -154,5 +155,4 @@ def test_english_corpus_training(self):
"""
Test the amount of time it takes to train with the English corpus.
"""
import unittest
raise unittest.SkipTest('TODO: This test needs to be written.')
self.skipTest('TODO: This test needs to be written.')
9 changes: 0 additions & 9 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ def test_remove_stop_words(self):
self.assertIn('test', list(words))
self.assertIn('string', list(words))

def test_generate_strings(self):
"""
Test that we can generate 2 strings of length 10.
"""
strings = utils.generate_strings(2, 10)
self.assertEqual(len(strings), 2)
self.assertEqual(len(strings[0]), 10)
self.assertEqual(len(strings[1]), 10)


class UtilityChatBotTestCase(ChatBotTestCase):

Expand Down

0 comments on commit f8b2f7f

Please sign in to comment.