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()StringgetDescription()StringgetName()ParametersgetParameters()protected EventhandleEndBatch(Event event)protected EventhandleRawDocument(Event event)protected EventhandleStartBatch(Event event)protected EventhandleTextUnit(Event event)static booleanisEmpty(String str)voidsetInputRootDirectory(String inputRootDir)voidsetOutputURI(URI outputURI)voidsetParameters(IParameters params)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()
- 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()
-
getName
public String getName()
-
getParameters
public Parameters getParameters()
- Specified by:
getParametersin interfaceIPipelineStep- Overrides:
getParametersin classBasePipelineStep
-
setParameters
public void setParameters(IParameters params)
- Specified by:
setParametersin interfaceIPipelineStep- Overrides:
setParametersin classBasePipelineStep
-
handleStartBatch
protected Event handleStartBatch(Event event)
- Overrides:
handleStartBatchin classBasePipelineStep
-
handleEndBatch
protected Event handleEndBatch(Event event)
- Overrides:
handleEndBatchin classBasePipelineStep
-
handleRawDocument
protected Event handleRawDocument(Event event)
- Overrides:
handleRawDocumentin classBasePipelineStep
-
handleTextUnit
protected Event handleTextUnit(Event event)
- Overrides:
handleTextUnitin classBasePipelineStep
-
isEmpty
public static boolean isEmpty(String str)
-
-