MnM Developer Guide

Table of Contents

0 Introdution

1 Plugin Architecture
1.1 Generic Plugin Interface
1.2 Engine Plugin
1.3 Ontology Plugin
1.3.1 Server Ontology Plugin
1.3.2 Url Ontology Plugin

2 Miscellaneous
2.1 IEInstace and IEInstanceSlot
2.2 IEOutput
2.3 IERange


3 What's Next

4 Conclusion

5 Contacts


0 Introduction

Welcome to MnM2's world!

In order to allow a certain degree of scalability and reusability a plugin mechanism has been implemented into MnM2. With this mechanism MnM2 can now accept plugins to interact with Ontologies defined by the user and plugins to use Information Extraction mechanism different from the one provided by default.
Plugins are dynamically loaded modules that can be loaded at the execution time (rather than compilation time), and thus allow developers to extend the functionality of the original application.

Thank you for your interest in this application.


1 Plugin Architecture

The plugin architecture adopted by MnM2 is very simple but yet very effective. All plugins must implement a generic interface defined in the package edu.ou.kmi.mnm2.core.plugin.IEPlugin. To make the life of the plugin developer a bit easier two abstract classes, implementing the IEPlugin interface, are provided.
The first abstract class is edu.ou.kmi.mnm2.core.plugin.IEEnginePlugin, this class defines the methods required by MnM2 to deal with IE mechanism.
The second abstract class is edu.ou.kmi.mnm2.core.plugin.IEOntologyPlugin and provides the methods that MnM2 needs to interact with Ontologies. IEOntologyPlugin provide also two additional subtypes of plugin: edu.ou.kmi.mnm2.core.plugin.IEOntoServerPlugin, to interact with ontologies stored on a server, and edu.ou.kmi.mnm2.core.plugin.IEOntoUrlPlugin, to work with ontologies stored on urls.
Thanks to these classes the plugin developer will have only to extend them and override the main methods; a simple implementation for the basic methods has been already defined.

Plugins are contained in jar files and placed in the Plugins directory (see MnM User Manual, section 1.4.1). At the start-up MnM2 loads each file from the Plugins directory and analyzes it in order to find the main class in the package. The plugin is then added to a specific list of plugins according to its type. These lists are then consulted when needed.

Plugins are deployed in the form of a jar file. After the jar file is created, it has to be placed in the Plugins directory. A manifest file has to be provided in the jar file and it must contain an entry for the main class. For example: the plugin for the XYZ IE mechanism is placed in a jar file called XYZ.jar and the manifest file inside it contains the following line: Main-Class: edu.ou.kmi.xyz.XYZPlugin.

The directory MnM2/Java/lib contains some common libraries (XML and RDF parser, Look&Feel, ...) that might be useful also to plugin developers, and it is already part of the classpath for MnM. So to keep the size of the plugins to a minimum, feel free to use the libraries already provided in the above directory.

Note: to develop plugins for MnM2, Java 1.4.1 or higher is required.

1.1 Generic Plugin Interface

The generic plugin interface IEPlugin defines the basics functionalities that a plugin must provide. Each plugin must have:
- a type: at the moment only two types of plugins are accepted by MnM2: ENGINE_PLUGIN, for Information Extraction mechanism, and ONTOLOGY_PLUGIN, for Ontology interaction. A type is defined by the static class IEPlugin.PluginType.
- a name: the name of the plugin. Must be unique, because it is also used as a key to find the corresponding plugin in the list of available plugins generated by MnM2 during the start-up.
- a configurator: it is a subclass of javax.swing.JPanel, that deals with the preferences of the plugin to which it belongs to. In this way the plugin developer is responsible to take care of the needs of the plugin. This should keep the plugin and its settings indipendent from MnM2.
- an icon: the icon to be used by MnM2 so that the final user can easily identify the plugin just by looking at its icon. Supported formats for the icon are .gif and .jpeg. The icon is an instance of javax.swing.ImageIcon.
- an about: it is a string, formatted in plain text or HTML, containing information about the plugin.

/**
 *  Generic interface that defines the basics functionalities
 *  that a plugin for MnM must have.
 *
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    12 March 2003
 */
public interface IEPlugin {
    /**
     *  This class is used to define the types of plugins accepted by MnM:
     *  - ENGINE_PLUGIN: plugin to deal with the different IE mechanisms. Most
     *  of the times it is only a wrapper class that maps the functionalities of
     *  the IE mechanism into the operational behaviour of MnM;
     *  - ONTOLOGY_PLUGIN: plugin to deal with the different types of ontologies
     *  that is possible to encouter in real life
     *
     * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
     * @created    12 March 2003
     */
    public static class PluginType { private PluginType() { } }

    /**
     *  ENGINE_PLUGIN: identifies the plugins for IE mechanisms.
     */
    public final static PluginType ENGINE_PLUGIN = new PluginType();
    /**
     *  ONTOLOGY_PLUGIN: identifies the plugins for reading/writing ontologies.
     */
    public final static PluginType ONTOLOGY_PLUGIN = new PluginType();

//GET METHODS
    /**
     *  Gets the About information for the specific pluging. The information can
     *  be formatted in plain text or html.
     *
     * @return  The information to be displayed in the about panel.
     */
    public String getAbout();

    /**
     *  Gets the plugin configurator: a subclass of JPanel that deals with the preferences
     *  of the Plugin. In this way the plugin should be indipendent
     *
     * @return    The configurator value
     */
    public IEPluginConfigurator getConfigurator();

    /**
     *  Gets the icon to be used
     *
     * @return    The icon value
     */
    public ImageIcon getIcon();

    /**
     *  Gets the name of the plugin
     *
     * @return    The name value
     */
    public String getName();

    /**
     *  Gets the type of the plugin
     *
     * @return    The type value
     */
    public PluginType getType();


//SET METHODS
    /**
     *  Sets the About information for the specific pluging. The information can
     *  be formatted in plain text or html.
     *
     * @param  about  The information to be displayed in the about panel.
     */
    public void setAbout(String about);

    /**
     *  Sets the plugin configurator: a subclass of JPanel that deals with the preferences
     *  of the Plugin. In this way the plugin should be indipendent
     *
     * @param  configurator  The new configurator value
     */
    public void setConfigurator(IEPluginConfigurator configurator);

    /**
     *  Sets the icon to be used
     *
     * @param  icon  The new icon value
     */
    public void setIcon(ImageIcon icon);

    /**
     *  Sets the name of the plugin
     *
     * @param  name  The new name value
     */
    public void setName(String name);

    /**
     *  Sets the type of the plugin
     *
     * @param  type  The new type value
     */
    public void setType(PluginType type);
}
Table 1.1a: IEPlugin.java

The configurator (edu.ou.kmi.mnm2.core.plugin.IEPluginConfigurator) is a subclass of javax.swing.JPanel, that deals with the preferences of the plugin to which it belongs to. In this way the plugin developer is responsible to take care of the needs of the plugin. This should keep the plugin and its settings indipendent from MnM2. The configurator of a plugin is show every time the user decides to modify the settings of the application and opens the Preferences dialog (Settings>Preferences... from the menubar). In this dialog the plugin configurators are grouped according to their IEPlugin.PluginType. After the user has done his job, he can decide whether to apply the changes (OK button), to go back to the default settings (Default button) or to discard the changes (Cancel button).
The functionalities provided by IEPluginConfigurator are:
- applySettings(): called when the user decides to apply the changes;
- applyDefaultSetting(): called when the user wants to go back to the default settings;
- discardSettings(): called when the user discards the tchanges.

/**
 *  Subclass of JPanel that deals with the preferences
 *  of the plugin. In this way the plugin should be indipendent
 *
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    12 March 2003
 */
public abstract class IEPluginConfigurator extends JPanel {
    /**
     *  Apply the settings defined by the user
     */
    public abstract void applySettings();
   
    /**
     *  Apply the default settings
     */
    public abstract void applyDefaultSettings();
   
    /**
     *  Discard the settings defined by the user.
     */
    public abstract void discardSettings();
}
Table 1.1b: IEPluginConfigurator.java

1.2 Engine Plugin

This type of plugin is used to deal with the different Information Extraction mechanism available in the real world. Since it is quiet unlikely that an entire IE mechanism can be implemented as a plugin, most of the times the plugins of this type are just wrappers that map the functionalities of the IE mechanism into the operational behaviour of MnM.
All the plugins of type ENGINE_PLUGIN must extend the abstract class edu.ou.kmi.mnm2.core.plugin.IEEnginePlugin. This class defines the needed functionalities and provides also a simple implementation for the basic methods defined in the IEPlugin interface. Functionalities:
- init(): called when the IE mechanism is to be initialized;
- extract(...): called to start the extraction phase;
- learn(...): called to start the learning phase;
- stop(): called to stop the current process (extract or learn);
- createScenario(...): called to set all the parameters that can be useful to configure a Scenario. Note that in this case the plugin will have only to provide the content of the configuration file, MnM2 is in charge to save it in the proper location;
- retrieveResults(): called to retrieve the results of the extraction or learning phase. The results are organized as an array of IEInstance objects;
- getTestCorpusDir() and setTestCorpusdir(...): get/set the test corpus directory (the folder where the non-annotated documents are stored). The test corpus is used during the extraction phase. The implementation for these methods is already provided;
- getTrainingCorpusDir() and setTrainingCorpusDir(...): get/set the training corpus directory (the folder where annotated documents are stored). The training corpus is used during the learning phase. The implementation for these methods is already provided.
- toString(): returns the name of the plugin (same behaviour as getName()). The implementation for this method is already provided.

/**
 *  This abstract class defines the basic functionalities that an ENGINE_PLUGIN
 *  must have. It also specifies some of the methods that are defined in the
 *  IEPlugin interface
 *
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    12 March 2003
 */
public abstract class IEEnginePlugin implements IEPlugin {
    /**
     *  Initializes the IE mechanism
     */
    public abstract void init();

    /**
     *  Starts the extraction phase
     *
     * @param  scenarioName  contains the path of the scenario to be used
     * @param  showDialog    true if the progress dialog has to be displayed
     */
    public abstract void extract(String scenarioName, boolean showDialog);

    /**
     *  Starts the learning phase
     *
     * @param  scenarioName  contains the path of the scenario to be used
     * @param  showDialog    true if the progress dialog has to be displayed
     */
    public abstract void learn(String scenarioName, boolean showDialog);

    /**
     *  Stops the current process (learn or extract)
     */
    public abstract void stop();

    /**
     *  Set all the parameters that can be useful to define a Scenario
     *
     * @param  fullSlots  array containing the full-name for each Slot
     * @param  slots      array containing the short-name for each Slot
     * @param  tags       array containing the tag used for each Slot
     * @param  types      array containing the type of each Slot
     * @param  colors     array containing the color of each Slot
     * @param  oName      name of the ontology
     * @param  cName      name of the class
     * @param  mName      mnemonic name for the class
     * @param  baseDir    directory in which the Scenario file is going to be stored
     *
     * @return            Returns the content of the scenario to be created
     */
    public abstract String createScenario(String[] fullSlots, String[] slots, String[] tags, String[] types, Color[] colors, String oName, String cName, String mName, String baseDir);

    /**
     *  Retrieve the results of the extraction or learning phase. The results are stored
     *  in an array of IEInstance
     *
     * @return    an array of IEInstance objects
     */
    public abstract IEInstance[] retrieveResults();

    /**
     *  Returns the name of the plugin
     *
     * @return    the name of the plugin
     */
    public String toString() { ... }

//GET METHODS
    /**
     *  Returns the directory where the documents for the testing phase are stored
     *
     * @return    The testCorpusDir
     */
    public String getTestCorpusDir() { ... }


    /**
     *  Returns the directory where the documents for the training phase are stored
     *
     * @return    The trainingCorpusDir
     */
    public String getTrainingCorpusDir() { ... }


    /**
     *  Gets the About information for the specific pluging. The information can
     *  be formatted in plain text or html.
     *
     * @return  The information to be displayed in the about panel.
     */
    public String getAbout() { ... }

    /**
     *  Returns the plugin configurator: a subclass of JPanel that deals with the preferences
     *  of the plugin
     *
     * @return    The configurator
     */
    public IEPluginConfigurator getConfigurator() { ... }


    /**
     *  Returns the icon to be used
     *
     * @return    The icon
     */
    public ImageIcon getIcon() { ... }


    /**
     *  Returns the name of the plugin
     *
     * @return    the name of the plugin
     */
    public String getName() { ... }


    /**
     *  Returns the PluginType of the plugin
     *
     * @return    the PluginType
     */
    public IEPlugin.PluginType getType() { ... }


//SET METHODS
    /**
     *  Sets the About information for the specific pluging. The information can
     *  be formatted in plain text or html.
     *
     * @param  about  The information to be displayed in the about panel.
     */
    public void setAbout(String about) { ... }

     /**
     *  Sets the directory where the documents for the testing phase are stored
     *
     * @param  dir  The new testCorpusDir value
     */
    public void setTestCorpusDir(String dir) { ... }


    /**
     *  Sets the directory where the documents for the training phase are stored
     *
     * @param  dir  The new trainingCorpusDir value
     */
    public void setTrainingCorpusDir(String dir) { ... }


    /**
     *  Sets the plugin configurator: a subclass of JPanel that deals with the preferences
     *  of the plugin
     *
     * @param  configurator  The new configurator value
     */
    public void setConfigurator(IEPluginConfigurator configurator) { ... }


    /**
     *  Sets the icon to be used
     *
     * @param  icon  The new icon value
     */
    public void setIcon(ImageIcon icon) { ... }


    /**
     *  Sets the name of the plugin
     *
     * @param  name  The new name value
     */
    public void setName(String name) { ... }


    /**
     *  Sets the PluginType of the plugin
     *
     * @param  type  the PluginType
     */
    public void setType(IEPlugin.PluginType type) { ... }

}
Table 1.2: IEEnginePlugin.java

1.3 Ontology Plugin

This type of plugin is used to describe the behaviour of generic Ontologies. The abstract class edu.ou.kmi.mnm2.core.plugin.IEOntologyPlugin implements the interfaces provided by IEPlugin and edu.ou.kmi.mnm2.core.output.IEOutput. The latter, IEOutput, is used to provide a common interface for output operation that  maybe requested to an ontology plugin (commit, print and save functionalities for generated instances after having formatted them according to the ontology needs). IEOntologyPlugin defines the needed functionalities and provides also a simple implementation for the basic methods defined in the IEPlugin interface. Each plugin of type ONTOLOGY_TYPE must provide the following:
- subtype: at the moment only two sub-types of ontology plugins are accepted by MnM2: ONTO_SERVER, to interact with ontologies stored on a server, and ONTO_URL, to interact with ontologies stored in files. A sub-type is defined by the static class IEOntologyPlugin.PluginSubType.
- getOntologies(), getClasses(...), getInstances(...) and getSlots(...): these methods get respectively the list of ontologies, classes, instances and slots available in the current Ontology. Note that in the array returned by getSlots() each element contains the name and the type of the slot separated by a "¬" character. Example: <slot_name1>¬<slot_type1>.
- getInstanceData(...): returns an instance of the IEInstance object containing all the information related to a specific instance of a paticular class in a given ontology.
- getOntologyInfo(...), getClassInfo(...), getInstanceInfo(...),getSlotInfo(...) and getUnknownInfo(...): get the information related respectively to an ontology, a class, an instance and a slot. getUnknownInfo() is used whenever is required information about an unidentified object (this object could be an ontology, a class, an instance or a slot). The returned information is a string formatted in HTML.
- removeInstance(...) and removeInstances(...): called to remove an instance or a set of instances from the current Ontology.
- renameInstance(...): called to rename an instance  in the current Ontology.
- format(...): formats an IEInstance object according to the needs of the current Ontology.
- commit(): commits the formatted instance to the current Ontology.
- print(): prints the formatted instance to the standard output (DEBUG).
- save(...): saves the formatted instance in a local file.
- toString(): returns the name of the plugin (same behaviour as getName()). The implementation for this method is already provided.

Note: see 2.1 for further information about IEInstance and 2.2 for more information about IEOutput.

/**
 *  This abstract class defines the basic functionalities that an ONTOLOGY_PLUGIN
 *  must have. It also specifies some of the methods that are defined in the
 *  IEPlugin interface. This class implements also the IEOutput interfaces to deal
 *  with output operations (commit, print, save).
 *
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    12 March 2003
 */
public abstract class IEOntologyPlugin implements IEOutput, IEPlugin {
    /**
     *  This class is used to define the sub-types of an ONTOLOGY_PLUGIN accepted by MnM:
     *  - ONTO_SERVER: plugin to deal with ontologies stored on a server (see WebOnto);
     *  - ONTO_URL: plugin to deal with ontologies stored on a file (RDF, Daml+Oil, OWL);
     *
     * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
     * @created    12 March 2003
     */
    public static class PluginSubType {    private PluginSubType() {}    }

    /**
     *  ONTO_SERVER: identifies the plugins for ontologies stored on a server
     */
    public final static PluginSubType ONTO_SERVER = new PluginSubType();
    /**
     *  ONTO_URL: identifies the plugins for ontologies stored on files
     */
    public final static PluginSubType ONTO_URL = new PluginSubType();

//INPUT METHODS
    //GET ELEMENTS
    /**
     *  Returns an array of ontologies in the active server/url
     *
     * @return                  an array containing the name of the ontologies
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract Object[] getOntologies() throws IOException;

    /**
     *  Returns an array of classes given the ontology name
     *
     * @param  ontology_name    the ontology
     * @return                  an array containing the name of the classes
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract Object[] getClasses(String ontology_name) throws IOException;

    /**
     *  Returns an array of instances given the ontology and class name
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @return                  an array containing the name of the instances
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract Object[] getInstances(String ontology_name, String class_name) throws IOException;

    /**
     *  Returns an array of slots given the ontology and class name.  Each element in the
     *  array must contain the name and the type of the slot separated by a "¬" character.
     *  Example: <slot_name1>¬<slot_type1>
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @return                  an array containing the name and the type of the slots
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract Object[] getSlots(String ontology_name, String class_name) throws IOException;

    //GET ELEMENTS' DATA
    /**
     *  Returns the instance data about a particular instance in a given class and ontology
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @param  instance_name    the instance
     * @return                  the IEInstance object associated to the instance
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract IEInstance getInstanceData(String ontology_name, String class_name, String instance_name) throws IOException;

    //GET ELEMENTS' INFO
    /**
     *  Returns the information about a particular ontology in html format
     *
     * @param  ontology_name    the ontology
     * @return                  the information formatted in html
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract String getOntologyInfo(String ontology_name) throws IOException;

    /**
     *  Returns the information about a particular class in a given ontology
     *  in html format
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @return                  the information formatted in html
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract String getClassInfo(String ontology_name, String class_name) throws IOException;

    /**
     *  Returns the information about a particular instance in a given class and ontology
     *  in html format
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @param  instance_name    the instance
     * @return                  the information formatted in html
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract String getInstanceInfo(String ontology_name, String class_name, String instance_name) throws IOException;

    /**
     *  Returns the information about a particular slot in a given class and ontology
     *  in html format
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @param  slot_name        the slot
     * @return                  the information formatted in html
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract String getSlotInfo(String ontology_name, String class_name, String slot_name) throws IOException;

    /**
     *  Returns the information about an unknown concept in a given ontology in html format
     *
     * @param  ontology_name    the ontology
     * @param  unknown_name     the unknown concept
     * @return                  the information formatted in html
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract String getUnknownInfo(String ontology_name, String unknown_name) throws IOException;

//ACTION METHODS
    /**
     *  Removes an instance of a given class from an ontology
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @param  instance_name    the instance
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void removeInstance(String ontology_name, String class_name, String instance_name) throws IOException;

    /**
     *  Removes a set instances of a given class from an ontology
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @param  instances        an array of instance_name
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void removeInstances(String ontology_name, String class_name, String[] instances) throws IOException;

    /**
     *  Rename an instance
     *
     * @param  ontology_name    the ontology
     * @param  class_name       the class
     * @param  new_instance     the new name
     * @param  old_instance     the old name
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void renameInstance(String ontology_name, String class_name, String new_instance, String old_instance) throws IOException;

//OUTPUT METHODS
    /**
     *  Given a IEInstance object creates the output formatted according to the ontology
     *  requirements
     *
     * @param  instance the instance data
     * @param  mode     - MOD_INSTANCE: in case of a modified instance;
     *                  - NEW_INSTANCE: in case of a new instance.
     */
    public abstract void format(IEInstance instance, IEOutput.Mode mode);

    /**
     *  Formats the output given a String object
     *
     * @param  content  the content
     */
    public void format(String content) { }

    /**
     *  Prints the output to the stdout
     */
    public abstract void print();

    /**
     *  Saves the output in the specified file
     *
     * @param  file             the pathname
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void save(String file) throws IOException;

    /**
     *  Commits the output to the active ontology
     *
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void commit() throws IOException;

    /**
     *  Returns the offset given by the length of the header
     *
     * @return    The offset value
     */
    public int getOffset() { ... }


    /**
     *  Returns the name of the plugin
     *
     * @return    the name of the plugin
     */
    public String toString() { ... }


//GET METHODS
    /**
     *  Gets the About information for the specific pluging. The information can
     *  be formatted in plain text or html.
     *
     * @return  The information to be displayed in the about panel.
     */
    public String getAbout() { ... }

     /**
     *  Returns the plugin configurator: a subclass of JPanel that deals with the preferences
     *  of the plugin
     *
     * @return    The configurator value
     */
    public IEPluginConfigurator getConfigurator() { ... }


    /**
     *  Returns the icon to be used
     *  Gets the icon attribute of the IEOntologyPlugin object
     *
     * @return    The icon value
     */
    public ImageIcon getIcon() { ... }


    /**
     *  Returns the name of the plugin
     *
     * @return    the name of the plugin
     */
    public String getName() { ... }


    /**
     *  Returns the PluginType of the plugin
     *
     * @return    the PluginType
     */
    public IEPlugin.PluginType getType() { ... }


    /**
     *  Returns the PluginSubType of the plugin
     *
     * @return    the PluginSubType
     */
    public PluginSubType getSubType() { ... }


//SET METHODS
    /**
     *  Sets the About information for the specific pluging. The information can
     *  be formatted in plain text or html.
     *
     * @param  about  The information to be displayed in the about panel.
     */
    public void setAbout(String about) { ... }

    /**
     *  Sets the plugin configurator: a subclass of JPanel that deals with the preferences
     *  of the plugin
     *
     * @param  configurator  The new configurator value
     */
    public void setConfigurator(IEPluginConfigurator configurator) { ... }


    /**
     *  Sets the icon to be used
     *
     * @param  icon  The new icon value
     */
    public void setIcon(ImageIcon icon) { ... }


    /**
     *  Sets the name of the plugin
     *
     * @param  name  The new name value
     */
    public void setName(String name) { ... }


    /**
     *  Sets the PluginType of the plugin
     *
     * @param  type  the PluginType
     */
    public void setType(IEPlugin.PluginType type) { ... }


    /**
     *  Sets the PluginSubType of the plugin
     *
     * @param  subType  the PluginSubType
     */
    public void setSubType(PluginSubType subType) { ... }
}

Table 1.3: IEOntologyPlugin.java

1.3.1 Server Ontology Plugin

This sub-type of plugin is used to interact with ontologies stored on a server. All the plugins of sub-type ONTO_SERVER must extend the abstract class edu.ou.kmi.mnm2.core.plugin.IEOntoServerPlugin. This class defines the functionalities needed to deal with logging into the server, host name and host port. Functionalities:
- initializeServer(...): called when attempting to connect to the ontology server.
- logIntoServer(...): called to log into the server after a connection has been established.
- createKB(...): creates a new Knowledge Base in the ontology server.
- getOntoTypes() and setOntoTypes(...): get/set the types of ontology (domain, application, task, ...) accepted by the current ontology server. The implementation for these methods is already provided.
- getHostName() and setHostName(...): get/set the host name. The implementation for these methods is already provided.
- getHostPort() and setHostPort(...): get/set the host port. The implementation for these methods is already provided.

/**
 *  This abstract class describe one of the sub-types available for the
 *  ONTOLOGY_PLUGIN type: SERVER_URL.
 *  This specific sub-type of plugin deals with ontologies stored on a server
 *  and example can be WebOnto. It specifies some methods to initialize the
 *  server, to login into it ontolgy, create and load a knowledge
 *  base, and others...
 *
 * @author     Mattia Lazoni
 * @created    13 March 2003
 */
public abstract class IEOntoServerPlugin extends IEOntologyPlugin {
    /**
     *  Method called to initialize the server, given the host_name and host_port
     *
     * @param  host_name        the name of the host
     * @param  host_port        the port of the host
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void initializeServer(String host_name, int host_port) throws IOException;

    /**
     *  Creates a new Knowledge Base in the server
     *
     * @param  ontology_name    the name for the new KB
     * @param  parents          a comma separated list of parents for the new KB
     * @param  editors          a comma separeted list of additional editors for the KB
     * @param  type             the type of the new ontology
     * @return                  the reply of the server
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract String createKB(String ontology_name, String parents, String editors, String type) throws IOException;


    /**
     *  Method used to log into the server
     *
     * @param  login            the login
     * @param  password         the password
     * @return                  the reply from the server
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract String logIntoServer(String login, String password) throws IOException;

//GET METHODS
    /**
     *  Gets the list of types of KB accepted by the server
     *
     * @return    the list of types
     */
    public String[] getOntoTypes() { ... }


    /**
     *  Gets the host_name of the server
     *
     * @return    the host_name
     */
    public String getHostName() { ... }


    /**
     *  Gets the host_port of the server
     *
     * @return    the host_port
     */
    public int getHostPort() { ... }


//SET METHODS
    /**
     *  Sets the types of KB accepted by the server
     *
     * @param  ontoTypes  an array containing the types
     */
    public void setOntoTypes(String[] ontoTypes) { ... }


    /**
     *  Sets the host_name of the server
     *
     * @param  host_name  the host_name
     */
    public void setHostName(String host_name) { ... }


    /**
     *  Sets the host_port of the server
     *
     * @param  host_port  the host_port
     */
    public void setHostPort(int host_port) { ... }
}

Table 1.3.1: IEOntoServerPlugin.java

1.3.2 Url Ontology Plugin

This sub-type of plugin is used to interact with ontologies stored on a url. All the plugins of sub-type ONTO_URL must extend the abstract class edu.ou.kmi.mnm2.core.plugin.IEOntoUrlPlugin. Functionalities:
- initializeUrl(...): called to initialize the ontology.
- createKB(...) and loadKB(...): called to create a new Knowledge Base or to load an existing one.
- isKBDefined(): checks if a Knowledge Base has been defined. The implementation for this method is already provided.
- getExtensions() and setExtensions(...): get/set the file extension for the current Ontology. The implementation for these methods is already provided.
- getDescription() and setDescription(...): get/set the file description for the current Ontology. The implementation for these methods is already provided.
- getOntologyUrl() and setOntologyUrl(...): get/set the URL of the current Ontology. The implementation for these methods is already provided.
- getInstanceUrl() and setOntologyUrl(...): get/set the URL of the current Knowledge Base. The implementation for these methods is already provided.

/**
 *  This abstract class describe one of the sub-types available for the
 *  ONTOLOGY_PLUGIN type: ONTO_URL.
 *  This specific sub-type of plugin deals with ontologies stored on a file
 *  and formatted according to a specific standard (RDF, Daml+Oil, OWL, ...). It
 *    specifies some methods to initialize the ontolgy, create and load a knowledge
 *  base, and others...
 *
 * @author     Mattia Lazoni
 * @created    13 March 2003
 */
public abstract class IEOntoUrlPlugin extends IEOntologyPlugin {
    /**
     *  Method called to initialize the ontology stored on the specified URL
     *
     * @param  url              the url of the ontology to load
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void initializeUrl(String url) throws IOException;

    /**
     *  Creates a new Knowledge Base to be stored at the specified URL
     *
     * @param  url              the url where the new KB will be saved
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void createKB(String url) throws IOException;

    /**
     *  Loads a Knowledge Base froma the specified URL
     *
     * @param  url              the url from which to load the KB
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public abstract void loadKB(String url) throws IOException;

//PUBLIC METHODS
    /**
     *  Checks if a Knowledge Base has been defined (created or loaded)
     *
     * @return    true if the KB has been already defined
     */
    public boolean isKBDefined() { ... }

//GET METHODS
    /**
     *  Gets the file extensions to be used when saving/loading the ontology and KB
     *
     * @return    an array containing the extensions
     */
    public String[] getExtensions() { ... }


    /**
     *  Gets the description of the file format to be used when saving/loading
     *  the ontology and KB
     *
     * @return    the description
     */
    public String getDescription() { ... }


    /**
     *  Gets the URL of the ontology
     *  This method will not be called directly by MnM. It is meant to be used inside
     *  the source code of the plugin itself.
     *
     * @return    the URL
     */
    public String getOntologyUrl() { ... }


    /**
     *  Gets the URL of the Knowledge Base
     *  This method will not be called directly by MnM. It is meant to be used inside
     *  the source code of the plugin itself.
     *
     * @return    the URL
     */
    public String getInstanceUrl() { ... }


//SET METHODS
    /**
     *  Sets the file extensions to be used when saving/loading the ontology and KB
     *
     * @param  extensions  an array containing the extensions
     */
    public void setExtensions(String[] extensions) { ... }


    /**
     *  Sets the description of the file format to be used when saving/loading
     *  the ontology and KB
     *
     * @param  description  the description
     */
    public void setDescription(String description) { ... }


    /**
     *  Sets the URL of the ontology
     *  This method will not be called directly by MnM. It is meant to be used inside
     *  the source code of the plugin itself.
     *
     * @param  ontologyUrl  the URL
     */
    public void setOntologyUrl(String ontologyUrl) { ... }

    /**
     *  Sets the URL of the Knowledge BAse
     *  This method will not be called directly by MnM. It is meant to be used inside
     *  the source code of the plugin itself.
     *
     * @param  instanceUrl  the URL
     */
    public void setInstanceUrl(String instanceUrl) { ... }

}
Table 1.3.2: IEOntoUrlPlugin.java


2 Miscellaneous

This chapter will introduce some classes that are not part of the plugin architecture, but may be useful to the plugin developer. These classes can be the return value or a paramater to be passed  to one or more methodes introduced in the previous chapters. These classes are: IEInstance (describes an Instance in the Ontology), IEInstanceSlot (describe a Slot of an Instance in the Ontology), IEOutput (an interface describing the output behaviour that an ontology plugin must have) and IERange (describes the position of a piece of text in a document).

2.1 IEInstace and IEInstanceSlot

The class edu.ou.kmi.mnm2.core.IEInstance describes an Instance in the current Ontology. It has the following attributes:
- ontology_name: the name of the ontology;
- class_name: the name of the class;
- instance_name: the name of the instance;
- file_name: the place where the instance is located. It is a file in case of IEOntoUrlPlugin. It is <host_name>:<host_port> in case of IEOntoServerPlugin.
- an array of Slots (edu.ou.kmi.mnm2.core.EInstanceSlot): one entry for each Slot in the Class.

/**
 *  This class describe MnM's internal representation of an instance: each instance
 *  has its unique name, belongs to a particular class in a specific ontology and
 *  has an array of slots of type IEInstanceSlot. The typical attributes of an
 *  IEInstanceSlot object are: name, type, tag and color.
 *  Optionally, it is possible to specify where the instance is going to be saved
 *  (fileName).
 *  This class also contains some methods to initialize and retrieve the array of
 *  slots, and some other methods to get a specific slot give its position in the
 *  array, its name or its tag.
 * 
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    17 March 2003
 */
public class IEInstance {
    /**
     *Constructor for the IEInstance object
     */
    public IEInstance() { ... }


    /**
     *Constructor for the IEInstance object
     *
     * @param  ontoName   name of the ontology
     * @param  className  name of the class
     */
    public IEInstance(String ontoName, String className) { ... }


    /**
     *Constructor for the IEInstance object
     *
     * @param  ontoName      name of the ontology
     * @param  className     name of the class
     * @param  instanceName  name of the instance
     */
    public IEInstance(String ontoName, String className, String instanceName) { ... }


    /**
     *Constructor for the IEInstance object
     *
     * @param  ontoName      name of the ontology
     * @param  className     name of the class
     * @param  instanceName  name of the instance
     * @param  fileName      path of the instance
     */
    public IEInstance(String ontoName, String className, String instanceName, String fileName) { ... }


//GET METHODS
    /**
     *  Gets the name of the ontology to which the instance belong to
     *
     * @return    the name of the ontology
     */
    public String getOntoName() { ... }


    /**
     *  Gets the name of the class to which the instance belong to
     *
     * @return    the name of the class
     */
    public String getClassName() { ... }


    /**
     *  Gets the name of the instance
     *
     * @return    the name of the instance
     */
    public String getInstanceName() { ... }


    /**
     *  Gets the path where the instance is going to be saved
     *
     * @return    the path name
     */
    public String getFileName() { ... }


//SET METHODS
    /**
     *  Sets the name of the ontology to which the instance belong
     *
     * @param  ontoName  the name of the ontology
     */
    public void setOntoName(String ontoName) { ... }


    /**
     *  Sets the name of the class to which the instance belong
     *
     * @param  className  the name of the class
     */
    public void setClassName(String className) { ... }


    /**
     *  Sets the name of the instance
     *
     * @param  instanceName  the name of the instance
     */
    public void setInstanceName(String instanceName) { ... }


    /**
     *  Sets the path where the instance is going to be saved
     *
     * @param  fileName  tha path name
     */
    public void setFileName(String fileName) { ... }


//PUBLIC METHODS
    /**
     *  Initialize an array of <code>size</code> elements of type IEInstanceSlot
     *
     * @param  size  the size of the array
     */
    public void initializeInstanceSlots(int size) { ... }


    /**
     *  Gets the array of IEInstanceSlot objects
     *
     * @return    the array of IEInstanceSlot
     */
    public IEInstanceSlot[] getInstanceSlots() { ... }


    /**
     *  Gets the size of the array of IEInstanceSlot
     *
     * @return    the size of the array
     */
    public int getNumberOfSlots() { ... }


    /**
     *  Gets the IEInstanceSlot object at <code>pos</code> position in the array
     *
     * @param  pos  the position
     * @return      the IEInstanceSlot object
     */
    public IEInstanceSlot getSlotAt(int pos) { ... }


    /**
     *  Gets the IEInstanceSlot object with name <code>name</code>
     *
     * @param  name  the name of the IEInstanceSlot object to retrieve
     * @return       the IEInstanceSlot object
     */
    public IEInstanceSlot getSlotWithName(String name) { ... }


    /**
     *  Gets the IEInstanceSlot object with tag <code>tag</code>
     *
     * @param  tag  the tag of the IEInstanceSlot object to retrieve
     * @return      the IEInstanceSlot object
     */
    public IEInstanceSlot getSlotWithTag(String tag) { ... }


    /**
     *  DEBUG: prints the content of this IEInstance object to the console
     */
    public void printInfo() { ... }


    /**
     *  Creates a tag for element in the array of IEInstanceSlot
     */
    public void createTagsForSlots() { ... }

}

Table 2.1a: IEInstance.java

The class edu.ou.kmi.mnm2.core.IEInstanceSlot describes a Slot belonging to an Instance in the current Ontology. It has the following attributes:
- slot_name: the name of the slot;
- slot_type: the type of the slot;
- slot_tag: the tag to be used when annotating a document;
- slot_color: the color to be used to highlight an annotated piece of text;
- a list of Tokens (edu.ou.kmi.mnm2.core.IEInstanceSlot.Token): each token holds information about the value of the Slot to which it belongs. The value of the Token can also be given by the piece of annotated text: in this case it is also possible to store info about the highlight (Object), the position of the annotated piece of text in the document (IERange) and if the annotation has been confirmed or not (boolean).

/**
 *  This class describe MnM's internal representation of an instance's slot. Each
 *  slot has its unique name, tag, type and color. Additionally a slot has also a
 *  list tokens. Each token contains information about the portion of text that has
 *  been annotated using the tag assigned to the slot (value and position of the
 *  annotation, whether it was confirmed or not and the value the highlight).
 *
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    17 March 2003
 */
public class IEInstanceSlot {
    /**
     *Constructor for the IEInstanceSlot object
     */
    public IEInstanceSlot() { ... }


    /**
     *Constructor for the IEInstanceSlot object
     *
     * @param  slotName  the name of the slot
     */
    public IEInstanceSlot(String slotName) { ... }


    /**
     *Constructor for the IEInstanceSlot object
     *
     * @param  slotName   the name of the slot
     * @param  slotTag    the tag of the slot
     * @param  slotType   the type of the slot
     * @param  slotColor  the color of the slot
     */
    public IEInstanceSlot(String slotName, String slotTag, String slotType, Color slotColor) { ... }


//GET METHODS
    /**
     *  Gets the color of this slot
     *
     * @return    the color
     */
    public Color getColor() { ... }


    /**
     *  Gets the name of this slot
     *
     * @return    the name
     */
    public String getName() { ... }


    /**
     *  Gets the tag of this slot
     *
     * @return    the tag
     */
    public String getTag() { ... }


    /**
     *  Gets the type of this slot
     *
     * @return    the type
     */
    public String getType() { ... }


    /**
     *  Gets the index of the current value of the list of tokens
     *
     * @return    the index of the current token
     */
    public int getCurrentToken() { ... }


//SET METHODS
    /**
     *  Sets the color for this slot
     *
     * @param  slotColor  the color
     */
    public void setColor(Color slotColor) { ... }


    /**
     *  Sets the name for this slot
     *
     * @param  slotName  the name
     */
    public void setName(String slotName) { ... }


    /**
     *  Sets the tag for this slot
     *
     * @param  slotTag  the tag
     */
    public void setTag(String slotTag) { ... }


    /**
     *  Sets the type for this slot
     *
     * @param  slotType  the type
     */
    public void setType(String slotType) { ... }


    /**
     *  Sets the index of the current token
     *
     * @param  current  the index of the current token
     */
    public void setCurrentToken(int current) { ... }


//PUBLIC METHODS
    /**
     *  For each token in the list of tokens adjusts the position of annotated
     *  text when a tag is added or removed
     *
     * @param  offset  the modifier
     */
    public void adjustRanges(int offset) { ... }


    /**
     *  Removes from the list of tokens the ones that have not been confirmed
     */
    public void clearNonConfirmedTokens() { ... }


    /**
     *  Checks if the list of tokens contains some non-confirmed tokens
     *
     * @return    true is there are non-confirmed tokens, false otherwise
     */
    public boolean hasNonConfirmedTokens() { ... }


    /**
     *  DEBUG: prints the content of this IEInstanceSlot object to the console
     */
    public void printTokens() { ... }


//PUBLIC METHODS FOR TOKENS
    /**
     *  Adds a new token
     *
     * @param  value  the value of the new token
     */
    public void addToken(String value) { ... }


    /**
     *  Adds a new token
     *
     * @param  value  the value of the new token
     * @param  s      the star-index of the <code>value</code> in the text
     * @param  e      the end-index of the <code>value</code> in the text
     */
    public void addToken(String value, int s, int e) { ... }


    /**
     *  Adds a new token
     *
     * @param  value          the value of the new token
     * @param  s              the star-index of the <code>value</code> in the text
     * @param  e              the end-index of the <code>value</code> in the text
     * @param  confirmed    true if the new token is confirmed
     */
    public void addToken(String value, int s, int e, boolean confirmed) { ... }


    /**
     *  Adds a new token
     *
     * @param  value  the value of the new token
     * @param  s      the star-index of the <code>value</code> in the text
     * @param  e      the end-index of the <code>value</code> in the text
     * @param  chunk  the object returned by the highlight method
     */
    public void addToken(String value, int s, int e, Object chunk) { ... }

    /**
     *  Adds a new token
     *
     * @param  value          the value of the new token
     * @param  s              the star-index of the <code>value</code> in the text
     * @param  e              the end-index of the <code>value</code> in the text
     * @param  chunk          the object returned by the highlight method
     * @param  confirmed      true if the new token is confirmed
     */
    public void addToken(String value, int s, int e, Object chunk, boolean confirmed) { ... }


    /**
     *  Sets the new value for the following attributes for the token at position
     *  <code>pos</code> in the list of tokens
     *
     * @param  pos    the index of the token in the list
     * @param  value  the value
     * @param  s      the start-index
     * @param  e      the end-index
     */
    public void setTokenAt(int pos, String value, int s, int e) { ... }


    /**
     *  Sets the new value for the following attributes for the token at position
     *  <code>pos</code> in the list of tokens
     *
     * @param  pos    the index of the token in the list
     * @param  value  the value
     * @param  s      the start-index
     * @param  e      the end-index
     * @param  chunk  the highlight
     */
    public void setTokenAt(int pos, String value, int s, int e, Object chunk) { ... }


    /**
     *  Sets the new value for the following attributes for the token at position
     *  <code>pos</code> in the list of tokens
     *
     * @param  pos            the index of the token in the list
     * @param  value          the value
     * @param  s              the start-index
     * @param  e              the end-index
     * @param  confirmed      true if the token is confirmed
     */
    public void setTokenAt(int pos, String value, int s, int e, boolean confirmed) { ... }


    /**
     *  Sets the new value for the following attributes for the token at position
     *  <code>pos</code> in the list of tokens
     *
     * @param  pos            the index of the token in the list
     * @param  value          the value
     * @param  s              the start-index
     * @param  e              the end-index
     * @param  chunk          the highlight
     * @param  confirmed      true if the token is confirmed
     */
    public void setTokenAt(int pos, String value, int s, int e, Object chunk, boolean confirmed) { ... }


    /**
     *  Removes the token with value <code>value</code>, start-index <code>s</code>
     *  and end-index <code>e</code> from the list of tokens.
     *
     * @param  value  the value
     * @param  s      the start-index
     * @param  e      the end-index
     */
    public void removeToken(String value, int s, int e) { ... }


    /**
     *  Removes from the list of tokens the one at position <code>pos</code>
     *
     * @param  pos  the position of the token to remove
     */
    public void removeTokenAt(int pos) { ... }


    /**
     *  Empty the list of tokens
     */
    public void removeAllTokens() { ... }


    /**
     *  Get the size of the list of tokens
     *
     * @return    The numberOfTokens value
     */
    public int getNumberOfTokens() { ... }

    /**
     *  Insert the highlight in the token at position <code>pos</code> in the list
     *  of tokens
     *
     * @param  pos    the position of the token to modify
     * @param  chunk  the highlight
     */
    public void chunkToken(int pos, Object chunk) { ... }


    /**
     *  Confirm the token at position <code>pos</code> in the list of tokens
     *
     * @param  pos        the position of the token to modify
     * @param  confirmed  true if the token is confirmed
     */
    public void confirmToken(int pos, boolean confirmed) { ... }


    /**
     *  Check if the token at position <code>pos</code> is confirmed
     *
     * @param  pos  the position of the token
     * @return      true if the tokens is confirmed, false otherwise
     */
    public boolean isTokenConfirmed(int pos) { ... }


//PUBLIC METHODS FOR CHUNKS
    /**
     *  Gets the highlight at position <code>pos</code>
     *
     * @param  pos  the position of the token
     * @return      the highlight
     */
    public Object getChunkAt(int pos) { ... }


//PUBLIC METHODS FOR VALUES
    /**
     *  Checks if the list of tokens contains the given value
     *
     * @param  value  the value to look for
     * @return        true if the list of tokens contains the given value
     */
    public boolean containsValue(String value) { ... }


    /**
     *  Gets the value of the token at position <code>pos</code> in the list
     *
     * @param  pos  the position of the token
     * @return      the value
     */
    public String getValueAt(int pos) { ... }


    /**
     *  Returns a string given by the concatenation of all the values in the list
     *  of tokens.
     *  Convenience method for <code>getValuesToString(true)</code>
     *
     * @return    the values
     */
    public String getValuesToString() { ... }


    /**
     *  Returns a string given by the concatenation of all the values in the list
     *  of tokens. It is possible to ask for a comma separeted concatenation of
     *  values.
     *
     * @param  separator  true if each value must be separeted by a comma
     * @return            the values
     */
    public String getValuesToString(boolean separator) { ... }


    /**
     *  Returns a string given by the concatenation of all the values in the list
     *  of tokens. The return string does not contains repetition.
     *  Convenience method for <code>getValuesToStringNoRep(true)</code>
     *
     * @return    the values
     */
    public String getValuesToStringNoRep() { ... }


    /**
     *  Returns a string given by the concatenation of all the values in the list
     *  of tokens. It is possible to ask for a comma separeted concatenation of
     *  values. The return string does not contains repetition.
     *
     * @param  separator  true if each value must be separeted by a comma
     * @return            the values
     */
    public String getValuesToStringNoRep(boolean separator) { ... }


    /**
     *  Gets an array of values from the list of tokens
     *
     * @return    the array of values
     */
    public Object[] getArrayOfValues() { ... }


    /**
     *  Gets an array of values without repetition form the list of tokens
     *
     * @return    the array of values
     */
    public Object[] getArrayOfValuesNoRep() { ... }


//PUBLIC METHODS FOR RANGES
    /**
     *  Checks if the list of tokens contains a value with the given start-index
     *  <code>s</code> and the end-index <code>e</code>.
     *
     * @param  s  the start-index
     * @param  e  the end-index
     * @return    true if there is a token with the given start-index and end-index
     */
    public boolean containsRange(int s, int e) { ... }


    /**
     *  Gets the start-index and end-index at position <code>pos</code> in the list
     *  of tokens
     *
     * @param  pos  the position
     * @return      the range value
     */
    public IERange getRangeAt(int pos) { ... }



    /**
     *  Gets the array of ranges from the list of tokens
     *
     * @return    the array of ranges
     */
    public Object[] getArrayOfRanges() { ... }


    /**
     *  Gets the array of range without repetitions from the list of tokens
     *
     * @return    the array of ranges
     */
    public Object[] getArrayOfRangesNoRep() { ... }


//INNER CLASS
    /**
     *  This class describes the structure that an element in the list of tokens
     *  must have. Each token has the following attributes:
     *  - value: the portion of the text that has been annotated;
     *  - range: the start-index and end-index of the portion of text that has been
     *           annotated;
     *  - chunk: the highlight;
     *  - confirmed: true if the token has been confirmed, false otherwise.
     *
     * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
     * @created    17 March 2003
     */
    class Token {
        /**
         *Constructor for the Token object
         *
         * @param  value  the value
         */
        Token(String value) { ... }


        /**
         *Constructor for the Token object
         *
         * @param  value  the value
         * @param  range  the range
         */
        Token(String value, IERange range) { ... }


        /**
         *Constructor for the Token object
         *
         * @param  value      the value
         * @param  range      the range
         * @param  confirmed  true if the token is confirmed
         */
        Token(String value, IERange range, boolean confirmed) { ... }


        /**
         *Constructor for the Token object
         *
         * @param  value  the value
         * @param  range  the range
         * @param  chunk  the highlight
         */
        Token(String value, IERange range, Object chunk) { ... }


        /**
         *Constructor for the Token object
         *
         * @param  value          the value
         * @param  range          the range
         * @param  chunk          the highlight
         * @param  confirmed      true if the token is confirmed
         */
        Token(String value, IERange range, Object chunk, boolean confirmed) { ... }


        //GET METHODS
        /**
         *  Gets the value attribute of the Token object
         *
         * @return    the value
         */
        String getValue() { ... }


        /**
         *  Gets the range attribute of the Token object
         *
         * @return    the range
         */
        IERange getRange() { ... }


        /**
         *  Gets the chunk attribute of the Token object
         *
         * @return    the highlight
         */
        Object getChunk() { ... }


        /**
         *  Gets the confirmed attribute of the Token object
         *
         * @return    true if the token is confirmed
         */
        boolean getConfirmed() { ... }


        //SET METHODS
        /**
         *  Sets the value attribute of the Token object
         *
         * @param  value  the value
         */
        public void setValue(String value) { ... }


        /**
         *  Sets the range attribute of the Token object
         *
         * @param  range  the range
         */
        public void setRange(IERange range) { ... }


        /**
         *  Sets the range attribute of the Token object
         *
         * @param  sIndex  the start-index
         * @param  eIndex  the end-index
         */
        public void setRange(int sIndex, int eIndex) { ... }


        /**
         *  Sets the chunk attribute of the Token object
         *
         * @param  chunk  the highlight
         */
        public void setChunk(Object chunk) { ... }


        /**
         *  Sets the confirmed attribute of the Token object
         *
         * @param  confirmed  true if the token is confirmed
         */
        public void setConfirmed(boolean confirmed) { ... }


        //PUBLIC METHODS
        /**
         *  Gets the confirmed attribute of the Token object
         *
         * @return    true if the token is confirmed
         */
        public boolean isConfirmed() { ... }

    }
}
Table 2.1b: IEInstanceSlot.java

In IEEnginePlugin an array of IEInstance objects is returned by the method retrieveResults(). In IEOntologyPlugin an IEInstance object is returned by the getInstanceData(...) and another IEInstance object is passed as a parameter to the format(...) method. So the only thing the plugin developer has to learn is how to read/write information from/to an IEInstance object.

An example on how to write information on an IEInstance object could be:
IEInstance instance = new IEInstance( ontology_name, class_name, instance_name );
instance.initializeInstanceSlots( NUMBER_OF_SLOTS );
IEInstanceSlot[] iSlots = instance.getInstanceSlots();
for ( int i = 0; i < NUMBER_OF_SLOTS; i++ ) {
     iSlots[i] = new IEInstanceSlot( slot_name, slot_tag, slot_type, slot_color );
     for ( int j = 0; j < NUMBER_OF_VALUES; j++ ) {
          iSlots[i].addToken(values[j]);
     }
}

Table 2.1c: how to write info in a IEInstance object

An example on how to read information from an IEInstance object could be:
IEInstance instance = getInstanceDataFromSomewhere();
System.out.println( "Ontology: " + instance.getOntoName() );
System.out.println( "Class: " + instance.getClassName() );
System.out.println( "Instance: " + instance.getInstanceName() );
IEInstanceSlot[] iSlots=instance.getInstanceSlots();
int NUMBER_OF_SLOTS = iSlots.length;
for ( int i = 0; i < NUMBER_OF_SLOTS; i++ ) {
     System.out.println( "\tSlot Name: " + iSlots[i].getName() );
     System.out.println( "\tSlot Type: " + iSlots[i].getType() );
     System.out.println( "\tSlot Tag: " + iSlots[i].getTag() );
     int NUMBER_OF TOKENS = iSlots[i].getNumberOfTokens();
     for ( int j=0; j < NUMBER_OF_TOKENS; j++ ) {
          System.out.println( "\t\tValue: " + iSlots[i].getValueAt( j ) );
          System.out.println( "\t\tRange: " + iSlots[i].getRangeAt( j ).toString() );
          System.out.println( "\t\tConfirmed: " + iSlots[i].isTokenConfirmed( j ) );
     }
}

Table 2.1d: how to read info from a IEInstance object

2.2 IEOutput

The interface edu.ou.kmi.mnm2.core.output.IEOutput describes the output behaviour that an ontology plugin must have. So far there can be two different forms of output (edu.ou.kmi.mnm2.core.output.IEOutput.Mode):NEW_INSTANCE (when adding a new instance in the current Ontology) and MOD_INSTANCE (when modifying an existing instance in the current Ontology). The functionalities provided are:
- format(...): formats given by the IEInstance object according to the requirements of the current Ontology and the selected Mode;
- commit(): commits the formatted instance to the current Ontology;
- print(): prints the formattef instance to the standard output (DEBUG);
- save(...): saves the formatted instance to a file.

/**
 *  Basic interface to describe the output operation needed by MnM
 *
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    13 March 2003
 */
public interface IEOutput {
    /**
     *  This class is used to define the different format of the output:
     *  - NEW_INSTANCE: to format a new instance to be commited to the ontology;
     *  - MOD_INSTANCE: to format a modified instance to be commited to the ontology.
     *
     * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
     * @created    13 March 2003
     */
    public static class Mode { private Mode() {} }
    /**
     *  MOD_INSTANCE: to format a modified instance to be commited to the ontology.
     */
    public final static Mode MOD_INSTANCE = new Mode();
    /**
     *  NEW_INSTANCE: to format a new instance to be commited to the ontology;
     */
    public final static Mode NEW_INSTANCE = new Mode();

    /**
     *  Formats the output given an IEInstance object
     *
     * @param  instance the data about the instance
     * @param  mode     NEW_INSTANCE or MOD_INSTANCE
     */
    public void format(IEInstance instance, IEOutput.Mode mode);

    /**
     *  Prints the output to the stdout
     */
    public void print();

    /**
     *  Saves the output in the specified file
     *
     * @param  file             the path where file is to be saved
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public void save(String file) throws IOException;

    /**
     *  Commits the output to the ontology
     *
     * @exception  IOException  thrown if problem where encountered while processing
     *                            the information
     */
    public void commit() throws IOException;
}
Table 2.2: IEOutput.java

2.3 IERange

The class edu.ou.kmi.mnm2.core.IERange describes a range representing an interval (start-index, end-index) in the  document space, specified in integer precision. It is used to locate a piece of annotated text in a document. IERange mimics the behaviour of  java.awt.Point. The provided functionalities are:
- equals(...): checks if an instance of IERange is equal to this range;
- getLength(): returns the length of this interval;
- getInterval() and setInterval(...): get/set the interval of this range;
- getStartIndex() and setStartIndex(...): get/set the initial index of this range;
- getEndIndex() and setEndIndex(...): get/set the final index of this range;
- toString(): returns a string representation of this range and its interval in the document space.

/**
 *  A range representing an interval (start-index, end-index) in the  document space,
 *  specified in integer precision.
 *
 * @author     Mattia Lanzoni (m.lanzoni@open.ac.uk)
 * @created    17 March 2003
 */
public class IERange {
    /**
     *  The start index
     */
    public int start_index;
    /**
     *  The end index
     */
    public int end_index;

    /**
     *Constructs and initializes a null range (0, 0) in the document space
     */
    public IERange() { ... }


    /**
     *Constructs and initializes an interval range (start, end) in the document space
     *
     * @param  start  the start
     * @param  end    the end
     */
    public IERange(int start, int end) { ... }


    /**
     *Constructs and initializes a range with the same interval as the specified
     *<code>IERange</code> object
     *
     * @param  r  the range
     */
    public IERange(IERange r) { ... }


//PUBLIC METHODS
    /**
     *  Gets the lenght of the interval
     *
     * @return    the lenght
     */
    public int getLenght() { ... }


    /**
     *  Determines whether an instance of IERange is equal to this range.
     *
     * @param  obj  the other IERange object
     * @return      true if the two object are equal
     */
    public boolean equals(Object obj) { ... }


    /**
     *  Returns a string representation of this range and its interval in
     *  the document space.
     *
     * @return    the string
     */
    public String toString() { ... }

//GET METHODS
    /**
     *  Gets the interval of this range
     *
     * @return    the interval
     */
    public IERange getInterval() { ... }

    /**
     *  Gets the start_index of this range
     *
     * @return    the start_index
     */
    public int getStartIndex() { ... }

    /**
     *  Gets the end_index of this range
     *
     * @return    the end_index
     */
    public int getEndIndex() { ... }

//SET METHODS
    /**
     *  Sets the interval of this range
     *
     * @param  r  the interval
     */
    public void setInterval(IERange r) { ... }

    /**
     *  Sets the start_index of this range
     *
     * @param  start  the start_index
     */
    public void setStartIndex(int start) { ... }

    /**
     *  Sets the end_index of this range
     *
     * @param  end  the end_index
     */
    public void setEndIndex(int end) { ... }
}
Table 2.3: IERange.java


3 What's Next



4 Conclusion



5 Contacts

 Enrico Motta (e.motta@open.ac.uk)