def test__find_value_in_question_tokens__fuzzy_match(self): # GIVEN question_tokens = [['find'], ['column', 'name'], ['of'], ['user'], ['whose'], ['column', 'email'], ['contain'], ['‘superstar’'], ['or'], ['‘edu’'], ['.']] value = '%superstar%' # WHEN result = _find_value_in_question_tokens(question_tokens, value) # THEN self.assertIsNotNone(result) self.assertEqual(result, range(7, 8))
def test__find_value_in_question_tokens__case_insensitive(self): # GIVEN question_tokens = [['How'], ['many'], ['lessons'], ['did'], ['the'], ['customer'], ['Rylan'], ['Goodwin'], ['complete'], ['?']] value = 'rylan' # WHEN result = _find_value_in_question_tokens(question_tokens, value) # THEN # we don't expect to find the value - as it's not available in the question. But we don't want it to throw an exception. self.assertIsNotNone(result) self.assertEqual(result, range(6, 7))
def test__find_value_in_question_tokens__int(self): # GIVEN question_tokens = [['find'], ['name'], ['and'], ['column', 'gender'], ['type'], ['of'], ['table', 'dorm'], ['whose'], ['capacity'], ['is'], ['greater'], ['than'], ['value', '300'], ['or'], ['le'], ['than'], ['value', '100'], ['.']] value = 300 # WHEN result = _find_value_in_question_tokens(question_tokens, value) # THEN self.assertIsNotNone(result) self.assertEqual(result, range(12, 13))
def test__find_value_in_question_tokens__quotes_type2(self): # GIVEN question_tokens = [['what'], ['is'], ['id'], ['of'], ['table', 'reviewer'], ['whose'], ['column', 'name'], ['ha'], ['substring'], ['“mike”'], ['?']] value = '%Mike%' # WHEN result = _find_value_in_question_tokens(question_tokens, value) # THEN # we don't expect to find the value - as it's not available in the question. But we don't want it to throw an exception. self.assertIsNotNone(result) self.assertEqual(result, range(9, 10))
def test__find_value_in_question_tokens__word_to_number(self): # GIVEN question_tokens = [['show'], ['column', 'carrier'], ['of'], ['table', 'device'], ['in'], ['table', 'stock'], ['at'], ['more'], ['than'], ['one'], ['table', 'shop'], ['.']] value = 1 # WHEN result = _find_value_in_question_tokens(question_tokens, value) # THEN # we don't expect to find the value - as it's not available in the question. But we don't want it to throw an exception. self.assertIsNotNone(result) self.assertEqual(result, range(9, 10))
def test__find_value_in_question_tokens__multi_word_value_at_the_end(self): # GIVEN question_tokens = [['what'], ['are'], ['column', 'name'], ['of'], ['all'], ['table', 'track'], ['that'], ['belong'], ['to'], ['rock'], ['table', 'genre'], ['and'], ['whose'], ['table', 'medium', 'type'], ['is'], ['mpeg'], ['?']] value = 'MPEG audio file' # WHEN result = _find_value_in_question_tokens(question_tokens, value) # THEN # we don't expect to find the value - as it's not available in the question. But we don't want it to throw an exception. self.assertIsNone(result)
def test__find_value_in_question_tokens__float(self): # GIVEN question_tokens = [['what'], ['are'], ['distinct'], ['column', 'hometown'], ['of'], ['table', 'gymnast'], ['with'], ['column', 'total', 'point'], ['more'], ['than'], ['value', '57.5'], ['?']] value = 57.5 # WHEN result = _find_value_in_question_tokens(question_tokens, value) # THEN # we don't expect to find the value - as it's not available in the question. But we don't want it to throw an exception. self.assertIsNotNone(result) self.assertEqual(result, range(10, 11))