JWNL Properties File Configuration
A JWNL Properties file is an XML file that is parsed using the following DTD:
If you're not familiar with XML or with how to read a DTD, look at the example properties files included in
the distribution. Basically, the properties file allows you to specify 4 properties:
- Dictionary class: This defines the class used to interface with the dictionary. The JWNL v1.1 distribution comes
with two dictionary classes - MapBackedDictionary and FileBackedDictionary. Exactly 1 dictionary tag is required in
a properties file. If there are more than one, the first one will be used.
..parameters
- Version: Gives information on the version of WordNet being interfaced with. Excactly 1 version tag is required
in a properties file.
where [language] and [country] are used to specify the locale whose language is covered by the dictionary. If these tags are not included, the default locale is assumed. See the Java documentation for java.util.Locale for information on locales. The "path" tag is required.
- Dictionary Element Factory: This defines the class used to create Dictionary Elements (IndexWords, Synsets, Exceptions)
from lines in the dictionary. The JWNL v1.1 distribution comes with two Dictionary Element Factories in the "princeton"
package - one for Princeton WordNet version 1.6 and one for Princeton WordNet version 1.7. Exactly 1
dictionary_element_factory tag is required in a properties file.
..parameters
- Resources: A resource file contains mapping between keys and text used in the program. Typically, this text is
error or status messages. Resource files are used so that a program can be used with different (spoken) languages
without having to modify the code. See the Java documentation for java.util.ResourceBundle on how to name your resource files. You can specify as many resources as you want.
In the top-level tag, you can specify the language and country to use for resolving resources. For example:
..properties
tells the program to print all messages in American English (a resource file containing these messages has to be
present, of course).
You'll notice that and allow you to provide parameters. Parameters are of the
form:
..nested parameters
Parameters are provided to the install method of the class. Parameters can be nested. For example:
A set of params like this most likely means that an instance of net.didion.stuff.Money is going to be created,
and that its constructor will be passed "USD" as a parameter.
The valid parameters for each class are specified in that class's documentation. I would encourage you to
follow this convention of documenting valid parameters in the class documentation of any classes you
write that take parameters.
** Note: If you are getting a parse error when you try to call JWNL.initialize(), you may have to change the path of the dtd file in the DOCTYPE tag of your properties xml file. Currently, it looks like this:
You may need to change it to this:
or this:
where is the path where you installed the jwnl package.