|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||
See:
Description
| Packages | |
|---|---|
| edu.mit.jwi | Provides the main dictionary interface and a default implementation. |
| edu.mit.jwi.data | Provides classes and interfaces for the creation, searching, and interpretation of dictionary data sources. |
| edu.mit.jwi.data.compare | Provides classes that encode the sorting order of the Wordnet data file lines, to enable binary searching. |
| edu.mit.jwi.data.parse | Provides classes and interfaces that deal with parsing individual lines from Wordnet files. |
| edu.mit.jwi.item | Provides classes and interfaces that represent the Wordnet data structures. |
| edu.mit.jwi.morph | Provides several simple classes that can be used to find the stems of words using Wordnet. |
The MIT Java Wordnet Interface (JWI) was designed to be an easy-to-use, easy-to-extend Java library for interfacing with the Wordnet electronic dictionary. It features API calls to retrieve index entries, synsets, morphological exceptions, and sense index entries from the Wordnet data files. It also has calls that allow browsing by following lexical and semantic pointers, and contains classes that can perform simple morphological processing. The library includes no GUI elements.
JWI is compatible with Wordnet versions 1.6 through 3.0. It is not compatible with Wordnet 1.5. Wordnet itself is not included with the JWI distribution, but rather must be downloaded separately from the Wordnet site at http://wordnet.princeton.edu.
The freely available version of JWI is licensed for use for non-commercial purposes only, as long as proper acknowledgment is made. Details can be found in the license, which is included in the distribution. The copyright on the software is owned by MIT; if you wish to use the software for commercial purposes, please contact the MIT Technology Licensing Office for more information on how to obtain a commercial license.
The entry point for accessing dictionary data is the
edu.mit.jwi.IDictionary interface. JWI comes with a single
default implementation of this interface in the same package, the
Dictionary class. In the simplest case, where you are using Wordnet
with the data files on the same filesystem as your Java program, you can
instantiate the Dictionary class with a single argument, a URL object
that points to the directory where the Wordnet dictionary data files are
located.
An example of this can be found below, in the form of a Java method
runExample(). In the method, the first block of seven lines (4-9) deals
with constructing a URL object that points to the Wordnet data files.
In this particular example, the base Wordnet directory is assumed to be stored
in a system environment variable called WNHOME; this may be different on your
system. Note that the WNHOME variable points to the root of the Wordnet
installation directory and the dictionary data directory “dict” must be
appended to this path. Again, this may be different on your system depending
on where your Wordnet files are located. The second block of code, two lines
long (12-13), constructs an instance of the default Dictionary object, and
opens it by calling the open() method. The final block of six lines
(16-21) demonstrates searching the dictionary for the first sense of the noun
“dog”. The final numbered block of code shows the console output of the method.
Sample Dictionary code:
1 public void runExample(){
2
3 // construct the URL to the Wordnet dictionary directory
4 String wnhome = System.getenv("WNHOME");
5 String path = wnhome + File.separator + "dict";
6 URL url = null;
7 try{ url = new URL("file", null, path); }
8 catch(MalformedURLException e){ e.printStackTrace(); }
9 if(url == null) return;
10
11 // construct the dictionary object and open it
12 IDictionary dict = new Dictionary(url);
13 dict.open();
14
15 // look up first sense of the word "dog"
16 IIndexWord idxWord = dict.getIndexWord("dog", PartOfSpeech.NOUN);
17 IWordID wordID = idxWord.getWordIDs()[0];
18 IWord word = dict.getWord(wordID);
19 System.out.println("Id = " + wordID);
20 System.out.println("Lemma = " + word.getLemma());
21 System.out.println("Gloss = " + word.getGloss());
22
23 }
Output (for Wordnet 3.0)
1 Id = WID-2084071-n-?-dog 2 Lemma = dog 3 Gloss = a member of the genus Canis (probably descended from the common wolf) ...
|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||