rasa/core/training/structures.py
def _remove_unused_generated_cps(
        self,
        story_steps: Dict[Text, StoryStep],
        overlapping_cps: Set[Text],
        story_end_checkpoints: Dict[Text, Text]
    ) -> None:
        """Finds unused generated checkpoints
            and remove them from story steps."""

        unused_cps = self._find_unused_checkpoints(story_steps.values(),
                                                   story_end_checkpoints)

        unused_overlapping_cps = unused_cps.intersection(overlapping_cps)

        unused_genr_cps = {cp_name
                           for cp_name in unused_cps
                           if cp_name.startswith(GENERATED_CHECKPOINT_PREFIX)}

        k_to_remove = set()
        for k, step in story_steps.items():
            # changed all ends
            updated = step.create_copy(use_new_id=False)
            updated.start_checkpoints = self._checkpoint_difference(
                updated.start_checkpoints, unused_overlapping_cps)

            # remove generated unused end checkpoints
            updated.end_checkpoints = self._checkpoint_difference(
                updated.end_checkpoints, unused_genr_cps)

            if (step.start_checkpoints and not updated.start_checkpoints or
                    step.end_checkpoints and not updated.end_checkpoints):
                # remove story step if the generated checkpoints
                # were the only ones
                k_to_remove.add(k)

            story_steps[k] = updated

        # remove unwanted story steps
        for k in k_to_remove:
            del story_steps[k]
Finds unused generated checkpoints
            and remove them from story steps.
Finds unused generated checkpoints
and remove them from story steps.
Finds unused generated checkpoints and remove them from story steps .
def _remove_unused_generated_cps(
        self,
        story_steps: Dict[Text, StoryStep],
        overlapping_cps: Set[Text],
        story_end_checkpoints: Dict[Text, Text]
    ) -> None:
        unused_cps = self._find_unused_checkpoints(story_steps.values(),
                                                   story_end_checkpoints)
        unused_overlapping_cps = unused_cps.intersection(overlapping_cps)
        unused_genr_cps = {cp_name
                           for cp_name in unused_cps
                           if cp_name.startswith(GENERATED_CHECKPOINT_PREFIX)}
        k_to_remove = set()
        for k, step in story_steps.items():
            updated = step.create_copy(use_new_id=False)
            updated.start_checkpoints = self._checkpoint_difference(
                updated.start_checkpoints, unused_overlapping_cps)
            updated.end_checkpoints = self._checkpoint_difference(
                updated.end_checkpoints, unused_genr_cps)
            if (step.start_checkpoints and not updated.start_checkpoints or
                    step.end_checkpoints and not updated.end_checkpoints):
                k_to_remove.add(k)
            story_steps[k] = updated
        for k in k_to_remove:
            del story_steps[k]
def _remove_unused_generated_cps ( self , story_steps : Dict [ Text , StoryStep ] , overlapping_cps : Set [ Text ] , story_end_checkpoints : Dict [ Text , Text ] ) -> None : unused_cps = self . _find_unused_checkpoints ( story_steps . values ( ) , story_end_checkpoints ) unused_overlapping_cps = unused_cps . intersection ( overlapping_cps ) unused_genr_cps = { cp_name for cp_name in unused_cps if cp_name . startswith ( GENERATED_CHECKPOINT_PREFIX ) } k_to_remove = set ( ) for k , step in story_steps . items ( ) : updated = step . create_copy ( use_new_id = False ) updated . start_checkpoints = self . _checkpoint_difference ( updated . start_checkpoints , unused_overlapping_cps ) updated . end_checkpoints = self . _checkpoint_difference ( updated . end_checkpoints , unused_genr_cps ) if ( step . start_checkpoints and not updated . start_checkpoints or step . end_checkpoints and not updated . end_checkpoints ) : k_to_remove . add ( k ) story_steps [ k ] = updated for k in k_to_remove : del story_steps [ k ]
Finds unused generated checkpoints
and remove them from story steps.
Finds unused generated checkpoints and remove them from story steps .
"""Finds unused generated checkpoints
            and remove them from story steps.""" # changed all ends # remove generated unused end checkpoints # remove story step if the generated checkpoints # were the only ones # remove unwanted story steps
self
story_steps
Dict[Text, StoryStep]
overlapping_cps
Set[Text]
story_end_checkpoints
Dict[Text, Text]