def test_amazon_reviews_neutral(self): input_data = { 'data': { 'review_headline': 'okay headphones', 'review_body': 'the sound quality of these headphones is not bad', 'star_rating': 3, } } og_dataset = tf.data.Dataset.from_tensors(input_data) dataset = preprocessors.amazon_reviews(og_dataset) test_utils.assert_dataset(dataset, []) dataset = preprocessors.amazon_reviews(og_dataset, binary_output=False) test_utils.assert_dataset( dataset, { 'inputs': 'sentiment review: okay headphones the sound quality of ' 'these headphones is not bad', 'targets': '3' })
def test_amazon_reviews(self): input_data = { 'data': { 'review_headline': 'Great headphones', 'review_body': 'Loved the sound quality of these headphones', 'star_rating': 5, } } og_dataset = tf.data.Dataset.from_tensors(input_data) dataset = preprocessors.amazon_reviews(og_dataset) test_utils.assert_dataset( dataset, { 'inputs': 'sentiment review: Great headphones Loved the ' 'sound quality of these headphones', 'targets': 'positive' }) dataset = preprocessors.amazon_reviews(og_dataset, binary_output=False) test_utils.assert_dataset( dataset, { 'inputs': 'sentiment review: Great headphones Loved the ' 'sound quality of these headphones', 'targets': '5' })