8000 updated README · ez-max/stanford-corenlp-python@0f51765 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f51765

Browse files
committed
updated README
1 parent 1a64f9f commit 0f51765

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,49 @@
22

33
This a Python wrapper for Stanford University's NLP group's Java-based [CoreNLP tools](http://nlp.stanford.edu/software/corenlp.shtml). It can either be imported as a module or run as an JSON-RPC server. Because it uses many large trained models (requiring 3GB RAM and usually a few minutes loading time), most applications will probably want to run it as a server.
44

5-
It requires [pexpect](http://www.noah.org/wiki/pexpect) and uses [jsonrpc](http://www.simple-is-better.org/rpc/) and [python-progressbar](http://code.google.com/p/python-progressbar/), which are included.
5+
It requires [pexpect](http://www.noah.org/wiki/pexpect). Included dependencies are [jsonrpc](http://www.simple-is-better.org/rpc/) and [python-progressbar](http://code.google.com/p/python-progressbar/).
66

7-
There's not much to this script. I decided to create it after having trouble initializing the JVM through JPypes on two different machines.
7+
There's not much to this script. I decided to create it after having trouble initializing a JVM using JPypes on two different machines.
88

99
It runs the Stanford CoreNLP jar in a separate process, communicates with the java process using its command-line interface, and makes assumptions about the output of the parser in order to parse it into a Python dict object and transfer it using JSON. The parser will break if the output changes significantly. I have only tested this on **Core NLP tools version 1.0.2** released 2010-11-12.
1010

1111
## Download and Usage
1212

1313
You should have [downloaded](http://nlp.stanford.edu/software/corenlp.shtml#Download) and unpacked the tgz file containing Stanford's CoreNLP package. Then copy all of the python files from this repository into the `stanford-corenlp-2010-11-12` folder.
1414

15+
In other words:
16+
17+
sudo pip install pexpect
18+
wget http://nlp.stanford.edu/software/stanford-corenlp-v1.0.2.tgz
19+
tar xvfz stanford-corenlp-v1.0.2.tgz
20+
cd stanford-corenlp-2010-11-12
21+
git clone git://github.com/dasmith/stanford-corenlp-python.git
22+
mv stanford-corenlp-python/* .
23+
1524
Then, to launch a server:
1625

1726
python server.py
1827

19-
Optionally, specify a host or port:
28+
Optionally, you can specify a host or port:
2029

2130
python server.py -H 0.0.0.0 -p 3456
2231

23-
To run a public JSON-RPC server on port 3456.
32+
That will run a public JSON-RPC server on port 3456.
33+
34+
Assuming you are running on port 8080, the code in `client.py` shows an example parse:
35+
36+
port jsonrpc
37+
server = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(),
38+
jsonrpc.TransportTcpIp(addr=("127.0.0.1", 8080)))
39+
40+
result = server.parse("hello world")
41+
print "Result", result
42+
43+
44+
Produces:
45+
46+
Result [{"text": "hello world", "tuples": [["amod", "world", "hello"]], "words": {"world": {"NamedEntityTag": "O", "CharacterOffsetEnd": "11", "Lemma": "world", "PartOfSpeech": "NN", "CharacterOffsetBegin": "6"}, "hello": {"NamedEntityTag": "O", "CharacterOffsetEnd": "5", "Lemma": "hello", "PartOfSpeech": "JJ", "CharacterOffsetBegin": "0"}}}]
2447

25-
See `client.py` for example of how to connect with a client.
2648

2749
<!--
2850
## Adding WordNet

server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12
"""
23
This is a Python interface to Stanford Core NLP tools.
34
It can be imported as a module or run as a server.

0 commit comments

Comments
 (0)
0