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
. 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
PepperModuleImpl
to perform actions before or after a single
document or corpus was processed andModuleControllerImpl
to perform actions before or after
the entire corpus graph was processed.This is an overview on the possible actions:
#reportCorpusStructure(SNode, String, boolean)
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
void |
addSLayers(org.corpus_tools.salt.common.SDocument sDoc,
String layers)
Adds the passed layer to all nodes and objects in the passed
SDocument . |
void |
after(org.corpus_tools.salt.graph.Identifier id)
Invokes actions, after the mapping of a corpus or document is done.
|
void |
after(org.corpus_tools.salt.common.SCorpusGraph corpusGraph)
Invokes an actions, after the mapping of an entire corpus structure was
done.
|
void |
before(org.corpus_tools.salt.graph.Identifier id)
Invokes actions, before the mapping of a corpus or document was started.
|
void |
before(org.corpus_tools.salt.common.SCorpusGraph corpusGraph)
Invokes an actions, after the mapping of an entire corpus structure was
done.
|
void |
copyResources(String resString)
Reads customization property
PepperModuleProperties.PROP_AFTER_COPY_RES and copies the listed
resources to the named target folder. |
PepperModule |
getPepperModule() |
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 passed
Identifier . |
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.
|
protected String |
reportCorpusStructure(org.corpus_tools.salt.common.SCorpusGraph corpusGraph,
org.corpus_tools.salt.core.SNode node,
String prefix,
boolean isTail)
Deprecated.
use
instead |
public BeforeAfterAction(PepperModule pepperModule)
PepperModule
which does the action, and the
internal SCorpusGraph
on which the action should be performed.public PepperModule getPepperModule()
public void before(org.corpus_tools.salt.common.SCorpusGraph corpusGraph) throws PepperModuleException
PepperModule.start()
.PepperModuleException
public void after(org.corpus_tools.salt.common.SCorpusGraph corpusGraph) throws PepperModuleException
PepperModuleException
@Deprecated protected String reportCorpusStructure(org.corpus_tools.salt.common.SCorpusGraph corpusGraph, org.corpus_tools.salt.core.SNode node, String prefix, boolean isTail)
instead
corpusGraph
- the corpus structure to be printednode
- root node to start fromprefix
- isTail
- public void copyResources(String resString)
PepperModuleProperties.PROP_AFTER_COPY_RES
and copies the listed
resources to the named target folder.public void before(org.corpus_tools.salt.graph.Identifier id) throws PepperModuleException
#map()
, before
PepperMapper.mapSDocument()
was called.id
- id of either SDocument
or SCorpus
object to be
preparedPepperModuleException
public void after(org.corpus_tools.salt.graph.Identifier id) throws PepperModuleException
#map()
, after
PepperMapper.mapSDocument()
was called.id
- id of either SDocument
or SCorpus
object to be
post processedPepperModuleException
public void addSLayers(org.corpus_tools.salt.common.SDocument sDoc, String layers)
SDocument
.sDoc
- layers
- public void readMeta(org.corpus_tools.salt.graph.Identifier id)
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
.id
- identifying the current objectpublic void renameAnnotations(org.corpus_tools.salt.graph.Identifier id, String renameTemplate)
id
- identifying the current objectCopyright © 2009–2019 Humboldt-Universität zu Berlin, INRIA. All rights reserved.