Python interface for the Berkeley Parser using JPype
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Python-Enabled Berkeley Parser Build Status

This has the advantage over other implementations which essentially automate a call to the jar file: this actually duplicates the main method, allowing multiple parse calls and ability to modify options without the overhead of loading the grammar file each time (and without having to use Java!)

N.B. several features completely ignored (notably, -nThreads, -nGrammars, -kbest options) and some theoretically implemented but untested (-chinese)

See for a short running demo of the interface.


Note that this package requires the Berkeley Parser 1.6 or Berkeley Parser 1.7 JAR file (depending on your version of Java) as well as a grammar file. You can tell the Python module the location of these files via an ENVVAR:

export BERKELEY_PARSER_JAR=/path/to/berkeley/parser.jar
export BERKELEY_PARSER_GRM=/path/toberkeley/

Otherwise the default is currently set to C:\berkeleyparser\ for Windows systems. In the future we'll add a search path to perform lookups for sane places on OS X and Linux as well.

Installation and Dependencies

Although a package script has been setup to install the Python module, one dependency cannot currently be fulfilled by PyPi- the core bridge between Python and Java, JPype. The authors have submitted a support request to have JPype included into PyPi, but until that time, you'll have to download and install this dependency yourself.

Download the JPype package from JPype and unpackage it in your current working directory. Run the command:

pip install JPype-

Which should begin the installation process (we highly recommend that you use virtualenv and virtualenvwrapper to do this). Then simply run:

python install

And the BerkeleyInterface package should be installed into your Python path.

Note: For Mac users, you may have to modify JPype's settings a bit, according to this Stackoverflow Question. Modify the JPype- file to include the line following line:

def setupInclusion(self):
    self.includeDirs = [

        #I added this line below. The folder contains a jni.h

Then run the pip install JPype- command and it should work.