Jython:Intro
From Mallet
Version 0.4
For version 0.4 of mallet, a script called mallethon (in the bin directory) has been prepared. In order to get mallethon to work, you need to set the environment variable JAVA_HOME to point to the directory where the JDK resides. For example, on our system the java executable is at
/usr/java/jdk1.5.0_04/bin/java
and we set
JAVA_HOME=/usr/java/jdk1.5.0_04
Then use mallethon as the interpreter (in much the same way you would if you were using python). For example:
../bin/mallethon TrainCRF.py -f training_file -m save_model_here
Gotchas
- Jython does not deal well when the CLASSPATH contains two colons next to eachother
- the mallethon script sets the classpath based on where it is located (it assumes it is in the mallet home directory). If you move the script, you need to either edit it to set the MALLET_HOME environment variable, or set this externally.
- The mallethon script does not play nice with having a .jython file in the user's home directory (it sets some jython configuration which that file can overwrite).
Please note that Jython requires JDK 1.5, while MALLET has been developed and heavily tested with JDK 1.4. Please report problems to mallet-dev at cs.umass.edu.
Old instructions
In order to use mallet from jython, you will need both Mallet and Jython. Mallet is available here, while Jython is available at the Jython site (http://www.jython.org/). You will also need to set your classpath to include: <MALLET>/class:<MALLET>/lib/bsh.jar:<MALLET>/lib/junit.jar
For example, if MALLET is installed in /data/mallet/ then you would need to run (for bash-style shell users):
export CLASSPATH=/data/mallet/class:/data/mallet/lib/bsh.jar:/data/mallet/lib/junit.jar:$CLASSPATH
Finally, in order to use modules written in jython, you need to add a python path to a file called ~/.jython. For example, if mallet is installed in /data/mallet/ then you can create the necessary file with the command:
echo python.path=/data/mallet/pylib/:/data/mallet/class/ > ~/.jython