Concise Greedy Dependency Parser in Scala
Python Scala Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Concise Greedy Dependency Parser (in Scala)

This Dependency Parser was inspired by the following two blog posts :

With original BSD code here :

This version includes a copy of the original code for reference, but the goal is to implement the same minimalist ideals, in Scala.

There's a much more complete system (which extends over very many more files, however) at Matthew Honnibal's (the original author) GitHub account :

As background material, this presentation about this project that I gave to the Singapore Scala MeetUp Group could be interesting.

Significant Files

Original Python version (as well as a works-for-me version, that's adapted to import from Python's NLTK CONLL files) :


The Scala version :



As usual for Scala :

git clone
cd ConciseGreedyDependencyParser-in-Scala

In order to read in a directory's worth of free 'gold tagged' data, download the Python NLTK CONLL files, either by following the instructions at :

or by downloading directly from :, the dataset that is particularly useful is : Dependency Parsed Treebank. At the time of writing, a direct link is :

Once the file archive has been downloaded and the files extracted, create a link in the main directory to the nltk_data location. On my machine :

cd ConciseGreedyDependencyParser-in-Scala
ln -s /home/andrewsm/nltk_data .

If you want to explicitly link to a specific directory instead, search the Scala source for nltk_data and update the path to point directly to the appropriate directory.

Pre-Installation (sbt from scratch)

On my Fedora Linux server, all that is required is the zeromq3 backend library (for the Server functionality), and an installation of sbt (which automatically brings in java, etc as dependencies) :

yum install zeromq3-devel
yum localinstall sbt-0.13.7.rpm

Running the training / testing

Within the sbt environment, the following commands will do something:

> run learn tagger
> run learn tagger save

> run learn deps
> run learn deps save

> run learn both save

> run test tagger
> run test gold

# TODO : run test deps

> run server <PORT>

Running as a ZeroMQ Server

Once the models have been trained and saved, the program can be run in server mode. In server mode, it responds to REP/REQ messages via ZeroMQ.

Of course, an HTTP REST interface would also be possible, but (for reasons beyond this implementation), there's additional value in making it work a part of a ZeroMQ toolchain.
Indeed, this ZeroMQ/Clojure blog post makes it clear that there are many desirable properties of 'HTTP' semantics over ZeroMQ.

If you just want to run it straight from the command line (for instance, if you've done a run learn both save and now you just want to use the Parser in server-mode) :

$ sbt "run server <PORT>"

In order to ease development, the build.scala is set up to fork the scala code that's being run - and a bash script ./kill-CGDP will kill the child process without bringing down the sbt session.

Python ZeroMQ Utilities

For convenience, there are simple Python ZeroMQ client and broker programs that can send valid requests to the (scala) server.
These utilities are in the ./python directory.

To get them running, the zeromq-devel library should be installed (as above), and also the Python ZeroMQ library (this can also easily be done within a virtualenv, which is nice from an isolation point-of-view):

pip install pyzmq

The Python ZeroMQ broker (which should be left running, since it binds() to a pair of ports, and bridges them) can be started :

python python/ &

(this runs without any output).

The client program can easily be updated for testing :

python python/

It will produce output in the following form (newlines added for clarity) :

Client is connected to socket on broker frontend
Sending Request # 1
Received reply # 1 >{
   "tags": ["NNP","CD","CC","CD",",","NNP","NNP","VBD",