Skip to content

Commit

Permalink
Fill out remaining sequence matching test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Oct 26, 2016
1 parent c45abb3 commit 4a65347
Showing 1 changed file with 67 additions and 9 deletions.
76 changes: 67 additions & 9 deletions tests/test_subtree_matching.py → tests/test_graph.py
Expand Up @@ -113,29 +113,77 @@ def test_exact_match(self):
Statement('I am good, how about you?'),
Statement('I am also good.')
]

self.chatbot.train(statement.text for statement in sequence)

found = self.graph.find_closest_matching_sequence_in_tree(sequence)

self.assertEqual(len(found), len(sequence))
self.assertEqual(found[0], sequence[0])
self.assertEqual(found[1], sequence[1])
self.assertEqual(found[2], sequence[2])

def test_close_match(self):
sequence = [
Statement('Are you a robot?'),
Statement('No, I am not a robot.'),
Statement('Darn, I like robots.')
]
close_sequence = [
Statement('Are thou a robot?'),
Statement('I am not a robot.'),
Statement('Okay, I like robots.')
]
self.chatbot.train(statement.text for statement in sequence)

found = self.graph.find_closest_matching_sequence_in_tree(close_sequence)

print('found:', found)

self.assertEqual(len(found), len(sequence))
self.assertEqual(found[0], sequence[0])
self.assertEqual(found[1], sequence[1])
self.assertEqual(found[2], sequence[2])

def test_no_match(self):
pass
def test_partial_sequence_match(self):
sequence = [
Statement('Look at this cat!'),
Statement('Wow, that is a cool cat.'),
Statement('I know, right?')
]
close_sequence = [
Statement('Look at this cat!'),
Statement('Where is it?')
]
self.chatbot.train(statement.text for statement in sequence)

def test_close_match(self):
pass
found = self.graph.find_closest_matching_sequence_in_tree(close_sequence)

def test_partial_sequence_match(self):
pass
print('found:', found)

self.assertEqual(len(found), len(sequence))
self.assertEqual(found[0], sequence[0])
self.assertEqual(found[1], sequence[1])
self.assertEqual(found[2], sequence[2])

def test_partial_tree_match(self):
pass
sequence = [
Statement('Look at this cat!'),
Statement('Where is it?')
]
close_sequence = [
Statement('Look at this cat!'),
Statement('Wow, that is a cool cat.'),
Statement('I know, right?')
]
self.chatbot.train(statement.text for statement in sequence)

found = self.graph.find_closest_matching_sequence_in_tree(close_sequence)

print('found:', found)

self.assertEqual(len(found), len(sequence))
self.assertEqual(found[0], sequence[0])
self.assertEqual(found[1], sequence[1])


class SequenceMatchingTestCase(ChatBotTestCase):
Expand All @@ -154,4 +202,14 @@ def test_get_all_ordered_subsets(self):
self.assertIn([1, 2, 3], subsets)

def test_get_max_comparison(self):
pass
from chatterbot.utils.graphs import get_max_comparison
options = [
Statement('I like to watch the boats on the river.'),
Statement('Why are there boats on the river?'),
Statement('I like to sail my boat on the river.')
]

statement = Statement('I like to watch the boats.')
confidence, result = get_max_comparison(statement, options)

self.assertEqual(result, options[0])

0 comments on commit 4a65347

Please sign in to comment.