def test_generate_noise_utterances_should_replace_unknown_words( self, mocked_noise): # Given utterances = [{ "data": [{ "text": "hello " }, { "text": " you ", "entity": "you" }, { "text": " how are you " }, { "text": "bobby", "entity": "you" }] }] language = LANGUAGE_EN mocked_noise.return_value = ["hello", "dear", "you", "fool"] replacement_string = "unknownword" # When noise = generate_smart_noise(utterances, replacement_string, language) # Then expected_noise = [ "hello", replacement_string, "you", replacement_string ] self.assertEqual(noise, expected_noise)
def test_generate_noise_utterances_should_replace_unknown_words( self, mocked_noise): # Given utterances = [ { "data": [ { "text": "hello " }, { "text": " you ", "entity": "you" }, { "text": " how are you " }, { "text": "bobby", "entity": "you" } ] } ] language = LANGUAGE_EN mocked_noise.return_value = ["hello", "dear", "you", "fool"] replacement_string = "unknownword" # When noise = generate_smart_noise(utterances, replacement_string, language) # Then expected_noise = ["hello", replacement_string, "you", replacement_string] self.assertEqual(noise, expected_noise)