Example #1
0
    def visualize(self,
                  filename,
                  output_file,
                  max_history,
                  nlu_training_data=None,
                  fontsize=12):
        from rasa_core.training.visualization import visualize_stories
        from rasa_core.training import StoryFileReader

        story_steps = StoryFileReader.read_from_file(filename, self.domain)
        visualize_stories(story_steps, self.domain, output_file, max_history,
                          self.interpreter, nlu_training_data, fontsize)
Example #2
0
def test_graph_persistence(default_domain, tmpdir):
    from os.path import isfile
    from networkx.drawing import nx_pydot
    import io

    from rasa_core.training.dsl import StoryFileReader
    from rasa_core.interpreter import RegexInterpreter
    story_steps = StoryFileReader.read_from_file(
        "data/test_stories/stories.md",
        default_domain,
        interpreter=RegexInterpreter())
    out_file = tmpdir.join("graph.html").strpath
    generated_graph = visualization.visualize_stories(story_steps,
                                                      default_domain,
                                                      output_file=out_file,
                                                      max_history=3,
                                                      should_merge_nodes=False)

    generated_graph = nx_pydot.to_pydot(generated_graph)

    assert isfile(out_file)

    with io.open(out_file, 'r') as graph_file:
        content = graph_file.read()

    assert 'isClient = true' in content
    assert "graph = `{}`".format(generated_graph.to_string()) in content
Example #3
0
    def visualize(self,
                  resource_name,  # type: Text
                  output_file,  # type: Text
                  max_history,  # type: int
                  nlu_training_data=None,  # type: Optional[Text]
                  should_merge_nodes=True,  # type: bool
                  fontsize=12  # type: int
                  ):
        # type: (...) -> None
        from rasa_core.training.visualization import visualize_stories
        from rasa_core.training.dsl import StoryFileReader
        """Visualize the loaded training data from the resource."""

        story_steps = StoryFileReader.read_from_folder(resource_name,
                                                       self.domain)
        visualize_stories(story_steps, self.domain, output_file, max_history,
                          self.interpreter, nlu_training_data,
                          should_merge_nodes, fontsize)
Example #4
0
    def visualize(self,
                  resource_name,  # type: Text
                  output_file,  # type: Text
                  max_history,  # type: int
                  nlu_training_data=None,  # type: Optional[Text]
                  should_merge_nodes=True,  # type: bool
                  fontsize=12  # type: int
                  ):
        # type: (...) -> None
        from rasa_core.training.visualization import visualize_stories
        from rasa_core.training.dsl import StoryFileReader
        """Visualize the loaded training data from the resource."""

        story_steps = StoryFileReader.read_from_folder(resource_name,
                                                       self.domain)
        visualize_stories(story_steps, self.domain, output_file, max_history,
                          self.interpreter, nlu_training_data,
                          should_merge_nodes, fontsize)
Example #5
0
def test_story_visualization(default_domain):
    story_steps = StoryFileReader.read_from_file(
            "data/test_stories/stories.md", default_domain,
            interpreter=RegexInterpreter())
    generated_graph = visualize_stories(story_steps, default_domain,
                                        output_file=None,
                                        max_history=3,
                                        should_merge_nodes=False)
    assert len(generated_graph.nodes()) == 33
Example #6
0
    def visualize(self,
                  resource_name: Text,
                  output_file: Text,
                  max_history: Optional[int] = None,
                  nlu_training_data: Optional[Text] = None,
                  should_merge_nodes: bool = True,
                  fontsize: int = 12) -> None:
        from rasa_core.training.visualization import visualize_stories
        from rasa_core.training.dsl import StoryFileReader
        """Visualize the loaded training data from the resource."""

        # if the user doesn't provide a max history, we will use the
        # largest value from any policy
        max_history = max_history or self._max_history()

        story_steps = StoryFileReader.read_from_folder(resource_name,
                                                       self.domain)
        visualize_stories(story_steps, self.domain, output_file, max_history,
                          self.interpreter, nlu_training_data,
                          should_merge_nodes, fontsize)
Example #7
0
def test_story_visualization_with_merging(default_domain):
    story_steps = StoryFileReader.read_from_file(
            "data/test_stories/stories.md", default_domain,
            interpreter=RegexInterpreter())
    generated_graph = visualize_stories(story_steps, default_domain,
                                        output_file=None,
                                        max_history=3,
                                        should_merge_nodes=True)
    assert 15 < len(generated_graph.nodes()) < 33

    assert 20 < len(generated_graph.edges()) < 33
Example #8
0
def test_story_visualization(default_domain, tmpdir):
    story_steps = StoryFileReader.read_from_file(
            "data/test_stories/stories.md", default_domain,
            interpreter=RegexInterpreter())
    out_file = tmpdir.join("graph.html").strpath
    generated_graph = visualize_stories(story_steps, default_domain,
                                        output_file=out_file,
                                        max_history=3,
                                        should_merge_nodes=False)

    assert len(generated_graph.nodes()) == 51

    assert len(generated_graph.edges()) == 56
Example #9
0
def test_story_visualization(default_domain, tmpdir):
    story_steps = StoryFileReader.read_from_file(
            "data/test_stories/stories.md", default_domain,
            interpreter=RegexInterpreter())
    out_file = tmpdir.join("graph.png").strpath
    generated_graph = visualize_stories(story_steps, default_domain,
                                        output_file=out_file,
                                        max_history=3,
                                        should_merge_nodes=False)

    assert len(generated_graph.nodes()) == 51

    assert len(generated_graph.edges()) == 56