de.dfki.lt.hog
Class Module

java.lang.Object
  extended by de.dfki.lt.hog.Module
Direct Known Subclasses:
ChasenModule, ChunkieModule, CorcyModule, FreeLingModule, JTokModule, LoParModule, PetModule, PicModule, Rasp2Module, RaspModule, SampleTagger, SampleTokenizer, SdlModule, SleepyModule, SproutModule, TnTModule, TreeTaggerModule, XmlRpcModule

public abstract class Module
extends java.lang.Object

Module is an abstract class that provides methods for a module to process an XML string or a DOM tree, respectively.
DeepThought Adaptation by Robert Barbey


Field Summary
protected static java.lang.String CONFIG_SEARCH_PATH_PROP
          This is the property for the config files search path in the config.
static java.lang.String LINE_SEPARATOR
          This is the system local newline string.
static java.lang.String MODULE_DEPTH_PROP
          Key for depth of this Modulein configuration.
static java.lang.String MODULE_LANGUAGE_PROP
          Key for language in configurating Properties
static java.lang.String MODULE_NAME_PROP
          Key for name of this Module in the config.
static java.lang.String MODULE_ROOTELEMENT_PROP
          Key for root element name of this Modulein configuration.
protected static org.apache.log4j.Logger moduleLog
          A logger for Modules
protected static java.lang.String NO
          This is the value for a flag property that is unset.
protected static java.lang.String NONE
          This is the value for a property that is not used.
static java.lang.String ROOT
          This is the path to the summarizer root directory.
protected static java.lang.String YES
          This is the value for a flag property that is set.
 
Constructor Summary
Module()
           
 
Method Summary
protected  java.lang.String getAbsolutOrRelativePath(java.lang.String path)
          This takes a file path and returns it if it's an absolut path or appends it to the summarizer root if it's a relative path.
protected  java.util.Properties getConfig()
          This returns the Properties object with the individual configs of the module.
protected  java.io.File getFileProperty(java.lang.String aProperty)
          This returns a File build from the value of a property as found in the properties object of the module.
 MoCoMan getMoCoMan()
          Return a reference back to the current MoCoMan instance (uschaefer).
protected  int getModuleDepth()
          Returns depth of this Module
protected  java.lang.String getModuleLanguage()
          Returns language of this Module as an abbreviated string.
protected  java.lang.String getModuleName()
          This returns the key under which the module is stored in the registry.
protected  java.lang.String getModuleRootElement()
          .
protected  java.lang.String getProperty(java.lang.String aProperty)
          This returns the value of a property as found in the properties object of the module.
protected  java.lang.String getProperty(java.lang.String aProperty, java.lang.String aDefault)
          This returns the value of a property as found in the properties object of the module.
protected  void init(java.util.Properties configProps)
          This makes the basic initialization of the module for a Properties object configProps.
abstract  java.lang.String process(java.lang.String processString)
           
abstract  org.w3c.dom.Node processDOMTree(org.w3c.dom.Node domTree)
           
protected  java.io.File searchConfigFile(java.lang.String configFile)
          This searchs a config file in the config file search path and returns it's first occurrence.
protected  java.io.File searchConfigFile(java.lang.String configFile, java.util.List dirList)
          This searchs a config file in the config file search path and returns it's first occurrence.
protected  void setConfig(java.util.Properties aConfig)
          This sets the individual configs of the module.
protected  void setMoCoMan(MoCoMan mcm)
          Store a reference back to the MoCoMan instance (uschaefer).
protected  void setModuleDepth(int aDepth)
           
protected  void setModuleLanguage(java.lang.String aLanguage)
          This sets the module language.
protected  void setModuleName(java.lang.String aName)
          This sets the module name.
protected  void setModuleRootElement(java.lang.String sElement)
          Set root element name for this Module
protected  void setProperty(java.lang.String aProperty, java.lang.String aValue)
          This sets the value of a property in the properties object of the module.
 void shutdown()
          This is the default shutdown method.
protected  boolean suitable(java.lang.String language, int depth)
          Determines whether this Module is suitable for analysis of a document with given language and depth.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULE_NAME_PROP

public static final java.lang.String MODULE_NAME_PROP
Key for name of this Module in the config.

See Also:
Constant Field Values

MODULE_LANGUAGE_PROP

public static final java.lang.String MODULE_LANGUAGE_PROP
Key for language in configurating Properties

See Also:
Constant Field Values

MODULE_DEPTH_PROP

public static final java.lang.String MODULE_DEPTH_PROP
Key for depth of this Modulein configuration.

See Also:
Constant Field Values

MODULE_ROOTELEMENT_PROP

public static final java.lang.String MODULE_ROOTELEMENT_PROP
Key for root element name of this Modulein configuration.

See Also:
Constant Field Values

ROOT

public static final java.lang.String ROOT
This is the path to the summarizer root directory.


LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR
This is the system local newline string.


moduleLog

protected static org.apache.log4j.Logger moduleLog
A logger for Modules


YES

protected static final java.lang.String YES
This is the value for a flag property that is set.

See Also:
Constant Field Values

NO

protected static final java.lang.String NO
This is the value for a flag property that is unset.

See Also:
Constant Field Values

NONE

protected static final java.lang.String NONE
This is the value for a property that is not used.

See Also:
Constant Field Values

CONFIG_SEARCH_PATH_PROP

protected static final java.lang.String CONFIG_SEARCH_PATH_PROP
This is the property for the config files search path in the config. This property is copied to all module properties in case they need to search a config file themself.

See Also:
Constant Field Values
Constructor Detail

Module

public Module()
Method Detail

getConfig

protected java.util.Properties getConfig()
This returns the Properties object with the individual configs of the module.

Returns:
a Properties object

setConfig

protected void setConfig(java.util.Properties aConfig)
This sets the individual configs of the module.

Parameters:
aConfig - a Properties object

getMoCoMan

public MoCoMan getMoCoMan()
Return a reference back to the current MoCoMan instance (uschaefer).

Returns:
instance of MoCoMan (set by MoCoMan module initialization loop)

setMoCoMan

protected void setMoCoMan(MoCoMan mcm)
Store a reference back to the MoCoMan instance (uschaefer).

Parameters:
mcm - instance of MoCoMan (given MoCoMan module initialization loop)

getModuleName

protected java.lang.String getModuleName()
This returns the key under which the module is stored in the registry.

Returns:
a String

setModuleName

protected void setModuleName(java.lang.String aName)
This sets the module name.

Parameters:
aName - a String

getModuleLanguage

protected java.lang.String getModuleLanguage()
Returns language of this Module as an abbreviated string.

Returns:
language

setModuleLanguage

protected void setModuleLanguage(java.lang.String aLanguage)
This sets the module language.

Parameters:
aLanguage -

getModuleDepth

protected int getModuleDepth()
Returns depth of this Module

Returns:
depth

setModuleDepth

protected void setModuleDepth(int aDepth)

getModuleRootElement

protected java.lang.String getModuleRootElement()
. Return root element name for this Module (default set to module name in init())

Returns:
a String

setModuleRootElement

protected void setModuleRootElement(java.lang.String sElement)
Set root element name for this Module

Parameters:
sElement - a String

shutdown

public void shutdown()
              throws ShutdownException
This is the default shutdown method. If any special action is needed for shutdown, overide this method in subclass.

Throws:
ShutdownException - if shutdown fails

init

protected void init(java.util.Properties configProps)
             throws InitializationException
This makes the basic initialization of the module for a Properties object configProps.

Parameters:
configProps - a Properties object that contains at least the module name
Throws:
InitializationException - if initialization fails

suitable

protected boolean suitable(java.lang.String language,
                           int depth)
Determines whether this Module is suitable for analysis of a document with given language and depth.

Parameters:
language -
depth -
Returns:
true iff this Module is suitable for analysis

process

public abstract java.lang.String process(java.lang.String processString)

processDOMTree

public abstract org.w3c.dom.Node processDOMTree(org.w3c.dom.Node domTree)

getFileProperty

protected java.io.File getFileProperty(java.lang.String aProperty)
                                throws NoSuchPropertyException
This returns a File build from the value of a property as found in the properties object of the module. If the pathname is relative, the summarizer root is added as a prefix.

Parameters:
aProperty - a String with the property
Returns:
a File build from the value of the property
Throws:
NoSuchPropertyException - if property is not found

getAbsolutOrRelativePath

protected java.lang.String getAbsolutOrRelativePath(java.lang.String path)
This takes a file path and returns it if it's an absolut path or appends it to the summarizer root if it's a relative path.

Parameters:
path - a String with a path
Returns:
a possibly modified path

searchConfigFile

protected java.io.File searchConfigFile(java.lang.String configFile)
                                 throws InitializationException
This searchs a config file in the config file search path and returns it's first occurrence. The config file search path is retrieved from the CONFIG_SEARCH_PATH_PROP property of the config file.

Parameters:
configFile - a String with the config filename
Returns:
a File with the first occurrence of the config file in the search path
Throws:
InitializationException - when config file is not found

getProperty

protected java.lang.String getProperty(java.lang.String aProperty)
                                throws NoSuchPropertyException
This returns the value of a property as found in the properties object of the module.

Parameters:
aProperty - a String with the property
Returns:
a String with the value of the property
Throws:
NoSuchPropertyException - if property is not found

getProperty

protected java.lang.String getProperty(java.lang.String aProperty,
                                       java.lang.String aDefault)
This returns the value of a property as found in the properties object of the module. If property is not found, it returns the default value.

Parameters:
aProperty - a String with the property
aDefault - a String with the default value
Returns:
a String with the value of the property or the default value if property is not found in config

setProperty

protected void setProperty(java.lang.String aProperty,
                           java.lang.String aValue)
This sets the value of a property in the properties object of the module.

Parameters:
aProperty - a String with the property
aValue - a String with the value

searchConfigFile

protected java.io.File searchConfigFile(java.lang.String configFile,
                                        java.util.List dirList)
                                 throws InitializationException
This searchs a config file in the config file search path and returns it's first occurrence.

Parameters:
configFile - a String with the config file's name
dirList - a List of Strings with the config file directories
Returns:
a File with the first occurrence of the config file in the search path
Throws:
InitializationException - when config file is not found