Exemplo n.º 1
0
    def _generate_training_examples_md(self,
                                       training_data: "TrainingData") -> Text:
        """Generates markdown training examples."""

        import rasa.nlu.training_data.util as rasa_nlu_training_data_utils

        training_examples = OrderedDict()

        # Sort by intent while keeping basic intent order
        for example in [
                e.as_dict_nlu() for e in training_data.training_examples
        ]:
            rasa_nlu_training_data_utils.remove_untrainable_entities_from(
                example)
            intent = example[INTENT]
            training_examples.setdefault(intent, [])
            training_examples[intent].append(example)

        # Don't prepend newline for first line
        prepend_newline = False
        lines = []

        for intent, examples in training_examples.items():
            section_header = self._generate_section_header_md(
                INTENT, intent, prepend_newline=prepend_newline)
            lines.append(section_header)
            prepend_newline = True

            lines += [
                self.generate_list_item(self.generate_message(example))
                for example in examples
            ]

        return "".join(lines)
Exemplo n.º 2
0
    def prepare_training_examples(training_data: "TrainingData") -> OrderedDict:
        """Pre-processes training data examples by removing not trainable entities."""

        import rasa.nlu.training_data.util as rasa_nlu_training_data_utils

        training_examples = OrderedDict()

        # Sort by intent while keeping basic intent order
        for example in [e.as_dict_nlu() for e in training_data.training_examples]:
            rasa_nlu_training_data_utils.remove_untrainable_entities_from(example)
            intent = example[INTENT]
            training_examples.setdefault(intent, [])
            training_examples[intent].append(example)

        return training_examples