def _validate_nlu(self, training_data: TrainingData) -> None:
        """Validates whether the configuration matches the training data.

        Args:
           training_data: The training data for the NLU components.
        """
        training_data.validate()

        self._raise_if_more_than_one_tokenizer()
        self._raise_if_featurizers_are_not_compatible()
        self._warn_of_competing_extractors()
        self._warn_of_competition_with_regex_extractor(training_data=training_data)
        self._warn_if_some_training_data_is_unused(training_data=training_data)
Exemple #2
0
def test_validate_number_of_examples_per_intent():
    message_intent = Message(data={
        "text": "I would like the newsletter",
        "intent": "subscribe"
    })
    message_non_nlu_intent = Message(data={"intent": "subscribe"})

    training_examples = [message_intent, message_non_nlu_intent]
    training_data = TrainingData(training_examples=training_examples)

    with pytest.warns(Warning) as w:
        training_data.validate()

    assert len(w) == 1
    assert (w[0].message.args[0] ==
            "Intent 'subscribe' has only 1 training examples! "
            "Minimum is 2, training may fail.")