Bernard BOU
Lycée Champollion
bbou@ac-toulouse.fr
THIS PAGE WAS REVISED ON FEB 20, 2006
This package is is under a GPL GNU Licence (See file GPL). Some of the code is under the WordNet license agreement.
This package allows you to use WordNet from Java. Some of the code is under the WordNet license agreement.
I weighed the pros and cons of writing a pure java solution (with no C code) and decided against it on the following grounds :
native methods | pure java methods | ||
for | against | for | against |
it is independent from the format of
the database which may evolve in future releases
if the current C API is still supported future
releases of WordNet - and at the moment this is the only thing that
looks like an interface - , adjustment could involve only minor changes |
the methods have to be recompiled to
the target platform code
release package is more complex and there is the hassle of indicating the library path |
it is portable without recompiling | it is data-dependent and tied to the
format of the database which may evolve in future releases
performance penalty in wide scope searches |
There are other implementations with the same functionality. I'm
referring to Jorge Gomez' ( jjgomez@sip.ucm.es
) implementation of a Java native interface. It came first and suffices
in most situations but, as as I started using it, I wanted to improve
on on a number of points. So I started a rewrite and the result has
evolved away from the original.
However we do have points in common :
The points I wanted to improve on :
This is taken from the JDK 1.2 documentation :
You need :
I have carefully avoided features which could not be portable.
You simply need a standard C++ tool.
However I developed this on two specific platforms :
I include the build files attached to these tools for convenience togehter with redundant batch or shell files.
But I didn't test it on other platforms as I don't have any other platform handy. Please refer to the build process below.
Windows | Linux | |
java lib | wnjn.jar | wnjn.jar |
native libs one of the version-tagged libs below renamed or linked to, this is what wnjn.jar expects |
wnjn.dll | libwnjn.so |
native libs version-tagged libs |
wnjn16.dll wnjn171.dll wnjn20.dll wnjn21.dll |
libwn16jn.so libwn17jn.so
libwn171jn.so libwn20jn.so libwnjn21.so |
You have to have Apache Jakarta Ant and run (in the folder where the build.xml file is to be found):
ant -Dtarget.wnx="21"
Valid wnx targets are "16", "17" or "171" or "20" or "21"
Alternatively you can run the different steps :
step | input | output |
javac -sourcepath <sourcefolder> -d <classfolder> <sourcefolder>/edu/princeton/wordnet/*.java | ||
compile the java source files to classes | edu.princeton.wordnet.Synset.java edu.princeton.wordnet.Index.java edu.princeton.wordnet.WordNet.java |
edu.princeton.wordnet.Synset.class edu.princeton.wordnet.Index.class edu.princeton.wordnet.WordNet.class |
jar cvf <jarfolder>/WordNet.jar -C <classfolder> . | ||
make java archive | edu.princeton.wordnet.Synset.class edu.princeton.wordnet.Index.class edu.princeton.wordnet.WordNet.class |
WordNet.jar (containing zipped input) |
javah -classpath
<classfolder> -d <Cfolder>
edu.princeton.wordnet.Synset javah -classpath <classfolder> -d <Cfolder> edu.princeton.wordnet.Index javah -classpath <classfolder> -d <Cfolder> edu.princeton.wordnet.WordNet |
||
generate the C-header files | edu.princeton.wordnet.Synset.class edu.princeton.wordnet.Index.class edu.princeton.wordnet.WordNet.class |
edu_princeton_wordnet_Synset.h edu_princeton_wordnet_Index.h edu_.princeton_wordnet_WordNet.h |
javap -s -private
-classpath <classfolder> edu.princeton.wordnet.Synset
> Synset.sig javap -s -private -classpath <classfolder> edu.princeton.wordnet.Index > Index.sig javap -s -private -classpath <classfolder> edu.princeton.wordnet.WordNet > Wordnet.sig |
||
generate the signature files (this step can be skipped and is useful for reference only) | edu.princeton.wordnet.Synset.class edu.princeton.wordnet.Index.class edu.princeton.wordnet.WordNet.class |
Synset.sig Index.sig WordNet.sig |
<the command line is platform dependent> | ||
generate the WordNet 1.x library care must be taken to include the bug-fixes |
BINSRCH.C MORPH.C SEARCH.C SETUTIL.C WNGLOBAL.C WNHELP.C WNRTL.C WNUTIL.C LICENSE.H SETUTIL.H WN.H WNGLOBAL.H WNHELP.H WNRTL.H WNTYPES.H WNCONSTS.H |
wnxx.lib or libwnxx.a |
<the command line is platform dependent> | ||
compile the wnjn link with standard libraries and the wn16 library |
WordNet.cpp wnFactory.cpp edu_princeton_wordnet_Index.h edu_princeton_wordnet_Synset.h edu_princeton_wordnet_WordNet.hwnFactory.h |
wnxxxjn.dll or libwnxxxjn.so |
java -classpath <wnjar path>wn.jar -Djava.library.path=<wnjn lib path> Test horse | ||
run | wn.jar wnjn.dll or libwnjn.so |
We owe the Unix makefiles to Ola Åkerberg and Hans
Svensson (e94hsv@efd.lth.se),
two masters thesis students from Lund, Sweden.
wnjn files | comments |
|
this file |
|
Ant file |
|
build command files for the Win32
platform using the JDK _wnjava.jpr is the JBuilder project file (its settings will have to be tuned to the target machine |
|
test application source files |
|
wnjn source files |
|
test application byte-code files |
|
wnjn byte-code files |
|
wnjn jar file containing code |
|
build commands of headers and
signatures form class files |
|
Microsoft Visual C++'s build
files wnjn.dsp is the project file wnjn.dsw is the workspace file wnjn.mak is the command line file wnjn.dep is th dependency file included in wnjn.dep |
|
Unix makefiles |
|
the header files generated the signature files are for reference only and not used in the compile process |
|
C++ native source files (portable) |
|
resource files for versioning (Visual C++) |
|
makefile for Unix |
|
output library |
|
license agreements |
WordNet files | comments |
|
make files for the Microsoft's C++
Compiler wn16.dsp is the project file wn16.mak is the make file |
|
makefiles for Unix |
|
source files |
|
makefile for Unix |
|
include files |
|
output library
|
The tests compile and run fine with the WordNet 2.0 C API files. One
major change with versions as of 1.7 is the addition at the beginning
of the C-structure of a idxoffset, which could mean trouble if the
proper defines and header files are not included.
The distribution has been compiled to WordNet 2.0
The tests compile and run fine with the WordNet 2.1 C API files. One
major change with versions as of 1.7 is the addition at the beginning
of the C-structure of a idxoffset, which could mean trouble if the
proper defines and header files are not included.
The distribution has been compiled to WordNet 2.1
Bernard BOU
Lycée Champollion,
Figeac, France.
This wnjn interface is needed as part of a data provider for my Treebolic engine which will be released later this year. I also authored WordNet TreeWalk (for which I have received very positive feedback):
as well as other various software programs ( http://www.ac-toulouse.fr/bbou)
Ola Åkerberg and Hans
Svensson
Barry Hathaway
When the output yields wninit=-1, the trouble can originate in the following:
The project page at SourceForge is http://sourceforge.net/projects/wnjn . There you will be directed to the CVS or to distribution (Zip file).
If anyone is interested in managing the project I'd also be happy to hand it over.