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
def extract_story_graph_from_file( filename, # type: Text domain, # type: Domain interpreter=RegexInterpreter() # type: NaturalLanguageInterpreter ): # type: (...) -> StoryGraph story_steps = StoryFileReader.read_from_file(filename, domain, interpreter) return StoryGraph(story_steps)
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
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
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
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