Class BeforeAfterAction
- java.lang.Object
-
- org.corpus_tools.pepper.impl.BeforeAfterAction
-
public class BeforeAfterAction extends Object
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 "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
PepperModuleImplto perform actions before or after a single document or corpus was processed and- used by
ModuleControllerImplto perform actions before or after the entire corpus graph was processed.
This is an overview on the possible actions:
- single corpus or document
- entire document structure
- before
#reportCorpusStructure(SNode, String, boolean)
- after
- before
- Since:
- 3.0.0
- Author:
- florian
-
-
Constructor Summary
Constructors Constructor Description BeforeAfterAction(PepperModule pepperModule)Initializes this object and in case an action should be performed, it sets the internalPepperModulewhich does the action, and the internalSCorpusGraphon which the action should be performed.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddSLayers(org.corpus_tools.salt.common.SDocument sDoc, String layers)Adds the passed layer to all nodes and objects in the passedSDocument.voidafter(org.corpus_tools.salt.common.SCorpusGraph corpusGraph)Invokes an actions, after the mapping of an entire corpus structure was done.voidafter(org.corpus_tools.salt.graph.Identifier id)Invokes actions, after the mapping of a corpus or document is done.voidbefore(org.corpus_tools.salt.common.SCorpusGraph corpusGraph)Invokes an actions, after the mapping of an entire corpus structure was done.voidbefore(org.corpus_tools.salt.graph.Identifier id)Invokes actions, before the mapping of a corpus or document was started.voidcopyResources(String resString)Reads customization propertyPepperModuleProperties.PROP_AFTER_COPY_RESand copies the listed resources to the named target folder.PepperModulegetPepperModule()voidreadMeta(org.corpus_tools.salt.graph.Identifier id)Loads meta data form a meta data file and adds them to the object corresponding to the passedIdentifier.voidrenameAnnotations(org.corpus_tools.salt.graph.Identifier id, String renameTemplate)Renames all annotations matching the search template to the new namespace, name or value.protected StringreportCorpusStructure(org.corpus_tools.salt.common.SCorpusGraph corpusGraph, org.corpus_tools.salt.core.SNode node, String prefix, boolean isTail)Deprecated.useinstead
-
-
-
Constructor Detail
-
BeforeAfterAction
public BeforeAfterAction(PepperModule pepperModule)
Initializes this object and in case an action should be performed, it sets the internalPepperModulewhich does the action, and the internalSCorpusGraphon which the action should be performed.
-
-
Method Detail
-
getPepperModule
public PepperModule getPepperModule()
-
before
public void before(org.corpus_tools.salt.common.SCorpusGraph corpusGraph) throws PepperModuleExceptionInvokes an actions, after the mapping of an entire corpus structure was done. Customization properties triggering a pre processing starts with "pepper.after.". This method is called before invocation ofPepperModule.start().- Throws:
PepperModuleException
-
after
public void after(org.corpus_tools.salt.common.SCorpusGraph corpusGraph) throws PepperModuleExceptionInvokes an actions, after the mapping of an entire corpus structure was done. Customization properties triggering a post processing starts with "pepper.after.". This method is called after invocation of {@link {@link PepperModule#start()} .- Throws:
PepperModuleException
-
reportCorpusStructure
@Deprecated protected String reportCorpusStructure(org.corpus_tools.salt.common.SCorpusGraph corpusGraph, org.corpus_tools.salt.core.SNode node, String prefix, boolean isTail)
Deprecated.useinsteadReturns the corpus structure as an ascii tree.- Parameters:
corpusGraph- the corpus structure to be printednode- root node to start fromprefix-isTail-- Returns:
-
copyResources
public void copyResources(String resString)
Reads customization propertyPepperModuleProperties.PROP_AFTER_COPY_RESand copies the listed resources to the named target folder.
-
before
public void before(org.corpus_tools.salt.graph.Identifier id) throws PepperModuleExceptionInvokes 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 "pepper.before.". This method is called by the method#map(), beforePepperMapper.mapSDocument()was called.- Parameters:
id- id of eitherSDocumentorSCorpusobject to be prepared- Throws:
PepperModuleException
-
after
public void after(org.corpus_tools.salt.graph.Identifier id) throws PepperModuleExceptionInvokes 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 "pepper.after.". This method is called by the method#map(), afterPepperMapper.mapSDocument()was called.- Parameters:
id- id of eitherSDocumentorSCorpusobject to be post processed- Throws:
PepperModuleException
-
addSLayers
public void addSLayers(org.corpus_tools.salt.common.SDocument sDoc, String layers)Adds the passed layer to all nodes and objects in the passedSDocument.- Parameters:
sDoc-layers-
-
readMeta
public void readMeta(org.corpus_tools.salt.graph.Identifier id)
Loads meta data form a meta data file and adds them to the object corresponding to the passedIdentifier. The meta data file is localized in the directory in case of the URI corresponding to passedIdentifieris a directory or (in case the corresponding URI addresses a file) in the same directory as the resource corresponding to the passedIdentifier. The meta data file must have the ending passed inPepperModuleProperties.PROP_BEFORE_READ_META.- Parameters:
id- identifying the current object
-
renameAnnotations
public void renameAnnotations(org.corpus_tools.salt.graph.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:
id- identifying the current object
-
-