From edfb9e89f68795ff3a4a5811dc02d75905c0c980 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Sat, 15 Apr 2017 16:42:35 -0400 Subject: [PATCH] Pretty print the NLTK syntax tree too --- edX Lightning Talk.ipynb | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/edX Lightning Talk.ipynb b/edX Lightning Talk.ipynb index 7e04310..dccfc61 100644 --- a/edX Lightning Talk.ipynb +++ b/edX Lightning Talk.ipynb @@ -585,7 +585,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 33, "metadata": { "slideshow": { "slide_type": "fragment" @@ -609,8 +609,42 @@ ], "source": [ "from stat_parser import Parser\n", - "parser = Parser()\n", - "print parser.parse('The quick brown fox jumps over the lazy dog.')" + "parsed = Parser().parse('The quick brown fox jumps over the lazy dog.')\n", + "print parsed" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "slideshow": { + "slide_type": "fragment" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " S \n", + " ________________________|__________________________ \n", + " | VP | \n", + " | ____|_____________ | \n", + " | | NP | \n", + " | | _________|________ | \n", + " | | | PP | \n", + " | | | ________|___ | \n", + " NP | NP | NP | \n", + " ___|____ | ___|____ | _______|____ | \n", + " DT NN VB JJ NN IN DT JJ NN . \n", + " | | | | | | | | | | \n", + "the quick brown fox jumps over the lazy dog . \n", + "\n" + ] + } + ], + "source": [ + "parsed.pretty_print()" ] }, {