def _parse_tree_explorer():  # put stuff in a function to not pollute global scope
    text = widgets.Text("John is eating pizza with anchovies")
    # Also try: John is eating pizza with a fork
    display.display(text)
    html = widgets.HTML()
    display.display(html)

    def handle_submit(sender):
        del sender  # unused
        parse_tree, trace = annotate_text(text.value)
        html.value = u"""
        <div style="max-width: 100%">{}</div>
        <style type="text/css">svg {{ max-width: 100%; }}</style>
        """.format(render_parse_tree_graphviz.parse_tree_graph(parse_tree))

    text.on_submit(handle_submit)
_parse_tree_explorer()

"""
Explanation: Interactive parse tree explorer
Run the cell below, and then enter text in the interactive widget.
End of explanation
"""


def _trace_explorer():  # put stuff in a function to not pollute global scope
    text = widgets.Text("John is eating pizza with anchovies")
    display.display(text)

    output = visualization.InteractiveVisualization()
    display.display(display.HTML(output.initial_html()))

    def handle_submit(sender):
        del sender  # unused
        parse_tree, trace = annotate_text(text.value)
        display.display(display.HTML(output.show_trace(trace)))


    text.on_submit(handle_submit)
_trace_explorer()

"""
Explanation: Interactive trace explorer
Run the cell below, and then enter text in the interactive widget.
End of explanation
"""


