hint method

Class: OCRRegionPlatform: ImagesLanguage: Python SDK:

Use this optional method to define the expected text as literal text or as a pattern.

The hint helps overcome ambiguities that arise when using OCR. It can be used, for example, to disinguish between the numeric '0' (zero) character and the alphabetic 'O' character.

For more information see Eyes OCR support .

This feature is experimental. Please note that the functionality and/or API may change.

Syntax


value = obj.hint(hint)

Parameters

hint
Type:Text
Literal text or a regular expression like pattern that defines what text is expected. See the remarks section for details of how to define patterns.

Return value

Type: Self
This method returns the object that called it so that it can be used to call other methods supportd by this class in a fluent API style.

Remarks

Defining Patterns and Hints

An OCR pattern/hint may be composed of any of the following characters:

. Matches any character.
\d Matches any digit 0-9.
\l (Lowercase L) Matches any letter a-z or A-Z.
\w Matches any word character a-z, A-Z, or _.
\S Matches any non-space character.
+ Repeats the previous literal character or character class one or more times, for example, "\d+" is any multi-numeral digit and "\w+" is any word that contains only letters or an underscore. This pattern cannot cross a line break.
\ Escapes a character that has a special meaning – specifically use this to specify the literals "\", ".", and "+" by using " \\", "\", and "\+".
space The OCR is tolerant of spaces between characters, so you don’t have to add them to the pattern. Where a space is detected in the image, it is translated into a single space. If you add an explicit space in the pattern, then it matches any number of spaces.
Any other character represents itself.

Depending on the programming language you use, the back-slashed character classes may need to be specially encoded in the string, for example, by using a double back-slash such as "\\w".

Example patterns

  • "\w+": Match a word

  • "\d+": Match a number

  • "\S+" : Match mixed alphabetic and digital data

  • "\d+/\d+/\d+": Match a date, such as 01/04/1972

  • "$\d+.\d+": Match an amount of money, such as $150.00

Example

Example not yet available.