1. Hiroyoshi Komatsu
  2. corenlp-python


Dustin Smith  committed 5d5648b

added NLTK example

  • Participants
  • Parent commits 25f5f7a
  • Branches master
  • Tags v1.3.1

Comments (0)

Files changed (2)

File README.md

View file
    * Python interface to Stanford CoreNLP tools: tagging, phrase-structure parsing, dependency parsing, named entity resolution, and coreference resolution.
    * Runs an JSON-RPC server that wraps the Java server and outputs JSON.
-   * Outputs parse trees which can be used in `nltk`
+   * Outputs parse trees which can be used by [nltk](http://nltk.googlecode.com/svn/trunk/doc/howto/tree.html).
 It requires [pexpect](http://www.noah.org/wiki/pexpect) and (optionally) [unidecode](http://pypi.python.org/pypi/Unidecode) to handle non-ASCII text.  This script includes and uses code from [jsonrpc](http://www.simple-is-better.org/rpc/) and [python-progressbar](http://code.google.com/p/python-progressbar/).
 This is free and open source software and has benefited from the contribution and feedback of others.  Like Stanford's CoreNLP tools, it is covered under the [GNU General Public License](http://www.gnu.org/licenses/gpl-2.0.html), which in short means that modifications to this program must maintain the same free and open source distribution policy.
-  * Justin Cheng jccf@221513ecf322dc32d6e088fb2f68751e45bac226
+  * Justin Cheng jcccf@221513ecf322dc32d6e088fb2f68751e45bac226
   * Abhaya Agarwal 8ed7640388cac8ba6d897739f5c8fe24eb87cc48

File client.py

View file
 import pprint
 result = json.loads(server.parse("Hello world!  It is so beautiful."))
+# example using nltk
+from nltk.tree import *
+tree = Tree.parse(result['sentences'][0]['parsetree'])
+print tree
+print tree.leaves()