emolib
Class AffectiveTagger

java.lang.Object
  extended by emolib.util.proc.TextDataProcessor
      extended by emolib.AffectiveTagger
All Implemented Interfaces:
Configurable, DataProcessor

public class AffectiveTagger
extends TextDataProcessor

The AffectiveTagger is a wrapper class for the chain of Text Data Processors that perform the emotional tagging of the incoming text. It provides methods for manipulating and navigating the processors.

The AffectiveTagger is modelled as a pipeline of Text Data Processors, each of which performs a specific Natural Language Processing (NLP) task.

This class is based on the Sphinx-4 FrontEnd class with the appropriate Text Data objects. It follows the Sphinx-4 implementation in order to friendly interact with the ConfigurationManager, a very useful tool to deal with the configuration issues. More information about the interfaces that must be implemented, the Pull Model, the configuration and the usage of this class is to be found in the documentation of the Sphinx-4 FrontEnd.

The AffectiveTagger implemented for EmoLib proposes that the Data objects that carry the actual information should be of the TextData class, i.e., the main data structure, and the processors chained in the pipeline should extend the TextDataProcessor abstract class. These two classes implement the interfaces required by the Configuration Manager.

The arrangement of the selected Text Data Processors is given by the external configuration file in XML format, treated by the Configuration Manager.

The tagger provides the tools to input data into the processing pipeline as well as to retrieve the results from the pipeline through the "inputData" and "outputData" methods. These methods MUST be implemented by the first and the last modules of the pipeline, namely the INPUTTER and OUTPUTTER. Otherwise, the application will report the problem and crash.

Author:
Alexandre Trilla (atrilla@salle.url.edu)

Field Summary
static java.lang.String PROP_EMOLIB_PATH
          The name of the property that defines the root path of EmoLib.
static java.lang.String PROP_LANGUAGE
          The name of the property that defines the language of the system.
static java.lang.String PROP_PIPELINE
          The name of the property list of all the components of the AffectiveTagger pipe line.
 
Constructor Summary
AffectiveTagger()
           
 
Method Summary
 void flush()
          Method to flush the previous partial results of this TextDataProcessor.
 Data getData()
          Returns the processed Data output, basically calls getData() on the last processor.
 java.lang.String getEmoLibPath()
          Function that returns the root path of EmoLib.
 java.lang.String getLanguage()
          Function that returns the language of the AffectiveTagger.
 void initialize()
          Initializes this DataProcessor.
 Data inputData(java.lang.String inData)
          Function to input and process data.
 void newProperties(PropertySheet ps)
          This method is called when this configurable component has new data.
 void outputData()
          Method to issue the Tagger to output the results.
 void outputData(java.io.File file)
          Method to issue the Tagger to output the results into a determined file.
 TextData processText(java.lang.String text)
          Function to process textual data.
 void register(java.lang.String name, Registry registry)
          Register my properties.
 void setPredecessor(DataProcessor dataSource)
          Sets the source of Data for this AffectiveTagger.
 java.lang.String toString()
          Returns a description of this AffectiveTagger in the format: {, ...
 
Methods inherited from class emolib.util.proc.TextDataProcessor
getName, getPredecessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_PIPELINE

public static final java.lang.String PROP_PIPELINE
The name of the property list of all the components of the AffectiveTagger pipe line.

See Also:
Constant Field Values

PROP_LANGUAGE

public static final java.lang.String PROP_LANGUAGE
The name of the property that defines the language of the system. This property should be coherent with the rest of the modules of the AffectiveTagger. Please check the XML configuration file.

See Also:
Constant Field Values

PROP_EMOLIB_PATH

public static final java.lang.String PROP_EMOLIB_PATH
The name of the property that defines the root path of EmoLib.

See Also:
Constant Field Values
Constructor Detail

AffectiveTagger

public AffectiveTagger()
Method Detail

register

public void register(java.lang.String name,
                     Registry registry)
              throws PropertyException
Description copied from interface: Configurable
Register my properties. This method is called once early in the time of the component, shortly after the component is constructed. This component should register any configuration properties that it needs to register. If this configurable extends another configurable, super.register should also be called

Specified by:
register in interface Configurable
Overrides:
register in class TextDataProcessor
Parameters:
name - the name of the component
registry - the registry for this component
Throws:
PropertyException

newProperties

public void newProperties(PropertySheet ps)
                   throws PropertyException
Description copied from interface: Configurable
This method is called when this configurable component has new data. The component should first validate the data. If it is bad the component should return false. If the data is good, the component should record the the data internally and return true.

Specified by:
newProperties in interface Configurable
Overrides:
newProperties in class TextDataProcessor
Parameters:
ps - a property sheet holding the new data
Throws:
PropertyException - if there is a problem with the properties.

initialize

public void initialize()
Description copied from interface: DataProcessor
Initializes this DataProcessor. This is typically called after the DataProcessor has been configured.

Specified by:
initialize in interface DataProcessor
Overrides:
initialize in class TextDataProcessor

flush

public void flush()
Description copied from class: TextDataProcessor
Method to flush the previous partial results of this TextDataProcessor.

Overrides:
flush in class TextDataProcessor

getData

public Data getData()
             throws DataProcessingException
Returns the processed Data output, basically calls getData() on the last processor.

Specified by:
getData in interface DataProcessor
Specified by:
getData in class TextDataProcessor
Returns:
A Data object that has been processed by this AffectiveTagger.
Throws:
DataProcessingException - If a Data Processor error occurs.

setPredecessor

public void setPredecessor(DataProcessor dataSource)
Sets the source of Data for this AffectiveTagger. It basically calls setDataSource(dataSource).

Specified by:
setPredecessor in interface DataProcessor
Overrides:
setPredecessor in class TextDataProcessor
Parameters:
dataSource - The source of Data.

toString

public java.lang.String toString()
Returns a description of this AffectiveTagger in the format: {, ... }

Overrides:
toString in class TextDataProcessor
Returns:
A description of this AffectiveTagger.

getLanguage

public java.lang.String getLanguage()
Function that returns the language of the AffectiveTagger. This language should be coherent with the rest of the modules of the AffectiveTagger. Please check the XML configuration file.

Returns:
The language of the system.

getEmoLibPath

public java.lang.String getEmoLibPath()
Function that returns the root path of EmoLib.

Returns:
The root path.

inputData

public Data inputData(java.lang.String inData)
Function to input and process data. The data to be inputted must be a String. The developer should ensure that the first data processor defined in the pipeline is able to execute the "inputData" method.

Parameters:
inData - The text to be inputted.
Returns:
The processed data.

processText

public TextData processText(java.lang.String text)
Function to process textual data. This function is just a rename of inputData.

Parameters:
text - The text to process.
Returns:
The processed data.

outputData

public void outputData()
Method to issue the Tagger to output the results. It brings the OUTPUTTER into action.


outputData

public void outputData(java.io.File file)
Method to issue the Tagger to output the results into a determined file. It brings the OUTPUTTER into action.