EmoLib Simple Example

EmoLib has been designed with modularity in mind. The whole system is described with a pipeline of text-data processors that produce the affective tagging pursued by this system.

The best possible documentation about the usage of EmoLib is yielded by a simple example code. This one shows how to declare and initialise an instance of EmoLib, which accepts a plain text file and returns a XML results file with the appropriate affective information.

In order to use EmoLib, two essential parts are required: the initialisation and the processing.

Initialisation

This part is constituted by the declaration and instantiation of the basic components of EmoLib. The associated source code is shown as follows:

// Location of the XML configuration file
URL configFile = new File("emolib.config.xml").toURI().toURL();
// Declaration and instantiation of the Configuration Manager
ConfigurationManager cm = new ConfigurationManager(configFile);
// Declaration and instantiation of the AffectiveTagger through the Configuration Manager
AffectiveTagger tagger = (AffectiveTagger)cm.lookup("<language>_tagger");
The <language> tag above refers to the appropriate text processing pipeline configuration for the language of use according to the configuration file.

Processing

This part is constituted by the method and function calls in order to feed the system with the text to process and to retrieve the results produced by EmoLib. The associated source code is shown as follows:

// Feeding of the system
tagger.inputData(text_paragraph);
// Repetition until no more paragraphs are left in the document
// Retrieval of the processed text
tagger.outputData();

A direct implementation of this code is available in the "emolib.util.eval.ExampleTextFile" class.