Class SearchAndReplaceStep
- java.lang.Object
-
- net.sf.okapi.common.pipeline.BasePipelineStep
-
- net.sf.okapi.steps.searchandreplace.SearchAndReplaceStep
-
- All Implemented Interfaces:
AutoCloseable,Function<Stream<Event>,Stream<Event>>,IPipelineStep
public class SearchAndReplaceStep extends BasePipelineStep
This step performs search and replace actions on either the text units or the full content of input documents. Source and/or target content can be searched and replaced. Takes: Raw document or Filter events. Sends: same as the input. The step provides a way to define a list of search entries and corresponding replacements. You can use regular expressions if needed. The step can take as input either a raw document or filter events. If the step receives filter events, the search and replace is done on the content of the text units, and the step sends updated filter events to the next step. If the step receives a raw document, the search and replace is done on the whole file, and the step sends an updated raw document to the next step. Note that in this case, the raw document must be in some text-based file format for the search and replace to work: The document is seen exactly like it would be in a text editor (no conversion of escaped characters is done for example).- Author:
- Fredrik L., Yves S., HargraveJE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSearchAndReplaceStep.ProcTypestatic classSearchAndReplaceStep.TargetType
-
Constructor Summary
Constructors Constructor Description SearchAndReplaceStep()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcountMatches(String str, String sub)static intcountRegExMatches(String str, Pattern p)voiddestroy()Executes any cleanup code for this step.StringgetDescription()Gets a short localizable description of what this step does.StringgetName()Gets the localizable name of this step.ParametersgetParameters()Gets the current parameters for this step.protected EventhandleEndBatch(Event event)Handles theEventType.END_BATCHevent.protected EventhandleRawDocument(Event event)Handles theEventType.RAW_DOCUMENTevent.protected EventhandleStartBatch(Event event)Handles theEventType.START_BATCHevent.protected EventhandleTextUnit(Event event)Handles theEventType.TEXT_UNITevent.static booleanisEmpty(String str)voidsetInputRootDirectory(String inputRootDir)voidsetOutputURI(URI outputURI)voidsetParameters(IParameters params)Sets new parameters for this step.voidsetRootDirectory(String rootDir)voidsetTargetLocale(LocaleId targetLocale)-
Methods inherited from class net.sf.okapi.common.pipeline.BasePipelineStep
cancel, getHelpLocation, getSourceLocale, getTargetLocale, handleCustom, handleDocumentPart, handleEndBatchItem, handleEndDocument, handleEndGroup, handleEndSubDocument, handleEndSubfilter, handleEvent, handleMultiEvent, handlePipelineParameters, handleStartBatchItem, handleStartDocument, handleStartGroup, handleStartSubDocument, handleStartSubfilter, isDone, isLastOutputStep, setLastOutputStep, setSourceLocale
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.pipeline.IPipelineStep
apply, close, handleStream
-
-
-
-
Method Detail
-
destroy
public void destroy()
Description copied from interface:IPipelineStepExecutes any cleanup code for this step. Called once at the end of the pipeline lifecycle.- Specified by:
destroyin interfaceIPipelineStep- Overrides:
destroyin classBasePipelineStep
-
setRootDirectory
public void setRootDirectory(String rootDir)
-
setInputRootDirectory
public void setInputRootDirectory(String inputRootDir)
-
setOutputURI
public void setOutputURI(URI outputURI)
-
setTargetLocale
public void setTargetLocale(LocaleId targetLocale)
- Specified by:
setTargetLocalein interfaceIPipelineStep- Overrides:
setTargetLocalein classBasePipelineStep
-
getDescription
public String getDescription()
Description copied from interface:IPipelineStepGets a short localizable description of what this step does.- Returns:
- the text of a short description of what this step does.
-
getName
public String getName()
Description copied from interface:IPipelineStepGets the localizable name of this step.- Returns:
- the localizable name of this step.
-
getParameters
public Parameters getParameters()
Description copied from interface:IPipelineStepGets the current parameters for this step.- Specified by:
getParametersin interfaceIPipelineStep- Overrides:
getParametersin classBasePipelineStep- Returns:
- the current parameters for this step or null if there are no parameters.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IPipelineStepSets new parameters for this step.- Specified by:
setParametersin interfaceIPipelineStep- Overrides:
setParametersin classBasePipelineStep- Parameters:
params- the new parameters to use.
-
handleStartBatch
protected Event handleStartBatch(Event event)
Description copied from class:BasePipelineStepHandles theEventType.START_BATCHevent.- Overrides:
handleStartBatchin classBasePipelineStep- Parameters:
event- event to handle.- Returns:
- the event returned.
-
handleEndBatch
protected Event handleEndBatch(Event event)
Description copied from class:BasePipelineStepHandles theEventType.END_BATCHevent.- Overrides:
handleEndBatchin classBasePipelineStep- Parameters:
event- event to handle.- Returns:
- the event returned.
-
handleRawDocument
protected Event handleRawDocument(Event event)
Description copied from class:BasePipelineStepHandles theEventType.RAW_DOCUMENTevent.- Overrides:
handleRawDocumentin classBasePipelineStep- Parameters:
event- event to handle.- Returns:
- the event returned.
-
handleTextUnit
protected Event handleTextUnit(Event event)
Description copied from class:BasePipelineStepHandles theEventType.TEXT_UNITevent.- Overrides:
handleTextUnitin classBasePipelineStep- Parameters:
event- event to handle.- Returns:
- the event returned.
-
isEmpty
public static boolean isEmpty(String str)
-
-