public final class RegexParser extends Parser
AbstractOCREngineOptions). Due to differences between parsing normal strings
and OCR results, this parser does not support some regex features found in java's regex engine,
like back references. See RegexParser.setRegex(String) for more information about what is supported.| Modifier and Type | Class and Description |
|---|---|
static class |
RegexParser.Result |
| Modifier and Type | Field and Description |
|---|---|
static android.os.Parcelable.Creator |
CREATOR |
CLASS_NAME| Constructor and Description |
|---|
RegexParser(java.lang.String regex)
Constructor using default OCR engine options and provided regular expression.
|
RegexParser(java.lang.String regex,
AbstractOCREngineOptions ocrEngineOptions)
Constructor using provided OCR engine options and provided regular expression.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearResult()
Clears parser result.
|
RegexParser |
clone()
Create a copy of the entity.
|
void |
consumeResult(RegexParser.Result resultToConsume)
Consumes given result.
|
void |
consumeResultFrom(Entity other)
Consume result from other entity.
|
protected void |
deserializeNativeSettings(byte[] serializedSettings) |
AbstractOCREngineOptions |
getOcrEngineOptions()
Returns the OCR engine options used in Regex OCR parser.
|
java.lang.String |
getRegex()
Returns the currently set regular expression.
|
protected byte[] |
serializeNativeSettings() |
void |
setEndWithWhitespace(boolean mustEndWithWhitespace)
If set to true, regex will not be matched if there is no whitespace after matched string.
|
void |
setOcrEngineOptions(AbstractOCREngineOptions ocrEngineOptions)
Sets the OCR engine options used in Regex OCR parser.
|
void |
setRegex(java.lang.String regex)
Defines regex that will be used to parse OCR data.
|
void |
setStartWithWhitespace(boolean mustStartWithWhitespace)
If set to true, regex will not be matched if there is no whitespace before matched string.
|
void |
setUseSieve(boolean useSieve)
Enable the usage of algorithm for combining consecutive OCR results between video frames
for improving OCR quality.
|
boolean |
shouldEndWithWhitespace()
Returns whether matched string must end with whitespace.
|
boolean |
shouldStartWithWhitespace()
Returns whether matched string must start with whitespace.
|
boolean |
shouldUseSieve()
Returns true if algorithm for combining consecutive OCR results between video frames
for improving OCR quality is used.
|
protected void |
terminateNative(long nativeContext) |
getPriority, isRequired, setRequireddescribeContents, finalize, getNativeContext, getResult, nativeGetNativeResultContext, readFromParcel, writeToParcelpublic RegexParser(@NonNull
java.lang.String regex)
RegexParser.RegexParser(String, AbstractOCREngineOptions)
constructor. For more information about regex support, see RegexParser.setRegex(String).regex - Regular expression.java.lang.IllegalArgumentException - if regular expression cannot be compiledpublic RegexParser(@NonNull
java.lang.String regex,
@NonNull
AbstractOCREngineOptions ocrEngineOptions)
RegexParser.setRegex(String).regex - Regular expression.ocrEngineOptions - OCR engine options used for performing OCR.java.lang.IllegalArgumentException - if regular expression cannot be compiledpublic void setRegex(@NonNull
java.lang.String regex)
regex - Regular expression to be used for parsing OCR result.java.lang.IllegalArgumentException - if regular expression cannot be compiled@NonNull public java.lang.String getRegex()
public void setOcrEngineOptions(@NonNull
AbstractOCREngineOptions ocrEngineOptions)
BlinkOCREngineOptions'.ocrEngineOptions - OCR engine options used in Regex OCR parser@NonNull public AbstractOCREngineOptions getOcrEngineOptions()
BlinkOCREngineOptions'.public void setUseSieve(boolean useSieve)
BlinkOCREngineOptions is given
to RegexParser.setOcrEngineOptions(AbstractOCREngineOptions). Otherwise, it will not be
enabled and IllegalArgumentException will be thrown.useSieve - whether or not sieve algorithm should be usedpublic boolean shouldUseSieve()
public void setStartWithWhitespace(boolean mustStartWithWhitespace)
mustStartWithWhitespace - whether or not whitespace is required before matched stringpublic boolean shouldStartWithWhitespace()
public void setEndWithWhitespace(boolean mustEndWithWhitespace)
mustEndWithWhitespace - whether or not whitespace is required after matched stringpublic boolean shouldEndWithWhitespace()
protected void terminateNative(long nativeContext)
terminateNative in class Entity@Nullable protected byte[] serializeNativeSettings()
serializeNativeSettings in class Entityprotected void deserializeNativeSettings(@NonNull
byte[] serializedSettings)
deserializeNativeSettings in class Entity@NonNull public RegexParser clone()
EntityRecognizerRunnerView
or RecognizerRunner with the updated entity hierarchy.public void consumeResultFrom(@NonNull
Entity other)
Entitycom.microblink.blinkinput.entities.recognizers.RecognizerBundle#loadFromIntent(Intent)
and similar methods to replace the result content of the saved entities with results that
have arrived over IntentconsumeResultFrom in class Entityother - Entity from which result should be consumed.public void consumeResult(@NonNull
RegexParser.Result resultToConsume)
ParserconsumeResult in class ParserresultToConsume - Result that should be consumed.public void clearResult()
ParserclearResult in class Parser