Beispiel #1
0
    def test_generate_noise_utterances(self, mocked_get_noise):
        # Given
        language = LANGUAGE_EN
        num_intents = 2
        noise_factor = 1
        utterances_length = 5

        noise = [str(i) for i in range(utterances_length)]
        mocked_get_noise.return_value = noise

        augmented_utterances = [
            {
                "data": [
                    {
                        "text": " ".join(
                            "{}".format(i) for i in range(utterances_length))
                    }
                ]
            }
        ]
        num_utterances = 10
        random_state = np.random.RandomState(1)

        augmented_utterances = augmented_utterances * num_utterances
        config = IntentClassifierDataAugmentationConfig(
            noise_factor=noise_factor)
        # When
        noise_utterances = generate_noise_utterances(
            augmented_utterances, noise, num_intents, config, language,
            random_state)

        # Then
        joined_noise = text_to_utterance(" ".join(noise))
        for u in noise_utterances:
            self.assertEqual(u, joined_noise)
    def test_generate_noise_utterances(self, mocked_get_noises):
        # Given
        language = LANGUAGE_EN
        num_intents = 2
        noise_factor = 1
        utterances_length = 5

        noise = [str(i) for i in range(utterances_length)]
        mocked_get_noises.return_value = noise

        augmented_utterances = [
            {
                "data": [
                    {
                        "text": " ".join(
                            "{}".format(i) for i in range(utterances_length))
                    }
                ]
            }
        ]
        num_utterances = 10
        random_state = np.random.RandomState(1)

        augmented_utterances = augmented_utterances * num_utterances
        config = IntentClassifierDataAugmentationConfig(
            noise_factor=noise_factor)
        # When
        noise_utterances = generate_noise_utterances(
            augmented_utterances, num_intents, config, language, random_state)

        # Then
        joined_noise = " ".join(noise)
        for u in noise_utterances:
            self.assertEqual(u, joined_noise)