Pepper  3.6.0
A highly extensible plattform for conversion and manipulationoflinguisticdata.
org.corpus_tools.pepper.impl.BeforeAfterAction Class Reference

Public Member Functions

 BeforeAfterAction (PepperModule pepperModule)
 Initializes this object and in case an action should be performed, it sets the internal PepperModule which does the action, and the internal SCorpusGraph on which the action should be performed.
 
PepperModule getPepperModule ()
 
void before (SCorpusGraph corpusGraph) throws PepperModuleException
 Invokes an actions, after the mapping of an entire corpus structure was done. More...
 
void after (SCorpusGraph corpusGraph) throws PepperModuleException
 Invokes an actions, after the mapping of an entire corpus structure was done. More...
 
void copyResources (String resString)
 Reads customization property PepperModuleProperties#PROP_AFTER_COPY_RES and copies the listed resources to the named target folder.
 
void before (Identifier id) throws PepperModuleException
 Invokes actions, before the mapping of a corpus or document was started. More...
 
void after (Identifier id) throws PepperModuleException
 Invokes actions, after the mapping of a corpus or document is done. More...
 
void addSLayers (SDocument sDoc, String layers)
 Adds the passed layer to all nodes and objects in the passed SDocument. More...
 
void readMeta (Identifier id)
 Loads meta data form a meta data file and adds them to the object corresponding to the passed Identifier. More...
 
void renameAnnotations (Identifier id, String renameTemplate)
 Renames all annotations matching the search template to the new namespace, name or value. More...
 

Protected Member Functions

String reportCorpusStructure (SCorpusGraph corpusGraph, SNode node, String prefix, boolean isTail)
 Returns the corpus structure as an ascii tree. More...
 

Detailed Description

This class is a helper class to perform actions before or after a mapping was done. A mapping could be the mapping of a single corpus or document or even the mapping of an entire corpus structure.

This could be helpful, for instance to make some processing after the mapping e.g. adding all created nodes and relations to a layer. To trigger an action for a specific Pepper module a set of customization properties is available. Customization properties triggering a post processing starts with {@value PepperModuleProperties::PREFIX_PEPPER_AFTER}. Such an action could be the enhancement of a corpus with metadata (following the property file syntax) to enhance corpora in formats, which do not support metadata, see readMeta(Identifier). Or the printing of a corpus structure, see reportCorpusStructure(SNode, String, boolean).

Objects of this class are used by

  1. PepperModuleImpl to perform actions before or after a single document or corpus was processed and
  2. used by ModuleControllerImpl to perform actions before or after the entire corpus graph was processed.

This is an overview on the possible actions:

Author
florian
Since
3.0.0

Member Function Documentation

◆ addSLayers()

void org.corpus_tools.pepper.impl.BeforeAfterAction.addSLayers ( SDocument  sDoc,
String  layers 
)

Adds the passed layer to all nodes and objects in the passed SDocument.

Parameters
sDoc
layers

◆ after() [1/2]

void org.corpus_tools.pepper.impl.BeforeAfterAction.after ( Identifier  id) throws PepperModuleException

Invokes actions, after the mapping of a corpus or document is done.

This could be helpful, for instance to make some processing after the mapping e.g. adding all created nodes and relations to a layer. To trigger this post processing for a specific Pepper module a set of customization properties is available. Customization properties triggering a post processing starts with {@value PepperModuleProperties::PREFIX_PEPPER_AFTER}. This method is called by the method map(), after PepperMapper#mapSDocument() was called.

Parameters
idid of either SDocument or SCorpus object to be post processed
Exceptions
PepperModuleException

◆ after() [2/2]

void org.corpus_tools.pepper.impl.BeforeAfterAction.after ( SCorpusGraph  corpusGraph) throws PepperModuleException

Invokes an actions, after the mapping of an entire corpus structure was done.

Customization properties triggering a post processing starts with {@value PepperModuleProperties::PREFIX_PEPPER_AFTER}. This method is called after invocation of linkPepperModule#start().@throwsPepperModuleException

◆ before() [1/2]

void org.corpus_tools.pepper.impl.BeforeAfterAction.before ( Identifier  id) throws PepperModuleException

Invokes actions, before the mapping of a corpus or document was started.

This could be helpful, for instance to make some preparations for the mapping. To trigger this pre processing for a specific Pepper module a set of customization properties is available. Customization properties triggering a pre processing starts with {@value PepperModuleProperties::PREFIX_PEPPER_BEFORE}. This method is called by the method map(), before PepperMapper#mapSDocument() was called.

Parameters
idid of either SDocument or SCorpus object to be prepared
Exceptions
PepperModuleException

◆ before() [2/2]

void org.corpus_tools.pepper.impl.BeforeAfterAction.before ( SCorpusGraph  corpusGraph) throws PepperModuleException

Invokes an actions, after the mapping of an entire corpus structure was done.

Customization properties triggering a pre processing starts with {@value PepperModuleProperties::PREFIX_PEPPER_AFTER}. This method is called before invocation of PepperModule#start().

Exceptions
PepperModuleException

◆ readMeta()

void org.corpus_tools.pepper.impl.BeforeAfterAction.readMeta ( Identifier  id)

Loads meta data form a meta data file and adds them to the object corresponding to the passed Identifier.

The meta data file is localized in the directory in case of the URI corresponding to passed Identifier is a directory or (in case the corresponding URI addresses a file) in the same directory as the resource corresponding to the passed Identifier. The meta data file must have the ending passed in PepperModuleProperties#PROP_BEFORE_READ_META.

Parameters
ididentifying the current object

◆ renameAnnotations()

void org.corpus_tools.pepper.impl.BeforeAfterAction.renameAnnotations ( Identifier  id,
String  renameTemplate 
)

Renames all annotations matching the search template to the new namespace, name or value.

To rename an annotation, use the following syntax: "old_namespace::old_name=old_value := new_namespace::new_name=new_value", determining the name is mandatory whereas the namespace and value are optional. For instance a pos annotation can be renamed as follows: "salt::pos:=part-of-speech". A list of renamings must be separated with ";".

Parameters
ididentifying the current object

◆ reportCorpusStructure()

String org.corpus_tools.pepper.impl.BeforeAfterAction.reportCorpusStructure ( SCorpusGraph  corpusGraph,
SNode  node,
String  prefix,
boolean  isTail 
)
protected

Returns the corpus structure as an ascii tree.

Parameters
corpusGraphthe corpus structure to be printed
noderoot node to start from
prefix
isTail
Returns