About ABBYY FlexiLayout™ Studio

ABBYY FlexiLayout Studio is a software application that allows you to create formalized descriptions (FlexiLayouts) of documents with variable layouts (so-called semi-structured forms). The created FlexiLayouts are then used by forms processing applications to capture data from the documents which they describe. FlexiLayout Studio is built on ABBYY’s groundbreaking IPA technology which imitates the way living beings recognize objects.

Semi-structured forms are different from structured forms in that the exact location of the fields on such documents is not known in advance. For this reason, a data capture application needs additional information about the data fields in order to locate them on the forms and read the information they contain. ABBYY’s FlexiLayout technology allows you to create formalized descriptions which tell the data capture program how and where to find particular fields. Used in conjunction with a data capture application, e.g. ABBYY FlexiCapture, ABBYY FlexiLayout Studio will allow you to automate capturing data from such semi-structured forms as invoices, order forms, and many others.

ABBYY FlexiLayout Studio allows you to describe the layouts of simple and complex documents quickly and easily.

Used in conjunction with a forms processing solution built on ABBYY FlexiCapture technology, FlexiLayout Studio allows you to capture data from unstructured documents such as invoices, waybills, headers of incoming documents, etc.


Capturing data from unstructured forms

A form is document for gathering information which includes fields to be filled in by hand or by means of a printing device. Forms may have one or more pages.

Forms can be divided into 'hard' and 'flexible' forms. In the case of 'hard' forms, the identical fields have exactly the same locations on all the documents in a batch. Fixed forms can be processed by means of forms processing applications which read information from the data fields and export it into database, document management systems, or archiving applications. Data are captured fro such forms by means of template, which describes the locations of the fields and the type of information they may contain. One and the same template is used to capture data from all the forms in a given batch. It tells the forms processing application where to look for specific data on a form and how to make sure that the data have been captured correctly.

In the case of 'flexible' forms, the locations of identical data fields vary from one form to another. Additionally, not all fields may be present on all of the forms in a batch (e.g. one some forms may contain a signature field while others may not). A good example of a flexible form are various payment documents.

Letters, registration forms and legal documents are another good example of flexible forms. Forms of the same type will have similar structures but their may still be discrepancies among their fields. For example, letters will contain the name and address of the sender at the top of the page, legal documents will contain the names of the parties and their details, the effective date, etc.

Since the exact location of fields on flexible forms is not known in advance, data cannot be captured from such forms by means of a template. This means that traditional data capture systems cannot extract data from such forms.

ABBYY FlexiLayout Studio allows you to formally describe unstructured forms and provide the program with a search algorithm, enabling it to find data fields and extract information from these fields. A formal description relies on mutual relationships among the fields on an unstructured form and the nature of the data within the fields. Created descriptions can be tested on form images to make sure that information can be reliably extracted.

Formalized descriptions created by means of ABBYY FlexiLayout Studio are called FlexiLayouts. In order to start capturing data from unstructured forms by means of a FlexiLayout, you must export it into a data capture application such as ABBYY FlexiCapture 9.0. ABBYY FlexiCapture technology offers a wide range of data capture capabilities, enabling you to process practically any type of form.


Creating a FlexiLayout

A FlexiLayout is a formalized description of a set of unstructured documents which enables a data capture application to locate data fields on the forms and extract information from these fields.

For each object or a group of objects which must be detected on a form image a FlexiLayout element is created. The properties of the element describe the properties of the corresponding object. Thus the element will tell the program whether the object to look for is a picture, a text fragment or a barcode, how large it is and where it is most likely to be found on a form image.

A FlexiLayout block tells the program where to look for objects from which data must be captured. Block coordinates may be specified directly or by means of elements.

ABBYY FlexiLayout Studio offers a user-friendly visual interface which allows you to create FlexiLayouts consisting of elements and blocks. However, FlexiLayout creation requires a certain degree of creativity, as one and the same object can often be detected in more than one way, and the user must decide on which detection strategy to use.

FlexiLayout creation consists of the following stages:

Creating a FlexiLayout Studio project A project is a file which contains all the FlexiLayout data. It records the formalized description of the layout and is used for compiling and testing the FlexiLayout.

More...

Creating a batch of form images A batch is a set of sample form images which must be representative of the entire batch of forms which are to be processed.

More...

Pre-recognition Pre-recognition is a process whereby ABBYY FlexiLayout Studio detects atomic objects on a n image, such as text fragments, separators, check boxes, etc. Pre-recognition gives you an idea of what you can look for on the forms in a batch.

More...

Analyzing pre-recognition results

Once a form has been pre-recognized, you need to analyze it in order to find objects which can be reliable detected on all of the forms in the batch. Here is what you should look for:

  • Objects which are located in exactly the same place on all of the forms (these can be logos, headers, titles and similar objects);
  • Objects which have been reliably recognized and which are present on all of the form images;
  • Objects which are almost unaffected by the quality of printing or scanning;

If there is a sufficient number of such objects, you can describe the locations of all the other objects on the forms relative to these objects. At this stage you can also select the best way to look for a particular object on the form.

More...

Creating FlexiLayout elements and blocks First you need to create elements for objects which can be detected without resorting to other objects on the form (for example, a text fragment occurs only once on each form). Then the locations of the other objects are described through the locations of the already created elements. The FlexiLayout elements will form a search sequence - from the most reliable objects to the least reliable.

Additionally, you need to create elements fro objects which distinguish one set of forms from the other sets. These objects will be used as identifiers so that FlexiLayouts created for one set of forms are not matched with the forms from another set by mistake. This will speed up forms processing and make data capture more reliable.

Only the user can decide which elements and blocks must be created first. However we recommend testing the FlexiLayout after each new element or block has been created to make sure that the new element can indeed be used to detect the object it describes on all of the sample images.

More...

Compiling the FlexiLayout When you build a FlexiLayout, the program checks its logic and consistency.

More...

Testing the FlexiLayout by matching it with form images and testing it In order to test your FlexiLayout you need to try matching it with sample form images. The FlexiLayout must not only match all of the sample images, but also enable the program to detect the corresponding objects correctly. We recommend testing your FlexiLayouts after each new element or block has been added to it. It is much easier to detect errors in the FlexiLayout at this stage than in a complete FlexiLayout, particularly if your documents have sophisticated layouts.

More...

Exporting the FlexiLayout Once the FlexiLayout is complete, it must be exported into a data capture application.

More...


What's new in ABBYY FlexiLayout Studio 9.0

New features of ABBYY FlexiLayout Studio 9.0 not available in ABBYY FlexiLayout Studio 8.0

маркированный список Layout alternatives

Layout alternatives allow you to specify alternative positions of elements on documents that contain similar information (i.e. similar blocks), should be processed by the same rules, and contain data in the same language. Each layout alternatives specifies the location of the elements in a certain subset of documents, whereas the remaining part of the FlexiLayout describes what is common to all of the documents: the pre-recognition parameters (including languages), processing rules, page ranges, etc.

маркированный список Layout alternatives
маркированный список Classifiers

FlexiLayout Studio allows you to create special projects for identifying individual pages before applying a FlexiLayout. Identification helps select the FlexiLayout to be applied.

маркированный список Classifiers
маркированный список Prohibited elements

Prohibited elopements are elements which may not occur on an image. If the program hits upon a prohibited elements while building a chain of hypotheses, this chain is discarded.

маркированный список Required, optional, and prohibited elements
маркированный список New elements

A Labeled Field element has been introduced to search for fields with names. A Region element has been introduced to compute regions regardless of the objects they contain.

маркированный список | Labeled Field
маркированный список | Region
маркированный список Converting elements

Elements of one type can be converted into elements of another type.
маркированный список Elements

маркированный список Changes to Text Fragment

The algorithm and parameters used to detect a Text Fragment element have been improved.

маркированный список Text Fragment
маркированный список Non-Recognized block

An Non-Recognized block has been introduced to exclude an area from recognition

маркированный список Blocks
маркированный список Creating and initializing element properties directly on the image

You can quickly create elements while examining images. The properties of the elements you create are initialized by the values obtained during pre-recognition. Static Text and Labeled Field elements can be named using recognized text. The user can now specify the “looseness” of the parameters using the slider

маркированный список Creating, copying, and deleting elements
маркированный список User-defined element properties

Each element may now have its own set of additional variables.

маркированный список User-defined properties
маркированный список FlexiLayout language
  • Assembly of multi-page documents can now be controlled using the built-in FlexiLayout language
  • The FlexiLayout language now supports cycles of the following type: for <var-name> from <from-expr> to <to-expr> [step <step-expr>]
  • The FlexiLayout language now allows converting strings to integer (StrToInt) and real (StrToReal) numbers, and functions to check that these conversions are safe (IsInt and IsReal)
  • The FlexiLayout language now includes write to file (WriteToFile) and write to database (ExecuteSQL) functions. The latter can also be used for any other queries to the database, not just write to it
  • The hypothesis for a Text Fragment element now includes methods of accessing the rectangles of the detected strings. These methods are similar to those of the Static Text hypothesis
маркированный список Miscellaneous improvements
  • Storage and recognition of color images
  • Image pre-processing options
  • Ability to import FlexiLayouts from other projects
  • Pre-recognition stage no longer mandatory (when there are no text elements)
  • The pre-recognition parameters now include the “Pre-recognition area” parameter which limits the pre-recognition area. Additionally, it is now possible to manually invoke pre-recognition for any region using the FleixLayout language
  • Ability to copy recognized text from objects on the image
  • Case-sensitive search
  • Ability to ignore diacritics when searching for text
  • Letters with diacritics and Cyrillic letters can be used in names of elements, layout alternatives, blocks, and identifiers
  • Visualization of relations added: the Relations tab of the Element Properties dialog box now displays the thumbnail of the selected relation or the relation that is being created
  • Element search areas can now be viewed for matched layouts. This feature is available even if the tree of hypotheses has been closed.

New features of ABBYY FlexiLayout Studio 8.0 not available in ABBYY FlexiCapture Studio 1.5

маркированный список Support for multi-page documents

ABBYY FlexiLayout Studio allows you to create a single FlexiLayout for processing multi-page documents. FlexiLayouts for multi-page documents use the new Header and Footer elements to identify documents with a variable number of pages that is not known in advance. The program will search for fields in a multi-page document irrespective of the individual pages on which they are located.
маркированный список Multi-page FlexiLayout

маркированный список Multi-page tables

A Table can be located on more than one page. The number of pages may not be known in advance and may vary from document to document.
маркированный список Working with tables

маркированный список Repeating groups

The new Repeating Group element allows you to set up the properties of each field in a group only once and specify the possible number of repetitions for the group on one or more pages. This feature makes it easier to create FlexiLayouts for documents with a large number of similar field groups, such as database printouts, beginnings and ends of documents, and complex tables.
маркированный список Repeating Group

маркированный список Multi-page image window

The image window can now display the full set of batch images groped into documents and not just the selected image. The window is fully scalable: small scale view is convenient for viewing the structure of a multi-page document while the large scale view is ideal for viewing individual pages or fields.

маркированный список Better code editing (Advanced... sections)

You can edit FlexiLayout code in a full-screen editor which highlights different lexemes in different color, suggests possible methods and properties, and offers a find and replace tool.
маркированный список Additional search constraints

маркированный список Find and replace in FlexiLayout code

Now you can find and replace code strings in the entire FlexiLayout.
маркированный список Additional search constraints

маркированный список Auto correction of page orientation

Image orientation can be corrected automatically.
маркированный список Working with images

маркированный список Measure tool

The new Measure tool allows you to determine the coordinates of elements and measure distances on an image, which makes creating a FlexiLayout easier.
маркированный список Measuring objects

маркированный список Selecting units of measurement

Now you can select the units of measurement to be used: millimeters, centimeters, inches, dots (1/300 of an inch) or points (1/72 of an inch).
маркированный список Units of measurement

маркированный список Fuzzy interval visualizer

The new fuzzy interval visualization tool allows you to set fuzzy intervals quickly and easily using a graphical representation of the interval and a penalty calculator. When calling the tool from the Properties dialog box of a Character String element, the resulting fuzzy intervals are automatically copied into the properties of the element. This feature will also come in handy when writing code on the Advanced tab (select Tools>Fuzzy Interval Editor).
маркированный список Fuzzy interval

маркированный список FlexiLayout encryption

Exported FlexiLayouts (*.afl files) can be encrypted to prevent unauthorized use.

маркированный список Display of incomplete chains of hypotheses for Group elements

If the chain of hypotheses for a Group element (Group, Repeating Group) is incomplete, the hypothesis for the Group element is displayed as a red circle, double-clicking which will display the incomplete chain so that you can locate the element in the group that has not been detected.
маркированный список Tree of hypotheses

маркированный список Miscellaneous
  • Pages can be rearranged using the drag-and-drop feature or by renumbering them in the Batch window
  • The colors of graphics and code objects can be customized
  • New convenient settings for the regular expression of the Character String element.
  • Setting up and testing the connection with the database when finding key words for the Static Text element.
  • Setting up the Nearest relation
  • Testing Group elements
  • Image window is now scrollable


Installing, running, and removing ABBYY FlexiLayout™ Studio 1.5

Installing, running, and removing ABBYY FlexiLayout™ Studio 9.0

ABBYY FlexiLayout Studio 9.0 is installed and removed together with ABBYY FlexiCapture 9.0.

To run ABBYY FlexiLayout Studio select:

  • Start/Programs/ABBYY FlexiCapture 9.0/Tools/ABBYY FlexiLayout Studio 9.0 for StandAlone version;
  • Start/Programs/ABBYY FlexiCapture 9.0 Stations/Tools/ABBYY FlexiLayout Studio 9.0 for Distributed version.

Important! A protection key is required for the correct operation of ABBYY FlexiLayout Studio. Make sure that your protection key is installed before running the program.


ABBYY FlexiLayout™ Studio interface

The GUI of ABBYY FlexiLayout Studio allows you to create FlexiLayout elements and blocks, specify and adjust their properties, and view the results of matching your newly created FlexiLayout with form images.

Please note that the layout of the main window in the figure above may differ from the layout on your screen. You can customize the view of the main window by clicking the title bar of a window or the border of a toolbar and dragging it to a desired location. Selecting View>Status Bar toggles the status bar at the bottom of the window.

Right-clicking inside a window displays the corresponding shortcut menu.


Batch window

The Batch window lists the sample images you selected for the purpose of creating and testing your FlexiLayout.

The table columns display the following information about each of the images.

In the case of a FlexiLayout:

  • Page No. - The number of the page
  • Recognized - The page has or has not been pre-recognized
  • Analyzed - The FlexiLayout has or has not been matched with form images
  • Has Reference Blocks - A reference layout has or has not been created
  • Matched Document Number - The number of the document to which the page was assigned when matching the FlexiLayout
  • Matched Sequence Number - The number of the page in the document that was assigned to it when matching the FlexiLayout. The letter (H) next to the number indicates that a Header element has been detected on the page and the letter (F) indicates that a Footer element has been detected.
  • Reference Document Number - The number of the document to which the page must be assigned based on the reference assembly
  • Reference Sequence Number - The number of the page in the document that must be assigned to it based on the reference assembly. The letter (H) next to the number indicates that a Header element must be present on the page and the letter (F) indicates that a Footer element must be present.
  • Excess Areas - A comparison of matching the FlexiLayout with sample images and the reference layout with sample images; shows the percentage of excess areas.
  • Missing Areas - A comparison of matching the FlexiLayout with sample images and the reference layout with sample images; shows the percentage of missing areas.
  • Comment - Comments to the image;
  • FlexiLayout Name - the name of the FlexiLayout that matches the page
  • Reference FlexiLayout Name the name of the reference FlexiLayout
  • Source - The path to the image file.

In the case of a classifier:

  • Page No. - the number of the page
  • Recognized - whether pre-recognition has been carried out or not
  • FlexiLayout Name the result of the classification (text string)
  • Reference FlexiLayout Name the reference result of classification
  • Comment - comment to the image
  • Source - path to the original image file

Use your mouse to adjust column width and position.


FlexiLayout window

The FlexiLayout window displays the tree-like diagram of the current FlexiLayout. The tree has the following branches:

  • Blocks, in which blocks are located
  • SearchElements, in which elements are located. A tree may contain several branches of this type, each corresponding to a layout alternative.

Blocks and elements may be grouped together, forming new nesting levels.

Tip: You can move (drag-and-drop) and copy (Ctrl+drag-and-drop) elements and blocks in the tree.


Classification window

Classifier window

The classification window displays the Classifier as a tree-like diagram. The root folder of the tree corresponds to the classifier in its entirety.

Each node in the tree corresponds to a classification stage. A node contains a group identifier element (named Id by default) and nested nodes. Depth of nesting is not limited.

Tip: You can move (drag-and-drop) and copy (Ctrl+drag-and-drop) classification stages in the tree.

More

Classifiers

Creating a classifier


Properties window

The Properties window displays the properties of the object selected in the Batch, FlexiLayout, Image, or Hypotheses window.

At the bottom of the Properties window, a brief description of the property and its value are displayed.


Image window

The Image window displays the image of the page selected in the Batch window. The title of the Image window displays the number of the document, the name of alternative layout, the number of the selected page, and the view mode. Additionally, the Header/Footer indicator is displayed, if available for the given page in the current view mode.

The following views are available in the Image window:

  • The Matched layout view displays the results of matching the FlexiLayout with sample images. Click [image] on the Layout toolbar to enable this view. Use the arrow to the right to select the objects to be displayed: blocks, elements, or both.
  • The Reference layout view displays the reference layout. Click [image] on the Layout toolbar to enable this view.
  • The Difference view displays the difference between matching the FlexiLayout and matching the reference layout. Click [image] on the Layout toolbar to enable this view.
    Note: The difference between matching the FlexiLayout and matching the reference layout becomes available only after you have created a reference layout.


Hypotheses window

The Hypotheses window displays the tree of hypotheses generated by the program as a result of matching your FlexiLayout with a sample image. The program generates a hypothesis for each of the FlexiLayout elements. The left-hand pane displays the elements in the order in which they occur in the tree. The right-hand pane displays the tree of hypotheses.

The Hypotheses window becomes available after you have matched the FlexiLayout with an image (Image > Match). In the Image window, click [image] (Matched layout) on the toolbar to display the Hypotheses window.


Classifier Log window

Classifier log

The Classifier log window displays the log of applying the classifier to the pages. For each page, the order of the applied classes and the matching results are logged.

More

Classifiers

Creating a classifier


Standard toolbar

The Standard toolbar contains buttons which correspond to the standard commands such as creating, opening and saving FlexiLayouts.

The buttons on the Standard toolbar:

Button | Description
New | Opens the Create Project dialog box where you can enter a name for your new project.
Open | Opens the Open Project dialog box where you can select a project file to open.
Save | Saves the current project.
Cut | Deletes the selection and places it into the Clipboard.
Copy | Copies the selection (text in the Text window, blocks in the Image window, pages in the Batch window, blocks or elements in the FlexiLayout window) into the Clipboard.
Paste | Pastes the selection from the Clipboard.
Undo | Cancels the last action.
Redo | Cancels the last Undo action.
Previous Page | Opens the previous page in the project.
Next Page | Opens the next page in the project.


Extracted Objects toolbar

The Extracted Objects toolbar contains buttons which allow you to show/hide the objects detected during pre-recognition.

The Extracted Objects toolbar buttons:

Button | Description
Recognized Words | Displays only the objects classified as Text during pre-recognition.
Recognized Lines | Displays only the objects classified as Recognized Lines during pre-recognition.
Separators | Displays only the objects classified as Separators during pre-recognition.
Barcodes | Displays only the objects classified as Barcodes during pre-recognition.
Raw Objects | Displays only the objects which the program managed to classify during pre-recognition.


Block-Drawing Tools toolbar

The Block-Drawing Tools toolbar contains buttons which allow you to edit the reference layout.

The Block-Drawing tools toolbar buttons:

Button | Description
Select Region Selects a region on the image and moves the selected block.

Tip: Sometimes a block may be too small to be moved, as its borders are very close to one another and pointing the mouse on any of them will activate the "change size" mode. Hold down the Ctrl key to move such blocks.

Note: The button is only available in Reference layout mode.

Measure Rectangle Detects the coordinates and sizes of objects on the image and copies them to the Clipboard.

To measure an object on the current image, activate the Measure Tool and select the rectangular area to be measured: right-click one corner of the area, drag the mouse diagonally into the opposite corner, and release the mouse. The Measure Tool dialog box displays the coordinates and the width and height of the measured object in the user-defined units of measurement.

If you select Automatically copy results to Clipboard, the coordinates of the rectangle will be copied to the Clipboard so that you can easily paste them, for example, on the Search Constraints tab in the Properties dialog box of any element to define its search area.

Scroll Tool | Scrolls the image in the Image window.
Create New Element | Creates a new element and allows you to specify its properties based on the pre-recognized image.
Draw Block Creates a new block on the image.
Note: The button is only available in Reference layout mode.
Add Block Part Adds a rectangular area to the selected block.
Note: The button is only available in Reference layout mode.
Cut Block Part Cuts a rectangular area form the selected block.
Note: The button is only available in Reference layout mode.
Delete Block Deletes a block from the image.
Note: The button is only available in Reference layout mode.
Add Vertical Separator Adds a vertical separator to the selected Table block.
Note: The button is only available in Reference layout mode.
Add Horizontal Separator Adds a horizontal separator to the selected Table block.
Note: The button is only available in Reference layout mode.
Delete Separator Deletes a separator from the selected Table block.
Note: The button is only available in Reference layout mode.


Layout toolbar

The Layout toolbar contains buttons which allow you to view the test images in different modes.

The Layout toolbar buttons:

Button | Description
Matched layout | Displays the image in Matched layout mode. Use the arrow to the right to select the objects to be displayed: blocks, elements, or both.
Reference layout | Displays the image in Reference layout mode.
Difference | Displays the image in Difference mode.


Image Tools toolbar

The Image Tools toolbar contains buttons which correspond to the standard commands such as rotating and scaling the selected image(s).

The buttons on the Image Tool toolbar:

Button | Description
Rotate Clockwise | Rotates the image by 90° clockwise.
Rotate Counter-Clockwise | Rotates the image by 90° counter-clockwise.
Rotate Upside Down | Rotates the image by 180°.
Correct Orientation | Auto corrects the orientation of pages. The correct orientation is selected automatically based on the selected pre-recognition language and the settings made in the Options dialog box (Tools>Options).
Flip Horizontally | Flips the image horizontally.
Flip Vertically | Flips the image vertically.
Invert | Inverts the image (turns black into white and vice versa).
Despeckle | Removes excess dots from the image.
Zoom In | Makes the image twice as large.
Zoom Out | Makes the image twice as small.
Scale | Scales the image.

Note: When you perform image operations, all the pre-recognition and FlexiLayout matching results are deleted. When rotating and flipping images, the Reference Layout is also deleted.


Status bar

The status bar displays the result of an operation, brief tips for interface elements, and the coordinates of the object currently selected on the image.


Menu commands

  • File menu
  • Edit menu
  • View menu
  • Batch menu
  • Image menu
  • FlexiLayout / Classifier menu
  • Tools menu
  • Help menu
  • Block shortcut menu
  • Hypothesis shortcut menu
  • Image shortcut menu
  • Batch shortcut menu
  • FlexiLayout shortcut menu
  • Element shortcut menu


File menu

Command |  | Description
New Project | FlexiLayout Project… | Opens the Create Project dialog box, where you can specify a name for your new FlexiLayout project.
 | Classifier Project… | Opens the Create Project dialog box, where you can specify a name for your new classifier project.
Open Project… |  | Opens the Open Project dialog box where you can select a project file.
Close Project |  | Closes the current project.
Open & Add Images… |  | Opens the Open Images dialog box where you can select one or several images to be added to the batch.
Save |  | Saves the current project.
Save Copy… |  | Opens the Save Copy dialog box where you can save the current project under a new name.
Export… |  | Opens the Export FlexiLayout dialog box where you can enter a name for the export file.
Project Properties… |  | Opens the Properties dialog box where you can view the properties of the project.
Recent Projects |  | Displays a list of recent projects.
Exit |  | Closes FlexiLayout Studio.


Edit menu

Command | Description
Undo | Cancels the results of the previous action.
Redo | Cancels the results of the previous Undo action.
Cut | Cuts the selection and places it into the Clipboard.
Copy | Copies the selection (text in the Text window, blocks in the Image window, pages in the Batch window, blocks or elements in the FlexiLayout window) and places it into the Clipboard.
Paste | Pastes the selection from the Clipboard.
Delete | Deletes the selection.
Select All | Selects all the pages in the Batch window or all the blocks and elements on the image.


View menu

Command | Description
Batch | Activates the Batch window.
FlexiLayout / Classifier | Activates the FlexiLayout window.
Properties | Activates the Properties window.
Image | Activates the Image window.
Hypotheses | Activates the Hypotheses window. Note: This window opens after you match your FlexiLayout with an image (the Match command in the Image menu), if the Matched Layout mode was selected ( [image] button on the toolbar).
Status Bar | Displays/hides the status bar in the program’s main window.
Classifier Log | Opens the Classifier Log window.


Batch menu

Command |  | Description
Match |  | Matches the FlexiLayout with the selected pages.
Cla&ssify |  | Classifies the selected pages. This command is available only in classifier projects.
Open Page |  | Opens the selected image.
Next Page |  | Opens the next image in the batch.
Previous Page |  | Opens the previous image in the batch.
Go to Page… |  | Opens the Go to Page dialog box where you can enter the number of the page to which you wish to go.
Pre-Recognize |  | Pre-recognizes the selected pages.
Copy Matched Layout to Reference |  | FlexiLayout project: Creates a reference layout for the image on the basis of the results of FlexiLayout matching. Note: This command is only available for images which were matched with their FlexiLayouts. Classifier project: Copies a classification result to the page properties.
Assemble to Reference Documents… |  | Opens Assemble to Reference Documents dialog box, where you can set the reference assembly parameters and create a reference assembly of the selected documents.
Disassemble Reference Documents |  | Cancels the reference assembly for the selected documents.
Change Reference Header/Footer… |  | Opens the Change Header/Footer dialog box, where you can specify whether header/footer should coincide with the first/last pages of the selected documents.
Delete Pages |  | Deletes the selected pages from the batch.
Delete Page Data… |  | Opens the Select Data to Delete dialog box where you can select the page data to be deleted
Image Operations | Rotate Clockwise | Rotates the images of the selected pages by 90° clockwise.
 | Rotate Counter-Clockwise | Rotates the images of the selected pages by 90° counter-clockwise.
 | Rotate Upside Down | Rotates the images of the selected pages by 180°.
 | Flip Horizontally | Flips the images of the selected pages horizontally.
 | Flip Vertically | Flips the images of the selected pages vertically.
 | Invert | Inverts the images of the selected pages (turns black into white and vice versa).
 | Despeckle | Removes excess dots from the images of the selected pages.
Correct Orientation |  | Auto corrects the orientation of pages in the batch. The correct orientation is selected automatically based on the selected pre-recognition language and the settings made in the Options dialog box (Tools>Options…).


Image menu

Command |  | Description
Match |  | Attempts to match the FlexiLayout with the current page.
Cla&ssify |  | Classifies the current page.
Image Window Scale | 200% | Sets the scale of the Image window to 200%.
 | 100% | Sets the scale of the Image window to 100%.
 | 50% | Sets the scale of the Image window to 50%.
 | 25% | Sets the scale of the Image window to 25%.
 | Fit to Width | Fits the width of the image to the window.
 | Fit to Height | Fits the length of the image to the window.
 | Best Fit | Fits the entire image to the window.
 | Zoom In | Makes the image 25% as large.
 | Zoom Out | Makes the image 25% as small.
Show Image Objects | Show All Objects | Displays all the objects detected during pre-recognition.
 | Hide All Objects | Hides all the objects detected during pre-recognition.
 | Recognized Words | Displays only the objects classified as Text during pre-recognition.
 | Recognized Lines | Displays only the objects classified as Recognized Lines during pre-recognition.
 | Separator | Displays only the objects classified as Separators during pre-recognition.
 | Raw Objects | Displays only the objects which the program managed to classify during pre-recognition.
 | Barcodes | Displays only the objects classified as Barcodes during pre-recognition.
 | Note: To select multiple types of objects, hold down the Ctrl key while clicking the desired buttons on the toolbar or selecting the menu items.
Image Operations | Rotate Clockwise | Rotates the image by 90° clockwise.
 | Rotate Counter-Clockwise | Rotates the image by 90° counter-clockwise.
 | Rotate Upside Down | Rotates the image by 180°.
 | Flip Horizontally | Flips the image horizontally.
 | Flip Vertically | Flips the image vertically.
 | Invert | Inverts the image (turns black into white and vice versa).
 | Despeckle | Removes excess dots from the image.
Select tool | Select | Selects an existing block on the image.
 | Measure Rectangle | Detects the coordinates and sizes of objects on the image and copies them to the Clipboard.
 | Create Block | Creates a new block on the image. Note: This command is only available if you have selected the Reference layout option.
 | Add Block Part | Adds a rectangular area to the selected block. Note: This command is only available if you have selected the Reference layout option.
 | Cut Block Part | Deletes a rectangular area from the selected block. Note: This command is only available if you have selected the Reference layout option.
 | Delete Block | Deletes the selected block from the image. Note: This command is only available if you have selected the Reference layout option.
 | Add Vertical Separator | Adds a vertical separator to the selected Table block. Note: This command is only available if you have selected the Reference layout option.
 | Add Horizontal Separator | Adds a horizontal separator to the selected Table block. Note: This command is only available if you have selected the Reference layout option.
 | Delete Separator | Deletes a separator from the selected Table block. Note: This command is only available if you have selected the Reference layout option.
Correct Orientation |  | Auto corrects the orientation of pages. The correct orientation is selected automatically based on the selected pre-recognition language and the settings made in the Options dialog box (Tools>Options…).
Pre-Recognize |  | Pre-recognizes the selected pages.
Copy Matched Layout to Reference |  | Creates a reference layout for the image on the basis of the results of FlexiLayout matching. Note: This command is only available for images which were matched with their FlexiLayouts.
Hide Active Blocks or Elements |  | Hides the selected blocks or elements on the image. This is useful when reviewing images on which both objects and regions of elements/blocks are selected. You may wish to temporarily hide an element to see the object under this element.
Page Properties… |  | Opens the Properties dialog box for the open page. On the Image tab, you can see the information available about the image - its size, resolution, and color. On the Page tab, you can see the information available about the current page - its number, source image, and the FlexiLayout matching results.


FlexiLayout menu

FlexiLayout / Classifier menu

Command |  | Description
Add Block | Text | Creates a new block of type Text in the blocks branch.
 | Table | Creates a new block of type Table in the blocks branch.
 | Barcode | Creates a new block of type Barcode in the blocks branch.
 | Checkmark | Creates a new block of type Checkmark in the blocks branch.
 | Checkmark Group | Creates a new block of type Checkmark Group in the blocks branch.
 | Picture | Creates a new block of type Picture in the blocks branch.
 | Non-Recognized | Creates a new block of type Non-Recognized in the blocks branch.
 | Group | Creates a new block of type Group in the blocks branch.
 | Repeating Group | Creates a new block of type Repeating Group in the blocks branch.
Add Element | Header | Adds a Header element to the FlexiLayout, which indicates the start of a new document.
 | Footer | Adds a Footer element to the FlexiLayout, which indicates the end of the document.
 | Group | Creates a Group element.
 | Static Text | Creates a new element of type Static Text.
 | Labeled Field | Creates a new element of the Labeled Field in the elements branch.
 | Character String | Creates a new element of type Character String in the elements branch.
 | Text Fragment | Creates a new element of type Text Fragment in the elements branch.
 | Date | Creates a new element of type Date in the elements branch.
 | Currency | Creates a new element of type Currency in the elements branch.
 | Phone | Creates a new element of type Phone in the elements branch.
 | Separator | Creates a new element of type Separator in the elements branch.
 | Barcode | Creates a new element of type Barcode in the elements branch.
 | Object Collection | Creates a new element of type Object Collection in the elements branch.
 | White Gap | Creates a new element of type White Gap in the elements branch.
 | Region | Creates a new element of type Region in the elements branch.
 | Table | Creates a new element of type Table in the elements branch.
 | Repeating Group | Creates a new element of type Repeating Group in the elements branch.
Convert Element to | Header | Converts the element to Header.
 | Footer | Converts the element to Footer.
 | Group | Converts the element to Group.
 | Static Text | Converts the element to Static Text.
 | Labeled Field | Converts the element to Labeled Field.
 | Character String | Converts the element to Character String.
 | Text Fragment | Converts the element to Text Fragment.
 | Date | Converts the element to Date.
 | Currency | Converts the element to Currency.
 | Phone | Converts the element to Phone.
 | Separator | Converts the element to Separator.
 | Barcode | Converts the element to Barcode.
 | Object Collection | Converts the element to Object Collection.
 | White Gap | Converts the element to White Gap.
 | Region | Converts the element to Region.
 | Table | Converts the element to Table.
Cut |  | Removes the element and copies it to the Clipboard.
Copy |  | Copies the element to the Clipboard.
Paste |  | Pastes the element from the Clipboard into the FlexiLayout.
Disable |  | Disables the selected element or block (i.e. makes it temporarily unavailable). Note: If there are elements and/or blocks in the FlexiLayout tree which refer to disabled elements, you need to either disable such elements and/or blocks or remove the references to disabled elements. Otherwise the program will fail to build the FlexiLayout.
Test Element |  | Tests the selected element.
Test Header |  | Tests the header.
Test Footer |  | Tests the footer.
Import Layout… |  | Imports a FlexiLayout from FlexiLayout Studio.
Build |  | Builds the FlexiLayout.
Save |  | Saves the FlexiLayout.
Properties… |  | Opens the Properties dialog box where you can view the properties of the FlexiLayout.


Tools menu

Item | Description
Find in Advanced Code… | Finds and replaces strings in the entire code on all the Advanced tabs. See Finding and replacing code strings on the Advanced tab.
Fuzzy Interval Editor… | Opens the fuzzy interval visual editor.
Options… | Opens the Options dialog box, where you can select units of measurement to be used in the program, the colors of objects, the colors for highlighting lexemes, and the possible orientations of pages in the batch to be used for auto selecting the orientation when you select the Correct Orientation command or match a FlexiLayout.


Help menu

Command | Description
Help Topics… | Opens the Help file.
Tutorial | Opens the Tutorial section of the Help file.
Send Feedback | Opens the Send your feedback page on the ABBYY website.
About… | Opens the About dialog box which contains brief information about ABBYY FlexiLayout Studio.


Block shortcut menu

Right-click a block in the FlexiLayout tree to display its shortcut menu.

Command |  | Description
New | Text | Creates a new block of type Text.
 | Table | Creates a new block of type Table.
 | Barcode | Creates a new block of type Barcode.
 | Checkmark | Creates a new block of type Checkmark.
 | Checkmark Group | Creates a new block of type Checkmark Group.
 | Picture | Creates a new block of type Picture.
 | Non-Recognized | Creates a new block of type Non-Recognized.
 | Group | Creates a new block of type Group.
 | Repeating Group | Creates a new block of type Repeating Group.
Cut |  | Removes the block and copies it to the Clipboard.
Copy |  | Copies the block to the Clipboard.
Paste |  | Pastes the block into the FlexiLayout
Delete |  | Deletes the selected block.
Disable |  | Disables the selected element or block (i.e. makes it temporarily unavailable).
Build FlexiLayout |  | Builds the FlexiLayout.
Save FlexiLayout |  | Saves the FlexiLayout.
Properties… |  | Opens the Properties dialog box where you can view the properties of the block.


Hypothesis shortcut menu

Right-click somewhere in the right-hand pane of the Hypothesis window to display its shortcut menu.

Item | Description
Show Details | Displays the hypotheses for the subelements in the selected Group element.
Go One Level Up | Goes one level up the tree and displays the hypotheses of the parent Group element. Available for all hypotheses with the exception of the hypotheses for the root element (SearchElements).
Expand Active | Displays all the hypotheses for the next element which originate from the current hypothesis. Available for hypotheses which have more than one child hypothesis for the next element.
Collapse Active | Hides all the hypotheses for the next element which originate from the current hypothesis. This command is used to view trees of hypotheses which have too many branches. Available for hypotheses which have more than one child hypothesis for the next element. Note: The hypothesis from the best path, i.e. the hypothesis which the program considers a good match, will not be hidden.
Expand All | Displays all the hypotheses, including those not from the best path. Available for any hypothesis for any element.
Collapse All | Hides all the hypotheses which are not from the best path. Available for any hypothesis for any element.
Show Search Area | Shows/hides the search area for the element for which the hypothesis has been formulated.
Element Properties… | Opens the Properties dialog box where you can view the properties of the element for which the hypothesis was formulated.


Image shortcut menu

Right-click somewhere in the Image window to display its shortcut menu.

Command |  | Description
Match |  | Matches the FlexiLayout with the open image.
Classi&fy |  | Classifies the current image. This command is available only in classifier projects.
Go to Page… |  | Goes to the page with the specified number.
Pre-Recognize |  | Pre-recognizes the selected pages.
Copy Matched Layout to Reference |  | Creates a reference layout for the image. Note: This command is only available for images which were matched with their FlexiLayouts.
Correct Orientation |  | Auto corrects the orientation of pages. The correct orientation is selected automatically based on the selected pre-recognition language and the settings made in the Options dialog box (Tools>Options…).
Test Element |  | Tests the selected element.
Match Layout |  | Attempts to match the current layout alternative.
Hide Active Blocks or Elements |  | Hides the selected blocks or elements on the image.
Scale | 200% | Sets the scale of the Image window to 200%.
 | 100% | Sets the scale of the Image window to 100%.
 | 50% | Sets the scale of the Image window to 50%.
 | 25% | Sets the scale of the Image window to 25%.
 | Fit Width | Fits the width of the image to the window.
 | Fit Height | Fits the length of the image to the window.
 | Fit Page | Fits the entire image to the window.
 | Zoom In | Makes the image 25% as large.
 | Zoom Out | Makes the image 25% as small.
Show Image Objects | Show All Objects | Displays all the objects detected during pre-recognition.
 | Hide All Objects | Hides all the objects detected during pre-recognition.
 | Recognized Words | Displays only the objects classified as Text during pre-recognition.
 | Recognized Lines | Displays only the objects classified as Recognized Lines during pre-recognition.
 | Separators | Displays only the objects classified as Separators during pre-recognition.
 | Raw Objects | Displays only the objects which the program managed to classify during pre-recognition.
 | Barcodes | Displays only the objects classified as Barcodes during pre-recognition.
 | Note: To select multiple types of objects, hold down the Ctrl key while clicking the desired buttons on the toolbar or selecting the menu items.
Image Operations | Rotate Clockwise | Rotates the image by 90° clockwise.
 | Rotate Counter-Clockwise | Rotates the image by 90° counter-clockwise.
 | Rotate Upside Down | Rotates the image by 180°.
 | Flip Horizontally | Flips the image horizontally.
 | Flip Vertically | Flips the image vertically.
 | Invert | Inverts the image (turns black into white and vice versa).
 | Despeckle | Removes excess dots from the image.
Tool | Select | Selects an existing block on the image.
 | Measure Rectangle | Detects the coordinates and sizes of objects on the image and copies them to the Clipboard.
 | Create Block | Creates a new block on the image. Note: This command is only available if you have selected the Reference layout option.
 | Add Block Part | Adds a rectangular area to the selected block. Note: This command is only available if you have selected the Reference layout option.
 | Cut Block Part | Deletes a rectangular area from the selected block. Note: This command is only available if you have selected the Reference layout option.
 | Delete Block | Deletes the selected block from the image. Note: This command is only available if you have selected the Reference layout option.
 | Add Vertical Separator | Adds a vertical separator to the selected Table block. Note: This command is only available if you have selected the Reference layout option.
 | Add Horizontal Separator | Adds a horizontal separator to the selected Table block. Note: This command is only available if you have selected the Reference layout option.
 | Delete Separator | Deletes a separator from the selected Table block. Note: This command is only available if you have selected the Reference layout option.
Properties… |  | Opens the Properties dialog box.


Batch shortcut menu

Right-click somewhere in the Batch window to display its shortcut menu.

Command |  | Description
Match |  | Matches the FlexiLayout with the selected pages.
Classi&fy |  | Classifies the selected pages. This command is available only in classifier projects.
Open & Add Images… |  | Opens the Open Images dialog box where you can select one or several images to be added to the batch.
Open Page |  | Opens the selected image.
Go to Page… |  | Opens the Go to Page dialog box where you can enter the number of the page to which you wish to go.
Pre-Recognize |  | Pre-recognizes the selected pages.
Copy Matched Layout to Reference |  | Creates a reference layout for the image on the basis of the results of FlexiLayout matching. Note: This command is only available for images which were matched with their FlexiLayouts.
Assemble to Reference Documents… |  | Opens Assemble to Reference Documents dialog box, where you can set the reference assembly parameters and create a reference assembly of the selected documents.
Disassemble Reference Documents |  | Cancels the reference assembly for the selected documents.
Change Reference Header/Footer… |  | Opens the Change Header/Footer dialog box, where you can specify whether header/footer should coincide with the first/last pages of the selected documents.
Delete Pages |  | Deletes the selected pages from the batch.
Delete Page Data… |  | Opens the Select Data to Delete dialog box where you can select the page data to be deleted
Image Operations | Rotate Clockwise | Rotates the images of the selected pages by 90° clockwise.
 | Rotate Upside Down | Rotates the images of the selected pages by 180°.
 | Rotate Counter-Clockwise | Rotates the images of the selected pages by 90° counter-clockwise.
 | Despeckle | Removes excess dots from the images of the selected pages.
 | Invert | Inverts the images of the selected pages (turns black into white and vice versa).
 | Flip Horizontally | Flips the images of the selected pages horizontally.
 | Flip Vertically | Flips the images of the selected pages vertically.
Correct Orientation |  | Auto corrects the orientation of pages in the batch. The correct orientation is selected automatically based on the selected pre-recognition language and the settings made in the Options dialog box (Tools>Options…).
Test Element |  | Tests the selected element.
Test Header |  | Tests the header of the document.
Test Footer |  | Tests the footer of the document.
Match Layout |  | Attempts to match the current layout alternative.
Properties… |  | Opens the Properties dialog box.


FlexiLayout shortcut menu

Right-click in the FlexiLayout window to display this shortcut menu.

Command | Description
Build FlexiLayout | Builds the FlexiLayout.
Save FlexiLayout | Saves the FlexiLayout.
Add Layout Alternative | Adds a layout alternative.
Import Layout Alterantives… | Opens a dialog box where you can select the projects from which to import layout alternatives.
Select Alternative Layout | Selects a layout alternative.
Properties… | Opens the Properties dialog box where you can view the properties of the FlexiLayout.


Element shortcut menu

Right-click an element in the FlexiLayout tree to display its shortcut menu.

Command |  | Description
Add Element | Header | Adds a Header element to the FlexiLayout, which indicates the start of a new document.
 | Footer | Adds a Footer element to the FlexiLayout, which indicates the end of the document.
 | Group | Creates a new element of type Group in the elements branch.
 | Static Text | Creates a new element of type Static Text in the elements branch.
 | Labeled Field | Creates a new element of type Labeled Field in the elements branch.
 | Character String | Creates a new element of type Character String in the elements branch.
 | Text Fragment | Creates a new element of type Text Fragment in the elements branch.
 | Date | Creates a new element of type Date in the elements branch.
 | Currency | Creates a new element of type Currency in the elements branch.
 | Phone | Creates a new element of type Phone in the elements branch.
 | Separator | Creates a new element of type Separator in the elements branch.
 | Barcode | Creates a new element of type Barcode in the elements branch.
 | Object Collection | Creates a new element of type Object Collection in the elements branch.
 | White Gap | Creates a new element of type White Gap in the elements branch.
 | Region | Creates a new element of type Region in the elements branch.
 | Table | Creates a new element of type Table in the elements branch.
 | Repeating Group | Creates a new element of type Repeating Group in the elements branch.
Convert Element To | Header | Converts the element to Header.
 | Footer | Converts the element to Footer.
 | Group | Converts the element to Group
 | Static Text | Converts the element to Static Text.
 | Labeled Field | Converts the element to Labeled Field.
 | Character String | Converts the element to Character String.
 | Text Fragment | Converts the element to Text Fragment.
 | Date | Converts the element to Date.
 | Currency | Converts the element to Currency.
 | Phone | Converts the element to Phone.
 | Separator | Converts the element to Separator.
 | Barcode | Converts the element to Barcode.
 | Object Collection | Converts the element to Object Collection.
 | White Gap | Converts the element to White Gap.
 | Region | Converts the element to Region.
 | Table | Converts the element to Table.
Cut |  | Removes the element and copies it to the Clipboard.
Copy |  | Copies the element to the Clipboard.
Paste |  | Pastes the element from the Clipboard into the FlexiLayout.
Delete |  | Deletes the selected element.
Disable |  | Disables the selected element (i.e. makes it temporarily unavailable).
Test Element |  | Tests the selected element.
Match Layout |  | Attempts to match the current layout.
Select Layout |  | Selects the current layout.
Import Layout… |  | Imports a FlexiLayout from FlexiLayout Studio.
Find in Code |  | Finds and replaces text in the code on the Advanced tab of the selected element and its subelements.
Build |  | Builds the FlexiLayout.
Save |  | Saves the FlexiLayout.
Properties… |  | Opens the Properties dialog box where you can view the properties of the selected element.


Classifier Log window, shortcut menu

Right-click the Classifier Log window to open its shortcut menu.
Item | Description
Display Hypotheses | Displays the hypotheses generated for the elements of the classifier.


Projects

A project is a set of files created in ABBYY FlexiLayout™ Studio and containing information about the elements and their properties, the test images, etc.

Projects fall into the following two types:

  • FlexiLayout projects. These projects are used to develop FlexiLayouts to detect data fields on documents.
  • Classifier projects. These projects are used to develop classifiers to group documents into classes.

Within projects, FlexiLayouts and classifiers are build, tested, and debugged.

A project includes:

  • the descriptions of the elements (a FlexiLayout or a classifier)
  • the batch of images based on which the FlexiLayout is created and debugged

A FlexiLayout project has the extension *.fsp. A classifier project has the extension .fcp. The default storage location of the images you add to the batch of images is [project name]Batch, and the default location of the FlexiLayout is [project name]Template.

To start working with ABBYY FlexiLayout Studio, you need to create a new project or open an existing one.

More

Working with projects


FlexiLayout projects

A FlexiLayout project contains information about the FlexiLayout, i.e. information about its blocks, elements and their properties, test images, etc.

In the FlexiLayout project, you create layout alternatives, add elements and blocks, and specify their properties. The project also allows you to debug the FlexiLayout, build it, and test it.

A FlexiLayout project includes:

  • the layout alternatives consisting of blocks and elements
  • the batch of images based on which the FlexiLayout is created and debugged

More

FlexiLayouts

Working with projects


Classifier projects

Classifier project contains a set of elements that can be used to quickly identify the pages. The classification result is saved in the properties of each page as a text string. For example, the name of the appropriate FlexiLayout (or layout alternative) may be saved in the page properties.

In the project, you need to create a classifier, specify its structure, add identifier elements, and specify their properties. The project also allows you to debug the classifier, build it, and test it.

A classifier project includes:

  • the classifier, with the required classifying stages and identifier elements
  • the batch of images based on which the classifier is created and debugged

More

Classifiers

Working with projects


Working with projects

When you start working with ABBYY FlexiLayout Studio, you need to create a new project or open an existing project.

To create a new project:

  1. Select the New Project... command in the File menu.
  2. Select a project type (Classifier Project… or FlexiLayout Project…).
  3. In the Create Project dialog box, enter a name for your new project.

Once you have created the new project, you can add images to the batch and create a FlexiLayout.

To open an existing project:

  1. Select the Open Project… command in the File menu.
  2. In the Open Project dialog box, select the file of the project you wish to open.

To view the properties of the project, select File> Project Properties… The paths to the project file and to the image batch will be dispalyed. You can add your comment to the batch if you wish.

to close the project, select Close Project in the File menu.


Batches

A batch is a collection of test images (pages) which are used for debugging the FlexiLayout.

The more test pages a batch contains, the better the resulting FlexiLayout. Test pages must be representative, i.e. they must include all the elements that may occur on the real-life forms to be processed and cover as many layout variations as possible.

You can add images of various formats to a batch. For a full list of supported formats, see the Supported images formats page.

A batch may contain images of different resolutions. You can also add images of one and the same document scanned at different resolutions. Thus, when creating and testing your FlexiLayout, you will be able to select the resolution that ensures the best quality of optical recognition and object detection.

More

Adding, viewing, and deleting test images

Working with images


Adding, viewing, and deleting test images

To add a page to the batch:

  1. Select the Open & Add Images… command in the File menu.
  2. In the dialog box, select the desired images and click Open.
    Note: You can add multi-page files into a batch. In this case, the program will add several pages. Image files need not have the same resolutions.

When adding mages to the batch, you can define the principles to be used for the reference assembly of images into documents. You can create a document for each image file (select One document per file) or assemble a specified number of pages into a document (select Group by page count and enter the number of pages per one document). For details, see Reference assembly.

Tip: You can also add images to a batch from your Windows Explorer. Left-click the desired image file and, without releasing the mouse button, drag the file to the FlexiLayout Studio window. When the program window opens, drag the file to the Batch window.

To open a page image:

  1. In the Batch window, select the page whose image you wish to open.
  2. Select the Open Page command in the Batch menu or in the shortcut menu. Alternatively, you can simply double-click the desired page to open it.

To remove a page or several pages from the batch:

  1. In the Batch window, select the images you wish to remove.
  2. Select the Delete Pages command in the Batch menu or in the shortcut menu.


Working with images

ABBYY FlexiLayout Studio provides the following operations that can make your work with images in the program more convenient:

  • Rotating the image (90° clockwise or counterclockwise, or 180°) and auto correcting image orientation
  • Flipping the image (horizontally or vertically)
  • Inverting the image
  • Despeckling the image
  • Rescaling the image

If the image is opened in the Image window, you can use the buttons of the Image Tools toolbar, the commands of the Image menu, or the commands of the shortcut menu of the Image window:

If you want to... | click | or select the following command in the Image menu
Rotate the image 90° clockwise |  | Image Operations> Rotate Clockwise
Rotate the image 90° counterclockwise |  | Image Operations> Rotate Counter-Clockwise
Rotate the image 180° |  | Image Operations> Rotate Upside Down
Correct image orientation |  | Correct Orientation
Flip the image horizontally |  | Image Operations> Flip Horizontally
Flip the image vertically |  | Image Operations> Flip Vertically
Invert the image (replace white dots with black dots and vice versa) |  | Image Operations> Invert
Despeckle the image (remove the noise from the image) |  | Image Operations> Despeckle
Zoom in to 2x |  | Image Window Scale> Zoom In
Zoom out |  | Image Window Scale> Zoom Out

You can also work with images of multiple pages simultaneously:

  • Select the desired pages in the Batch window, then use the commands of the Batch>Image Operations menu or the commands of the shortcut menu of the Batch window.

Note: When you perform image operations, all the pre-recognition and FlexiLayout matching results are deleted. When rotating and flipping images, the Reference Layout is also deleted.


FlexiLayouts

A FlexiLayout is a formalized description of the structure of a document which allows a data capture program to detect image areas which correspond to data fields. FlexiLayouts have a tree-like structure. A FlexiLayout has a tree-like structure and consists of one block branch and several element branches, each branch corresponding to a layout alternative.

Elements describe image objects that must be detected. In order to enable a data capture application such as ABBYY FlexiCapture 9.0 to detect an object, you need to create a FlexiLayout elements corresponding to this object and in the element's properties specify the type of the object (i.e. whether it is a text fragment, a picture, a barcode, etc.), its geometrical data (length, width, etc.), and search area where the object is most likely to be found.

Blocks describe data fields from which data must be captured. The location of the blocks can be either specified relative to the location of elements or directly by entering their presumed c coordinates on the document. The purpose of any FlexiLayout is to provide a data capture application with an algorithm of finding blocks.

Blocks of a FlexiLayout are independent of one another. Elements, on the other hand, can be grouped together to form a complex hierarchy where elements are logically interconnected and the location of one element determines the location of another. The order of the elements in the tree determines the order in which they are searched - a data capture program will look for the topmost elements first, find the corresponding objects on the image, and then use this information to locate blocks.

By default, a new FlexiLayout Studio project has the name FlexiLayout. Its elements and blocks branches are empty.

More

FlexiLayout properties

Blocks

Elements


FlexiLayout properties

For each FlexiLayout, you need to specify the following properties:

Name - The name of the FlexiLayout. The default name is 'FlexiLayout'

Version - The version of the FlexiLayout. You can create and use several versions (or "editions") of one FlexiLayout

Comment - Your comment to the FlexiLayout (optional). This field may contain any text

Note: The Comment field will be available for viewing in the FormReader Template Editor. When you create a FormReader template from an *.alf file (these files are generated when exporting FlexiLayouts from FlexiLayout Studio), the comment to the FlexiLayout will be displayed in the template properties in read-only mode. Therefore, this field can be used to add information about the author of the FlexiLayout.

Pre-recognition parameters: Text languages, Text type, Mode - These parameters are used during pre-recognition

Multi-page parameters (Minimum number of pages, Maximum number of pages) - Set the minimum and maximum number of pages per document

Constants - These are global constants which can be used when specifying additional search criteria.

To select or view the properties of a FlexiLayout, select the Properties… command from the FlexiLayout menu (or the Properties… command from the shortcut menu of the FlexiLayout).

More

Pre-recognition

Pre-recognition parameters

Identifying and processing FlexiLayouts in ABBYY FormReader

Global constants


Layout alternatives

Sometimes you may encounter documents with identical sets of parameters (blocks), identical rules, and written in the same language, but with element positions varying greatly from one document to another. In this case, for the sake of convenience, you may create a FlexiLayout that includes several alternative layouts, each layout corresponding to a particular subset of documents with identically positioned elements. Apart from the layouts, the other processing parameters (pre-recognition/languages, rules, number of pages, etc.) will remain the same for all such documents described by the FlexiLayout.

Layout alternatives are specified as separate branches in the tree of elements. Thus, instead of one Group element (named SearchElements by default), you can create several elements, each having its own layout alternative represented by a branch of elements that described one particular subset of documents. The layout alternatives are independent, and elements in one branch should not refer to elements in another.

The names of layout alternatives (i.e. root elements) should be unique. We recommend selecting descriptive names that reflect the nature of the corresponding document subset.

When matching the FlexiLayout, the program will apply the layout alternatives one by one, top to bottom. If more than one layout alternative match a document, the first match will be used.

Image areas are specified for the blocks in each layout alternative (see the Blocks section for more information).

When debugging the FlexiLayout, you can choose just one layout alternative. To choose a layout alternative, select either the Select Layout item from the shortcut menu of the element, or the Select Alternative Layout item from the shortcut menu of the FlexiLayout.

To create a layout alternative:

  1. Select the root element of the layout (named FlexiLayout1 by default).
  2. Select Add Layout Alternative from the shortcut menu.
  3. Specify a name and properties for the layout.
    Note: The name of a layout alternative must start with a letter or an underscore, which may be followed by letters or digits. You may not use spaces or any of the following special symbols: '.', ',', ':', '-', '\', '/'. The name may not coincide with any of the reserved keywords.

To copy a layout alternative:

Select the layout alternative you wish to copy. Holding down the Ctrl key and the left mouse button, drag a copy of the layout alternative to the desired location. Alternatively, you can copy a layout by selecting the Copy/Paste commands from its shortcut menu or be pressing the Ctrl+C/Ctrl+V combinations.
Tip: Generally, it is easier to copy an existing layout alternative and make some adjustments to it than create a new layout alternative from scratch.

To import layout alternatives from another FlexiLayout:

  1. Select the root element of the layout (named FlexiLayout1 by default).
  2. Select Import Layout Alterantives… from the shortcut menu.
  3. Select the FlexiLayout from which you wish to import layout alternatives and click Open.

Note: All the available layout alternatives will be imported. If required, delete the redundant alternatives.

For the blocks that have identical names in the two FlexiLayouts, the image areas will be added. If the FlexiLayout from which you import layout alternatives has additional blocks, the will also be copied to the current FlexiLayout.

To import elements and blocks from another FlexiLayout:

  1. Select the layout alternative to which you wish to add elements from another FlexiLayout.
  2. Select Import Layout… from the shortcut menu.
  3. Select the FlexiLayout from which you wish to import elements and click Open.

Note: You can import elements only from FlexiLayouts without layout alternatives. Both the elements and the blocks will be imported. If the name of an element or block being imported is identical to that in the current FlexiLayout, a number will be added to the name of the imported element or block.

To delete a layout alternative

  1. Right-click the layout alternative (i.e. the branch in the tree of elements) you wish to delete.
  2. Select Delete from the shortcut menu or press Del.

Tip: You can temporarily disable a layout alternative by selecting Disable from its shortcut menu.

To change the order of layout alternatives:

Click the layout alternative you wish to move and, holding down the left mouse button, drag it to the desired location.


Global constants

Note: Global constants are used to specify additional search criteria (element's Properties dialog box, Advanced tab, Advanced pre-search relations and Advanced post-search relations sections; block's Properties dialog box, Expression field).

Global constants are set for the entire FlexiLayout and accessible in all sections of the program code.

When creating a global constant, you must specify its name and value. The name of a constant must start with a letter or an underscore character, then it can consist of letters and digits. Constant names must not contain blank spaces or special symbols. The name of a constant must be unique for the FlexiLayout in which it is to be used and cannot coincide with any of the reserved words. This means that you may not declare variables in the code whose names coincide with the names of the global constants.

Constants may be of any type which has a constructor in the FlexiLayout language. The type of a constant is either defined explicitly by calling its constructor, or is derived by the program from its value (e.g. type String). When you use a constant in your code, the compiler will check that this type of constant may be used in the given context. This check is performed when you build the FlexiLayout or when you ask the program to check the code in a particular field.

You can create global constants using global functions and other already created global constants.

Examples of global constants:

Name | Value | Type
RomanNumerals | "I V v X x" | String
SomeRect | Rect( 5mm, 10mm, 20mm, 50mm ) | Rect
FirstPageRect | Page( 1 ) .RectGlobal | Rect
UpperHalfOfFirstPage | Rect(FirstPageRect.Left, FirstPageRect.Top FirstPageRect.Right, FirstPageRect.Height / 2 ) | Rect
UpperHalfOfFirstPage 1 | Region( UpperHalfOfFirstPage ) | Region
TotalLineHeightOfFirstPage | Page( 1 ).AverageLineHeight() + Page( 1 ).AverageInterlineInterval() | Distance
Q_50_Percent | Quality( 0.5 ); | Quality

Adding, changing, and removing global constants

To add a global constant:
  1. Select the Properties… command from the FlexiLayout menu (or right-click in the FlexiLayout window and select the Properties… command from the shortcut menu).
  2. In the Properties dialog box, click the Constants tab.
  3. Click Add…
  4. Type a name and/or value for the constant and click OK.

To change a global constant:

  1. Select the Properties… command from the FlexiLayout menu (or right-click in the FlexiLayout window and select the Properties… command from the shortcut menu).
  2. In the Properties dialog box, click the Constants tab and select the constant you wish to change.
  3. Click Edit…
  4. Type a new name and/or value for the constant and click OK.

To remove a global constant:

  1. Select the Properties… command from the FlexiLayout menu (or right-click in the FlexiLayout window and select the Properties… command from the shortcut menu).
  2. In the Properties dialog box, click the Constants tab and select the constant you wish to remove.
  3. Click Delete.


Multi-page FlexiLayout

ABBYY FlexiLayout Studio 9.0 allows you to create FlexiLayouts for multi-page documents. The program will treat the document as one whole and look for the elements irrespective of the pages on which they are located.

In the FlexiLayout properties you must specify the minimum and maximum possible numbers of pages in the document. You can specify the exact number of pages in the document using the SetPagesCount function of the FlexiLayout description language.

For details, see

Using Header and Footer elements to detect the beginning and end of a document

Matching a multi-page FlexiLayout

Support for multi-page documents in ABBYY FlexiLayout Studio


Using Header and Footer elements to detect the beginning and the end of a document

To detect the beginning and the end of a document, the use of special Header and Footer elements is recommended. These are compound elements and must be placed at the beginning of the branch of elements. In the tree of elements, Header elements are marked with [image] and Footer elements are marked with [image].

The Header element is positioned on the first page of the document and may not occur on any of the subsequent pages. We recommend selecting a Header element which uniquely identifies the documents described by the FlexiLayout.

The Footer element is positioned on the last page of the document and may not occur on the preceding pages.

The Header and Footer elements are part of the FlexiLayout and their hypotheses may be used to search for other elements.

When applying a multi-page FlexiLayout, the Header and Footer elements are used to detect the first and last pages of the document respectively.

Tip:
The use of Header and Footer elements greatly improves detection of documents and speeds up the FlexiLayout matching process. Be sure to use these elements whenever possible.

More

Header and Footer

Matching a multi-page FlexiLayout


Matching a multi-page FlexiLayout

To match a FlexiLayout with multiple pages, select the pages in the Batch or in the Image window and then select Match from the shortcut menu. The application will attempt to match the FlexiLayout as follows:

  1. The selected pages are pre-recognized. For each page, the correct orientation is automatically selected based on the pre-recognition language.
  2. The first page in the document is detected.
  3. The last page in the document is detected.
  4. The FlexiLayout is matched with the detected pages.
  5. If the FlexiLayout matches the pages, steps 2-4 are performed for the page following the recognized document. If the FlexiLayout does not match, the steps are performed starting with the next page.

The first page in the selection becomes the first page of the document. Next, the program will treat the page following the last page of the previous document as the first page of the new document.

If the FlexiLayout has a set number of pages (the possible number of pages is specified in the FlexiLayout properties), the last page is detected based on the specified number of pages. If the number of pages may vary in the range [MinPages, MaxPages], the program will check if a Footer element is present on the last page with the number MinPages. If this page contains a Footer element, it is deemed to be the last page in the document. Otherwise, the program will check the following conditions for each next page starting from MinPages+1):

  1. Whether this page is redundant (its number in the document is greater than the maximum number of pages MaxPages).
  2. Whether this page contains a Header element (this check is performed with the Footer element is optional).
  3. Whether this page contains a Footer element.

If 1 or 2 is true, the preceding page is selected as the last page in the document. If 3 is true, the current page is selected as the last page in the document.


Support for multi-page documents in ABBYY FlexiLayout Studio

Multi-page sheet and coordinates

The multitude of all the pages of a document is termed a multi-page sheet. A multi-page sheet is obtained by merging together the pages of the document top down, without any joints or gaps, the left edges of all the pages are placed on the same axis that goes through the point (0,0). The sequence of the pages in the sheet depends on their order in the batch.

Two coordinate systems are used – global (goes through the entire document) and local (bound to a particular page. The only difference between the global and local coordinate systems is that the global system has parallel shifts, each page having its own shift.

Example.

Let there be 3 pages in document 3 having the following sizes: 2500x3500, 2400x3400, and 2300x3300.
Then the global coordinates of the pages are: [0, 0, 2500, 3500], [0, 3500, 2400, 6900], [0, 6900, 2300, 10200] (in the order [left, top, right, bottom] ).

For relations between elements, the global coordinate system is used, so that the relations, such as BELOW, are interpreted correctly.

Multi-page hypotheses

Hypotheses for the following elements may be located on multiple pages:

  • Group
  • Repeating Group
  • Table
  • Text Fragment
  • Object Collection

Text Fragment and Object Collection elements contain all the appropriate objects within the search area.


Pre-recognition

Pre-recognition is the first stage of processing a semi-structured document. Unlike structured forms, which are designed with computer processing in mind, unstructured documents have no reference points, such as black squares which tell the program where to look for data fields. For this reason, pre-recognition is used to detect objects on the document which could signal the location of data fields.

Pre-recognition is the first stage of document analysis both in FlexiLayout Studio and in a data capture application. Since pre-recognition may take considerable time, FlexiLayout Studio allows you to carry out pre-recognition independently of FlexiLayout matching, so that you can concentrate entirely on creating and testing your FlexiLayout.

However, you need to assess the quality of the pre-recognition results before you start creating your FlexiLayout. The quality of pre-recognition depends on the quality of the test images in the batch. The quality of the test images, in its turn, depends on the scanning parameters such as brightness, contrast, and resolution. If you are not satisfied with the quality of the pre-recognition results, you may need to change the scanning options and re-scan your test documents. Note also that FlexiLayout Studio allows you to add images scanned at different resolutions, so that you can experiment with pre-recognition and FlexiLayout matching and select the optimal scanning options.

Pre-recognition can be run in fast or full mode (see Pre-recognition parameters for details). For the purposes of document analysis, pre-recognition need not be perfect. There is always a way of finding practically any data field even if several recognition errors have been made. Indeed, sometimes pre-recognition speed is more important than quality - the quality of recognition may be tackled at a later stage in a data capture application where you can specify data types for each field, thereby greatly improving the quality of recognition.

During pre-recognition, the program analyzes the locations of dots of various colors, detects basic objects, and merges text fragments into words and lines. The program may detect the following types of basic object:

  • Raw Text
  • Picture
  • Punctuation Mark
  • Inverted
  • Separator
  • Barcode
  • Checkmark

Once basic objects have been detected, the program starts recognizing the text. Recognized text can be of the following two types:

  • Recognized Words
  • Recognized Lines

More

Pre-recognition parameters

Running pre-recognition and viewing the results

Analyzing images


Pre-recognition parameters

Pre-recognition parameters must be specified for each FlexiLayout. It is important to select the right pre-recognition parameters for each type of form.

The following pre-recognition parameters must be specified:

Text type - the method used to type the text on the forms (Typographic, Matrix printer, or Typewriter).

Mode - two pre-recognition modes are available: Fast and Full. In the fast mode, color and grayscale images are first binarized (i.e. converted to black and white). Fast mode saves time and produces good results for most forms. The full mode is recommended if:

  • poor quality forms are used and fast mode recognition results in too many errors
  • color-sensitive recognition is required

Text languages - the languages used in the forms. You can select one or several languages from the drop-down list. For the full list of available languages, see OCR languages supported in ABBYY FlexiLayout™ Studio.

to specify pre-recognition parameters, select the Properties… command from the FlexiLayout menu (or select the Properties… command from the shortcut menu of the FlexiLayout) and click the FlexiLayout / Classifier tab.

Show me the dialog boxes where to enter pre-recognition parameters


Running pre-recognition and viewing the results

To run pre-recognition:

  1. In the Batch window, select one or more images in the batch.
  2. Right-click in the Batch window or in the Image window, and select Image>Pre-Recognize.

to display the recognized objects on the image:

  1. Open the image.
  2. Select the objects you wish to view (Image>Show Image Objects):
  • Show All Objects (or click all the buttons on the Extracted Objects toolbar),
  • Recognized Words (or click [image]),
  • Recognized Lines (or click [image]),
  • Separators (or click [image]),
  • Raw Objects (or click [image]),
  • Barcodes (or click [image]).

Note: To select multiple types of objects, hold down the Ctrl key while clicking the desired buttons on the toolbar or selecting the menu items.

You can view the properties of each object on the image in the Properties window. Click the object whose properties you wish to view. The properties of the selected object will be displayed in the Properties window.


Analyzing images

You need to analyze the images in the batch in order to find objects which can form the backbone of your FlexiLayout, i.e. you need to find objects which are present on all of the images and which can be reliably detected by the program.

Another important decision you need to make when analyzing the images is in which order to describe the objects, as this order determines the order in which the program will use the elements when matching the FlexiLayout with its corresponding forms.

The general scenario is as follows:

  1. Look through the images in the batch and group similar images together.
  2. Visually try to find objects which are present on most of the images and occur on each image only once. Such objects will form the backbone of your FlexiLayout.
  3. Find an object (or objects) which can be used as the form identifier. This can be the title or any other object which unambiguously identifies the form as belonging to a particular type of document. The identifier object must be present on all of the forms and, if possible, recognized without errors. We recommend marking the element which will describe the identifier object as required element. If the program fails to find the object corresponding to this element, FlexiLayout matching will be stopped, which will mean that the form does not belong to the document type described by the FlexiLayout
  4. Consider the order in which you will create elements and how they will be arranged in the FlexiLayout tree. The order of elements in the tree will determine the order in which the program will look for the corresponding objects on the images.
  5. Consider the methods that can be used to find each of the objects. In the FlexiLayout, these methods will be described by means of element properties. Start with the most reliable objects, i.e. those which are present on most of the images and which do not occur too often on the same image. Later they can be used as starting points, or reference elements, to look for less reliable elements.
    Be sure to select the strictest search criteria, so that the program formulates the most reliable hypothesis. To prevent an uncontrollable growth of the tree of hypotheses, we do not recommend changing the default value in the Number of surviving hypotheses field.
  6. Consider grouping some of the elements into Group elements. Group elements are convenient for testing parts of the FlexiLayout which are independent of one another. For example, a FlexiLayout made up of a total of 100 elements, may include only 3 Group elements at the highest level - the title, the body, and the bottom of the form. Each of the three Group elements may be made up of Group elements which describe smaller portions of the document. Such nesting of Group elements reduces the number of possible search combinations and makes debugging the FlexiLayout easier, as you can work with each part of the FlexiLayout independently.


Elements

An element describes one or more image objects, such as separators, static text, pictures, etc. An element contains information about the type of the object, its geometrical features, its likely location, and relationships with other objects. The program uses the properties of an element to look for the object it describes and determines a region for the object. A region is made up of one or more rectangles enclosing the object. Next the program uses the detected to objects to locate blocks.

Elements fall into simple (Static Text, Separator, White Gap, Barcode, Character String, Text Fragment, Object Collection, Date, Phone, Currency, Region), which do not contain any other elements, and compound (Group, Repeating Group, Labeled Field, Header, Footer). You can convert elements of one type into elements of another type but you cannot convert compound elements into simple elements or vice versa. A Table element is neither simple nor compound and cannot be converted into an element of any other type. To convert an element, select the Convert To command on its shortcut menu.

An element may be displayed differently depending on its properties:

  • disabled elements are shown in gray
  • required elements are marked with green checks
  • prohibited elements are marked with red checks

Elements are joined together to form layout alternatives. In the project tree, each layout alternative is marked with [image].

More

Creating and deleting elements

An overview of element properties

Search area

Additional Search Constraints


Creating, copying, and deleting elements

To create an element:

  1. Activate the FlexiLayout window.
  2. Go down the FlexiLayout tree to the nesting level where you wish to create an element (SearchElements is the first nesting level).
  3. Select the type of the element in FlexiLayout>Add Elements>[Type].
  4. Specify the element’s properties, search area, and additional search constraints if required. For a detailed description of each element and its properties, consult the corresponding section of this help file.
    Important! The name of an element may contain letters (Roman characters, Roman characters with diacritics, Cyrillic characters), digits, and underscores. The name of an element must start with a letter or an underscore. The name of an element must not contain spaces or any the following special symbols: '.', ',', ':', '-', '\', '/'.

When viewing pre-recognition results, you can quickly create elements based on the current image. The following methods are available.

  1. Point the mouse to a recognized object and double-click it. A Select Element Type dialog box appears.
  2. Select the desired element type and click OK to confirm.

Alternatively:

  1. On the toolbar, click [image] to activate the element creation mode.
  2. Point the mouse to a corner of the rectangle from which the new element is to be created.
  3. Holding down the left mouse button, drag the mouse pointer diagonally to the opposite corner. A rectangle will be displayed from which the new element is to be created.
  4. Release the mouse. A Select Element Type dialog box appears.
  5. Select the desired element type and click OK to confirm.

Tip: You can move the created element to another level in the FlexiLayout tree using the drag-and-drop function. Note, however, that if the FlexiLayout tree contains elements or blocks which refer to the moved element, you will need to adjust the corresponding properties of the elements and blocks concerned. FlexiLayout Studio will automatically highlight the elements affected by such move.

Note: Once you have created a Group element, you need to add simple or Group elements into it. To add elements into a Group element:

  • Drag and drop the element you wish to add, or
  • Click the Group element in question and create new elements of the required types within this element.

The following methods can be used to copy an element:

  • Select the desired element in the branch. Hold down the Ctrl key and use the mouse to drag the element to the desired location in the tree of elements.
  • Select the desired element in the branch. Use the Copy and Paste commands on the Edit menu or the same commands on the shortcut menu.
  • Select the desired element in the branch. Use the Copy and Paste buttons on the toolbar.

You can copy any existing element, including Group elements. You may have to edit the properties of the copy, but it is still faster than creating several similar elements from scratch. The name of the copy is built from the name of the original elements and the number of the copy.

To delete an element:

  1. In the FlexiLayout tree, Right-click the element you wish to removed.
  2. Select Delete from the shortcut menu.

More

An overview of element properties

Search area

Additional search constraints


An overview of element properties

Element properties are specified in the Properties dialog box. To open the Properties dialog box, right-click the element in the FlexiLayout window and select Properties… from the shortcut menu. All element properties, with the exception of Name and Comment, serve to describe the parameters and search areas of image objects. Element properties can be classified into the following groups:

General properties
These properties do not depend on the type of element and are specified on the General tab:

Name - The name of an element. The name of an element may contain letters (Roman characters, Roman characters with diacritics, Cyrillic characters), digits, and underscores. The name of an element must start with a letter or an underscore. The name of an element must not contain spaces or any of the following special symbols: '.', ',', ':', '-', '\', '/'. The name of an element may not coincide with any of the reserved words or FlexiLayout language predefined types.

Type - The type is specified when you create a new element. You can create elements of the following types: Static Text, Separator, White Gap, Barcode, Character String, Text Fragment, Object Collection, Date, Phone, Currency, Table, Region. A FlexiLayout may include compound elements: Group, Repeating Group, and Labeled Field.

Comment - A comment or description of an element provided by the user.

Element occurrence - specifies whether the element is required, optional, or prohibited. For details, see the Required, optional, and prohibited elements section.

Null hypothesis quality - the quality of the null hypothesis (this property is available ifOptional element is selected in the Search Control section). The default value is 0.97.

Number of surviving hypotheses - The user can use this parameter to limit the number of hypotheses which the program may use when looking for the subsequent element. By default, this parameter is set to 5 for simple elements, and to 1 for Group elements.

Min number of found subelements - the minimum number of detected subelements to consider the element detected. This property is avilable only for compound elements (i.e. Group, Header, Footer, and Repeating Group).

Properties that describe the geometrical features of an object
These properties are specified on the tab which names the type of the element. Each type of element has its own set of geometrical properties. For details, see the section of this help file where the corresponding element is described.

Properties that describe the search area
These properties do not depend on the type of element and are specified on the Search Constraints and Relations tabs.

Properties that define the search area of an object relative to other elements
These properties are independent of the element type and are specified on the Relations tab.

Properties that describe additional search constraints

These properties are specified on the Advanced tab and are checked during and after the search See Additional search constraints for details.

Element fields
An element field is a typed variable that belongs to an element. Element fields are defined ion the Advanced tab. For more about element fields, refer to the Element fields section.

Tip
The properties of each element are displayed in the Properties dialog box and in the Properties window when you click the element in the FlexiLayout tree. You can edit the properties of an element in the Properties dialog box. Once you have matched the FlexiLayout with the images (Match command), double-click the desired element in the Tree of Hypotheses to view its properties.

ABBYY FlexiLayout Studio can display several Properties dialog boxes at a time. You can copy the properties of one element to another element, provided the element may have such properties (e.g. you will not be able to copy a Max width property into a Static Text element). You can also copy a value of an object displayed in its Properties dialog box and paste it into the Properties dialog box of an element.

More

Required, optional, and prohibited elements

Search area

Additional search constraints


Required, optional, and prohibited elements

A distinguishing feature of semi-structured documents is that sets of fields may vary from one document to another. For this reason, when creating an element, one must bear in mind that the objects(s) described by the element may be absent on some of the image and therefore will not be detected. Additionally, image information may be lost if incorrect scanning results in dark or bright patches on an image. In this case the objects located in such patches will not be detected either. FlexiLayout Studio can go on searching for elements even if a particular element has not been detected. To allow FlexiLayout Studio to continue matching the FlexiLayout even if a particular object has not been detected, you need to mark this object as optional.

Objects described by required elements must always be present on the images and the program must find then when matching the FlexiLayout with images. If the object is not detected, FlexiLayout Studio stops matching the FlexiLayout.

Use required elements to find identifier objects. An identifier object prevents matching the FlexiLayout with a form that belongs to a different type not described by the current FlexiLayout. You can also use required elements to describe objects whose absence means that any further search would be useless.

In all other cases, use optional elements to describe image objects.

Objects described by such elements need not be present on the image or the program may not detect them when matching the FlexiLayout. The matching will still continue and the program will detect the objects described by other elements.

By default, all simple elements are optional.

Note: Unlike simple elements, all Group elements are required by default.

The presence of a certain element in a chain of hypotheses may mean that the chain is not correct and should be discarded. These elements are termed prohibited elements. When the program hits on a prohibited element, it stops generating hypotheses in the branch where the prohibited element has been encountered.

Thus, elements may be used to identify a document (required elements), to detect blocks (required and optional elements), and to discard incorrect hypotheses (prohibited elements). Prohibited elements may be used, for example, to prevent false FlexiLayout matching.

You can specify how an element should be used it its Properties dialog box (General tab).

Required and prohibited elements are indicated as follows:

  • required element are marked with green checks:
  • prohibited elements are marked with red checks:


Static Text

Static Text is an element of a FlexiLayout which describes some pre-defined text. The text may consist of a word or of a phrase. Phrases are different from words in that they contain at least one space. A phrase may be written in several lines.

Static Text elements are marked with [image] in the FlexiLayout tree.

The program uses Static Text elements to search for static text, i.e. for text which is known in advance. The program will consider Recognized Words and Recognized Lines objects detected during pre-recognition and located in the element’s search area as static text candidates.

Usually all or many images in the batch include static text. This may be the heading of the document (e.g. Invoice) or the names of fields (e.g. Date, to:, From:). Such objects are detected as Recognized Words during pre-recognition are usually used as "signposts" when looking for any text which may be entered in their corresponding fields: for example, it is natural to expect a date next to the static text "Date".

The properties of a Static Text element

Click the Search text from file tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

Search text - the text to find on the image.

If you need to find a phrase or several words and you know that they will always be located on the same line, it is recommended to ignore spaces (i.e. leave unchecked the option Take spaces into account), as this will speed up the search. In this case, you can type in your search phrase without spaces - the program will remove them anyway if the Take spaces into account option is not selected.

E.g.: to find the name 'Purchase Agreement' which is written in one line on all of the forms, you need to enter PURCHASEAGREEMENT.

Use a vertical line (the symbol '|') to separate variants.

E.g.: If similar forms may have such names as Contract or Agreement, you need to enter CONTRACT|AGREEMENT.

Variants of phrases are enclosed in curly braces and separated by a vertical line: { }|{ }. You can list variants of words within phrases (the Take spaces into account option must be selected).

E.g.: If you enter {SALE|PURCHASE AGREEMENT|CONTRACT}|{CUSTOMER|CLIENT APPLICATION} in the Search text field, the program will look for the following phrases: sale agreement, purchase agreement, sale contract, purchase contract, customer application, client application.

Tip: To enter long strings, click [image] which opens a separate data entry window.

Search text from database - You can search for a text fragment from a database on your image. An SQL query starting with the SELECT command is used to search for the relevant fields in the table. The program will search on the image for the text contained in the found field.

Enter the data base connection string in the Connection string fields or click [image] to open the standard database connection dialog box.

Type your query in the Query text field. You can also click [image] to open a separate data entry window where you can type in your query.

Search text from file - You can search for a text fragment from a file. Click the Browse… button to select the desired file.

For details about using databases and files, see Using databases and text files in the FlexiLayout language.

Max number of errors - the maximum number of errors in the word. The program will check each word in the phrase if the words in the phrase are separated by spaces. Otherwise the phrase will be considered to consist of only one word. If the number of errors in a word is higher than the number specified in this field, the word is considered not detected. One error corresponds to one delete, paste, or replace operation required to adjust the text so that it corresponds to the text typed in the Search text field.
By default, the value of this property is unlimited.

E.g.: Suppose the Search text field contains the word 'meet' and the maximum number of errors is set to 1. If the program finds the word 'moot' in this search area, there will be 2 errors in the word and the word 'meet' will be considered not found.

Max error percentage - the maximum percentage of errors in the word (calculated as the ratio of the number of errors in the hypotheses to the number of letters in the hypothesis). If the percentage of errors in a word is higher than the percentage specified in this field, the word is considered not detected.
The default value is 30%.

Note: If you specify both the maximum number of errors and the maximum percentage of errors, the program will use the more strict criterion and ignore the other.

Max space length - Allows you to specify the maximum length of the space inside the detected object.

Whole words only - Searches for whole words only.

Match case - Enables case-sensitive search (the program distinguishes between small and capital letters).

May include spaces - Allows spaces in the search string. If this option is not selected, spaces will be removed from the search string. Ignoring spaces makes the search faster. However, if your search phrase may be located on multiple lines or if some words in the phrase may be missing, you need to enable the Take spaces into account option and type in your search phrase preserving the spaces.

The following options are available only if Take spaces into account is selected:

Permit multiple lines - allows the phrase to be written in several lines.

Line break penalty - sets a penalty for line breaks words. The penalty is a number from 0 to 1. The quality of the hypothesis will be multiplied by this number as many times as there are line breaks in the phrase. If line breaks are allowed in the phrase, set this parameter to 1 (multiplying the quality of the hypothesis by 1 will not downgrade its quality).

Permit missing words - allows missing words in the phrase.

Missing word penalty - sets a penalty for missing words. The penalty is a number from 0 to 1. The quality of the hypothesis will be multiplied by this number as many times as there are missing words in the phrase. If some words may be absent in the phrase, set this parameter to 1 (multiplying the quality of the hypothesis by 1 will not downgrade its quality).

Recommendations on creating a Static Text element

Since static text is known in advance, a Static Text element can be used as a reference element to look for other image objects. Use the following guidelines:

  • to make sure that the selected static text can be reliably recognized on all of the images, view the pre-recognition results on all of the images by clicking [image] or [image] for words and phrases respectively. Make sure that the letters are correctly grouped into words and words are correctly grouped into lines.
  • It is best to select static text printed in larger letters which remains the same even on poor quality scans or in which the number of OCR errors is predictable.
  • If there is only small print static text on the forms which cannot be reliable recognized during pre-recognition (i.e. the number and types of errors are very different on different images), such text fragments are better described not as Static Text but as Object Collection with the Text and Punctuation mark options selected. (You may also need to select the Picture option - click [image] (Raw Objects) on the toolbar and select the corresponding object on the image. The type of the object will be displayed in the DataType line in the Properties window.)
  • It is preferable to select unique static text fragments so as to prevent wrong hits and to keep additional search constraints to a minimum.
  • If there are both single-word names (which you plan to find by means of Static Text elements) and phrase names which contain the same words as single-word names, first create elements for the phrases. This will prevent the program from wrongly detecting single-word names within phrase names.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Separator

Separator is an element of a FlexiLayout which describes a vertical or horizontal separator.

Separator elements are marked with [image] in the FlexiLayout tree.

Separator elements are used to look for separators. The program will consider as candidates the Separator objects detected during pre-recognition which either fit entirely within the search area of the element or overlap the search area.

The properties of a Separator element

Click the Separator tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

Orientation - sets the orientation of the separator (vertical or horizontal).

Min length sets the minimum length of a separator. Measured in the user-defined units of measurement. Objects of smaller lengths will be ignored. You can estimate the length of a separator by clicking the corresponding object on the image and viewing its properties in the Properties window.

Max length sets the maximum length of the separator. Measured in the user-defined units of measurement. Objects of greater lengths will be ignored.

Min relative length sets the minimum relative length of a separator. This is a number from 0 to 100. The relative length of a separator is calculated as [length o the separator]/[length of the search area along the separator]. Objects of smaller relative lengths will be ignored.

Note: If you specify both Min length and Min relative length (%), the program will use the more strict criterion and ignore the other.

E.g. Suppose that Min length=300 (i.e. 1 in or 2.54 cm) and Min relative length=30%. If the width of the search area is 21.0 cm (i.e. the width of an A4 sheet), the program will look for separators longer than 6.3 cm.

Penalty limit for length - The minimum coefficient by which the hypothesis quality may be multiplied as a penalty for its length. When estimating quality, a hypothesis may be penalized for the length of the separator: the longer the separator object, the higher the quality of the hypothesis. The highest quality of 1 is assigned to a separator whose length is the same as the search area. When the relative length of the separator decreases from 1 to 0, the quality of the hypothesis decreases in direct proportion from 1 to Penalty limit for length.

Relative length = L/L0
[Quality] = ( 1 – [Min penalty for length] ) * [Relative length] + [Penalty limit for length].

(The quality changes linearly from 1 for a relative length of 1 to [Min penalty for length] for a relative length of 0.)

Fits entirely within search area - specifies that the separator must fit entirely within its search area. Uncheck this option to find separators which overlap the search area as in the figure below.

Space group

Sometimes the image of a separator may be distorted due to poor printing or scanning. Separators may be torn apart, skewed, or turn into thin parallel lines. This may cause the program to detect more than one separator during pre-recognition (see the figure below).

The properties in the Space group can be used to specify the conditions under which several separators must be merged into one.

Max length - the maximum length of the gap between two parts of a separator torn apart. If the gap is smaller than the number in this field the two lines will be merged into one.

Max relative length (%) - the maximum relative length of the gap between two parts of a separator torn apart. If the gap is smaller than the number in this field the two lines will be merged into one. The relative length of a gap is calculated as [gap length]/[separator length].

Note: If you specify both Max length and Max relative length (%), the program will use the more strict criterion and ignore the other.

Orthogonal shift - the maximum shift between separator lines measured at the right angle to the separator. If the shift is smaller than the number specified in this field, two parallel lines will be merged into one.

Recommendations on creating a Separator element

If you are planning to use separators as reference elements, make sure that they are reliably detected during pre-recognition. To do this, click [image] on the toolbar to view the separators detected by the program. Then, examine all the test images, making sue that the corresponding object is highlighted as separator. This is particularly important when separators are very thin and their detection largely depends on the quality of the scanned images.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


White Gap

White Gap is an element of a FlexiLayout which describes a rectangular area on the image which contains almost no objects of the specified type.

To look for White Gaps, the program creates histograms for objects. When creating histograms fro the objects in the search area, the program calculates the sum of the projections of all the objects on the horizontal axis (to look for a vertical gap) or on the vertical axis (to look for a horizontal gap). If the sum of the projections is smaller than the specified threshold, the program considers the area to be a White Gap.

Building a histogram for a vertical gap

For more about histograms, see White Gap hypotheses.

The search area may contain accidental objects. The maximum allowed number of such objects is specified in the properties of the element.

White Gap elements are marked with [image] in the FlexiLayout tree.

The properties of a White Gap element

Click the White Gap tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

Orientation sets the orientation of a White Gap.

Vertical White Gaps have top and bottom boundaries coinciding with the top and bottom boundaries of the search area. The left and right boundaries must be detected. An example of a vertical White Gap is the space between two text columns.
Horizontal White Gaps have left and right boundaries coinciding with the left and right boundaries of the search area. The top and bottom boundaries must be detected. An example of a horizontal White Gap is the space between two paragraphs of text.

Min width/height sets the minimum width/height of a White Gap in the direction perpendicular to Orientation. Gaps of smaller width/height will be ignored. Measured in the user-defined units of measurement. The default value is 20dot.

The Search among objects of type property sets the type of objects among which to look for the White Gap. Select the desired objects by checking the boxes next to them.

The properties of the histograms of objects which may occur in the search area

Lower threshold limit sets the minimum level of the histogram. This property allows other objects in the search area. If the height of the histogram of the objects is greater than the number specified in this field, the program will consider the search area to contain no gaps. Measured in the user-defined units of measurement. The default value is 37dot.

Upper threshold limit sets the maximum level of the histogram. This property allows excluding false histogram maximums which may be caused by large numbers of vertically arranged accidental objects in the search area when looking for a vertical gap or horizontally arranged objects when looking for a horizontal gap. Measured in the user-defined units of measurement. The default value is 150dot.

Threshold coefficient (%) sets the maximum relative level of the histogram. The relative level of the histogram is calculated as [level of histogram]/[histogram maximum in search area]. The default value is 20.

Note:

  1. The values of Lower threshold limit, Upper threshold limit and Threshold coefficient (%) can only be selected by trial and error. We recommend starting with the default values. If the results are unsatisfactory, try finding the values enabling the program to detect the White Gap on all of the test images.

  2. If the value of the Threshold coefficient (%) is smaller than the value of the Lower threshold limit, the Lower threshold limit will be used. If the Threshold coefficient (%) is greater than the Upper threshold limit, the Upper threshold limit (i.e. the program will use the most strict criterion).

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints

White Gap hypotheses


Barcode

Barcode is an element of a FlexiLayout which describes barcodes used to encode various information in a series of black and white lines.

Barcode elements are marked with [image] in the FlexiLayout tree.

Barcode elements are used for finding barcodes of the types supported by ABBYY FlexiLayout™ Studio. The program will consider Barcode objects detected during pre-recognition in the search area.

The properties of a Barcode element

Click the Barcode tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

Barcode type - the type of barcode.

Orientation sets the orientation of a barcode:

  • Left-to-Right,
  • Bottom-to-Top,
  • Right-to-Left,
  • Top-to-Bottom.

Note: You can select more than one option.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Character String

Character String is an element of a FlexiLayout which describes a string of characters written in one line from left to right. Character strings may consist of words or parts of words.

Character String elements are marked with [image] in the FlexiLayout tree.

Character String elements are used to look for unspecified text. The program will consider as candidates the Recognized Words objects detected during pre-recognition in the element’s search area.

Usually, character strings are located next to static text. When looking for the Ref. No. of a document, for example, the program must first find the static text "Ref. No." and then look for digits next to it.

Describing the search text

Click the Character String tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

The text to find can be described in one of two ways.

Describing search text by means of a regular expression

A regular expression defines possible combinations of characters. If you use a regular expression, the hypothesis must meets its conditions. This method is usually used on good quality documents which are recognized without errors.

To enter a regular expression, select the Regular expression option and enter the expression in the field next to it. You can also click the [image] button, which opens a drop-down list of options (Any Letter, Character from Set, etc.). Select the desired option to enter the corresponding regular expression into the field.

Regular expression alphabet
Name in the list | Symbol in the field | Example
Any character | * | "k"*"t" – allows 'kit', 'kat', etc.
Letter | C | C"at" – allows cat, bat, Rat, mat, etc.
Upper case letter | A | A"at" – allows Cat, Bat, Rat, Mat, etc..
Lower case letter | a | a"at" – allows car, bat, rat, mat, etc.
Letter or digit | Х | X – allows any single letter or digit.
Digit | N | N"th" allows 5th, 4th, 6th, etc.
String | "" | "cat"
Or | | | "dr"("i"|"u")"nk" – allows "drink" or "drunk".
Character from the set | [] | [hm]"at" – allows 'hat' or 'mat'.
Character not from the set | [^] | [^b]"at" – allows 'cat', 'mat', 'rat', but does not allow bat.
Any number of repeats (applies to the expression or sub-expression to the left) | {-} | [AB74]{-} – allows any combination of A, B, 7, 4 of any length.
Number of repeats is n | {n} | N{2}"th" allows 25th, 84th, 11th, etc.
n to m repeats | {n-m} | N{1-3}"th" allows 5th, 84th, 111th, etc.
0 to n repeats | {-n} | N{-2}"th" allows th, 84th, 4th, etc.
n or more repeats | {n-} | N{2-}"th" allows 25th, 834th, 311th, 34576th, etc.
Subexpression | () |

Describing search text by means of an alphabet

An alphabet lists characters that may occur in the search text. This methods is used whenever the character string cannot be described by means of a regular expression or there are too many errors in the recognized text as a result of poor image quality. You can specify several alphabets for a Character String element. If the format of the text is unknown, no alphabets are specified. In this case the program will consider all possible characters when looking for the object corresponding to the element.

To describe search text by means of an alphabet:

  1. Select a hypotheses generation mode. To use the characters in the search area to generate all the possible hypotheses, including intersecting and embedded hypotheses, select Allow embedded hypotheses. To generate hypotheses of maximum length, clear Allow embedded hypotheses.

  2. Create one or more alphabets.

    More about creating, editing, and deleting alphabets
    To create an alphabet:

    1. Click Add….

    2. In the Add New Alphabet dialog box, select the required code page from the Code page list,

    3. In the Character map, select the characters which occur in the search text. The selected characters and their number are displayed in the Selected on screen/selected in all field.

    4. In the Percentage of alphabet characters field, specify the required percentage of alphabet characters in the search text.

    Note:
    You may specify several alphabets, but they must not overlap, i.e. include the same characters.

    To delete an alphabet, select it in the Alphabets list and click Delete.

    To add or delete alphabet characters, select the required alphabet in the Alphabets list and then click Edit….

  3. In the Percentage of non-alphabet characters field, specify the allowed percentage of characters which do not belong to any of the alphabets.

Depending on the method used to describe the search text, you may need to specify the following properties:

  1. Select Whole words only if you wish to find whole words only.

  2. Use the Detect words by interword space option to specify how lines should be divided into words. Disable this option to detect words automatically. Enabling this option will divide a line into words whenever the space between neighboring characters is greater than or equal to the value entered in Min interword space.

    Note: In the case of automatic word detection, word ends are detected based on spaces or other symbols that separate words (e.g. ",", ";", "/", "?" - the exact set of symbols depends on the selected pre-recognition language), or based on other attributes. To make sure that the program correctly divides lines into words, review the text objects on the test images (Image>Show Image Objects> Recognized Words).

  3. In the Word count fields, specify the number of words in the character string. The number of words is specified by means of a fuzzy interval. The default interval is {-1,-1,INF,INF} (i.e. the program looks for hypotheses containing any number of words).

  4. In the Max space length field, specify the maximum length of the space inside the object. Measured in the user-defined units of measurement. You can estimates the length of the space by looking at the coordinates of the neighboring objects. Rest the mouse cursor on a neighboring objects to display its coordinates in the status bar. When looking for a text, characters will be added to the character string until the distance between neighboring elements exceeds Max space length.

  5. In the Character count field, specify the length of the character string (i.e. the number of characters in the string). The number of characters is specified by means of a fuzzy interval and assesses the quality of the hypothesis based on its length.

    Use the [image] button to specify fuzzy intervals in a separate window that visualizes fuzzy intervals for your convenience.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Text Fragment

Text Fragment is an element that describes a paragraph. When searching for the paragraph, the program will consider all text objects wholly or partially contained within the search area.

A Text Fragment element is marked with [image] in the tree of elements.

This element is used to search for text paragraphs whose text is unknown. The program will consider the Recognized Words and Recognized Lines objects detected by pre-recognition and falling within the element's search area.

The properties of a Text Fragment element

The properties of a Text Fragment element are specified on the Text Fragment tab of the element's Properties dialog box. To open the element's Properties dialog box, in the FlexiLayout window, right-click the element and select Properties… from the shortcut menu.

Line count specifies the number of lines in the paragraph (a fuzzy interval is used)

Fragment width specifies the width of the paragraph in characters (a fuzzy interval is used)

Min font height specifies the minimum height of the characters (font size) in user-defined units of measurement

Max font height specifies the maximum height of the characters in user-defined units of measurement

Max line length variation (%) specifies the maximum variation in the length of the lines; calculated as the difference in length between the longest line and the shortest line divided by the length of the longest line

Max line height variation (%) specifies the maximum variation in the height of the lines; calculated as the difference in height between the tallest line and the smallest line divided by the height of the tallest line

Min horizontal line overlap (%) specifies the minimum horizontal overlap of the neighboring lines; calculated as the length of the common segment of the lines divided by the length of the shortest line

Max space length in line specifies, in user-defined units of measurement, the maximum allowed absolute length of the space inside the detected object; when searching for the text, characters are added to the string until the distance between the neighboring characters becomes greater than the value in Max space length in line.

Max interline space specifies the maximum distance between the lines in user-defined units of measurement.

Max relative interline space specifies the maximum distance between the two lines relative to the height of the top line; if the distance between the lines is greater than this value, the second line does not make it into the hypothesis

Whole words only specifies whether the hypothesis should include the parts of the words which are partially contained within the search area; enable this option if you need to exclude word fragments from the hypothesis

Ignore separators specifies whether separators should be ignored when searching for the paragraph; disable this option if the paragraphs are marked off by separators

Remove stamp. When recognizing payment documents, stamps placed over text may pose a problem. Typically, a stamp is placed in the bottom right corner of the text. The text fragment with a superimposed stamp is practically illegible and is recognized by the program as bits of phrases which make no sense. To avoid this, do not include the stamped text fragment into the block and key in the text manually from the image (and you won't have to remove the incorrectly recognized text). If Remove stamp is enabled, the program will analyze the bottom right corner of the search area and remove any bits of text that may have been caused by a superimposed stamp.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Object Collection

Object Collection is an element of a FlexiLayout which is used to look for sets of objects of different types each of which meets the search criteria.

Object Collection elements are marked with [image] in the FlexiLayout tree.

Object Collection elements are usually used to look for objects which cannot be found using other elements. For example, you can use an Object Collection element to look for punctuation marks which stand apart and are not marked as text objects. You can also use this element to look for non-text objects, e.g. pictures and check marks.

The properties of an Object Collection element

Click the Object Collection tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

Type specifies the type of the objects to search: Text, Punctuation mark, Picture, Inverted text, Checkmark, Separator, Barcode. When matching the FlexiLayout with the images, only the objects of the specified types will be detected. All other objects will be ignored.

Object size sets the minimum and maximum widths and lengths of the objects in the user-defined units of measurement. To be able select the values for these properties, first look at the sizes of the objects in the Properties window.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Date

Date is an element of a FlexiLayout which describes a date.

Date elements are marked with [image] in the FlexiLayout tree.

Dates may be in many formats, but the day and year must always be designated by numbers, whereas the month may be written either in figures or as a word. The format is selected by the user.

The properties of a Date element

Click the Date tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

Format group

Date - date format:

  • Day, month, year,
  • Month, day, year,
  • Year, day, month,
  • Year, month, day.

Note: You can select more than one option.

Day - sets the number of digits in the day field.

E.g. If Allow single digit is selected, the program will find both 1.09.2005 and 01.09.2005.

If Two digits only is selected, the program will only find 01.09.2005.

Month - sets the number of digits in the month field.
E.g. If Allow single digit is selected, the program will find both 1.9.2005 and 01.09.2005.

If Two digits only is selected, the program will only find 1.09.2005.

If Word is selected, the month can be spelled out as a word.
Note: If you select this option, you need to specify the language in which the name of the month will be written.

Year - sets the number of digits in the year field.

E.g. If Two digits is selected, the program will only find dates where the year is indicated by two digits: 01.09.95.

If Four digits is selected, the program will only find dates where the year is indicated by four digits: 01.09.1995.

If both options are selected, the program will find both 01.09.95. and 01.09.1995.

Date interval - specifies a time period: from... to ...

E.g. If the from contains 01.09.1995 and the to contains 1.09.2005, the date 9.05.1945 will be ignored during search.

Language - the language in which the name of the month is written. Possible choices: English, Russian.
Note: This property is only available if the Word option is selected for the Month property.

Separators - Day, month and year may be separated by different symbols. This property allows you to specify possible date separators. When specifying more than one symbol, do not separate them by commas or spaces. A space may also be used as a date separator, but you need not specify it as a separator - the program will still detect such date.

E.g. .,/

In the Max space length field, enter the maximum allowed absolute length of the space inside the detected object. The space length is measured in the user-defined units of measurement. When looking for the text, the program will add characters to the string until the distance between the neighboring character reaches the value in the Max space length field.

Recommendations on creating a Date element

When matching the FlexiLayout, the program carries out a 'strict' search for dates, i.e. dates may not contain errors or excess characters. This means that dates can be found only on good quality images. Cases where the name of the month is spelled out as a word are an exception. Then 20% of errors is allowed.

Tip: If the name of the month is written neither in English nor in Russian, you can create the following three elements to find such dates:

In a Static Text element, specify the names of all the months, separating them by '|' in the Search Text property. Be sure to enter all the possible grammatical forms.

In two Character String elements, specify digits as an alphabet, and the areas to the right and to the left of the month specify as search areas. As an additional search constraint, specify that the program must look for Character String elements only if its has already found the Static Text, element corresponding to the name of the month.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Group elements

Group is a collection of several elements (termed subelements). Subelements, in turn, can be Group elements.

Group elements are marked with [image] in the FlexiLayout tree.

Note: Group elements also include: Header, Footer, and Repeating Group. Use Header and Footer elements to detect the beginning and the end of a document. Header and Footer elements may each occur in a document only once. Repeating Group is a recurring Group element. A Labeled Field element may also be represented as a compound element.

If required, you can specify the minimum number of subelements to be detected. If applying the FlexiLayout detects fewer elements, the compound element will be deemed not detected.

A Group element, just like a simple element, can be required, optional, or prohibited. If an optional Group element includes a required element, the failure to match this element with an object will result in a null hypothesis for the Group element and the program will continue trying to match the FlexiLayout.

Be sure not to keep empty compound elements (i.e. compound elements without any subelements). If the program encounters an empty compound element when compiling a FlexiLayout, it will display a warning message. If you FlexiLayout makes no use of the compound Header and Footer elements, which are added by default, delete these redundant elements.

Group elements are useful in the following cases:

  • to make testing independent parts of a FlexiLayout easier. For example, a FlexiLayout made up of 100 elements may include only 3 Group elements - the title, the body, and the bottom of the form. Each of the three Group elements will contain Group elements describing smaller portions of the form. This approach both limits the number of possible variants to consider and makes debugging the FlexiLayout easier, as each group can be edited and tested independently.
  • to make navigation in the FlexiLayout tree easier.
  • to reduce the number of possible element hypotheses, thereby speeding up the formulation of the final hypothesis. Grouping elements together allows the program to consider a set of elements as one whole, for which a single hypothesis has been formulated (albeit consisting of the hypotheses for subelements) and for which the quality can be calculated. Considering various combinations of subelement hypothesis goes inside the group and only a set number of the best group hypotheses are used in the search down the tree. The default number of best hypotheses for a Group element is 1.
    Note: We do not recommend increasing the maximum number of hypotheses, as this may lead to an uncontrollable growth of the tree and failure to match the FlexiLayout with the images.
  • A Group element allows you to specify a search constraint common to all of the subelements. The search area for a particular element will be calculated as an intersection of the search area specified in the subelement and the search area of the entire group.
    Note: Sometimes, the intersection of the search area of a Group element and one of its subelements may be empty, and the program will fail to find the subelement. Try to specify only simpler relations for Group elements, e.g. "Above: PageRect.Top + PageRect.Height/2;" (i.e. "look for the element in the upper half of the image"), or not specify any relations at all.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Phone

A Phone element describes a telephone number, which is often preceded by the words Tel., Phone, etc. and an area or city code in brackets (see the figure below). The words Tel., Phone etc. and the telephone number must be typed on the same line.

Phone elements are marked with the [image] icon in the FlexiLayout tree.

The properties of a Phone element

Click the Phone tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

You need to specify the following properties of a Phone element in order to describe a phone number:

Prefixes for phone numbers - specify the possible words or phrases which may precede the phone number. 20% of errors are allowed in a prefix (i.e. one error for each 5 characters).

  • to add a prefix to the list, click Add… and in the Add Phone Prefix dialog box, type a new prefix;

  • to edit a prefix, click Edit… and in the Edit Phone Prefix dialog box, make the necessary changes;

  • to delete a prefix from the list, select the desired prefix and click Delete.

Missing prefix penalty - specifies a penalty coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied if the prefix is not found.

Possible digit separators - specifies symbols that can be used to separate digits in the phone number. A separator may consist only of one symbol. By default, the list of separators includes a space. When entering several separators, do not separate them by commas or spaces.

Minimum number of digits - specifies the minimum number of digits the phone number may contain. Hypotheses with fewer digits will be discarded.

Minimum number of digits - specifies the maximum number of digits the phone number may contain. Excess digits will be discarded.

Max space length - specifies the maximum allowed absolute length of the space inside the detected object. The space length is measured in the user-defined units of measurement. When looking for the text, the program will add characters to the string until the distance between the neighboring character reaches the value in the Max space length field.

Area code/city code brackets - allows brackets for city/area codes.

  • to add an opening and closing bracket, click Add… and in the Add Phone Code Brackets dialog box, type the opening bracket in the Opening symbol field and the closing bracket in the Closing symbol field;

  • to change the opening and closing brackets, click Edit… and in the Edit Phone Code Brackets dialog box, make the necessary changes in the Opening symbol and Closing symbol fields;

  • to delete brackets from the list, select the brackets and click Delete.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Currency

Currency is an element of a FlexiLayout which describes numerical values with a fractional part which has two digits or none at all. By default, the program allows the '-' symbol to be substituted for the fractional part, i.e. it will interpret 12.- as 12.00. The integer part of the number can be divided into orders. The default separators of the orders are .,' and a space. The number may have a prefix or a suffix - a text element preceding or following the number. The prefix must be located on the same line as the number. This format is typical for sums of money, where prefixes are the names of currencies.
Currency are marked with [image] in the FlexiLayout tree.

The properties of a Currency element

Click the Currency tab in the Properties dialog box to describe the corresponding object. To open the Properties dialog box, right-click the element in the FlexiLayout tree and select Properties… from the shortcut menu.

To find the numerical value of the sum, you need to specify the following properties of the Currency element:

Currency names - contains the list of possible currency names. The name of the currency may be a word or phrase or a symbol such as $ or ¥.

  • To add a currency name to the list, click the Add… button and in the Add Currency Name dialog box, enter the name of the currency;

  • To change a currency name, click Edit… and in the Edit Currency Name dialog box, make the necessary changes to the name of the currency;

  • To delete a currency, select it in the list and click Delete.

Missing name penalty - specifies a penalty coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied if the program fails to find the specified name of the currency.

Minimum value - sets the minimum value of the sum.

Maximum value - sets the maximum value of the sum.

Possible fractional part separators - the symbols that can be used to separate the integer and fractional part of the sum. A separator may consist of only one symbol. By default, the list of allowed separators includes ",", ".", and a space. When you enter separator symbols, do not separate them by commas or spaces.

Max space length - specifies the maximum allowed absolute length of the space inside the detected object. The space length is measured in the user-defined units of measurement. When looking for the text, the program will add characters to the string until the distance between the neighboring character reaches the value in the Max space length field.

Currency name position - the position of the currency symbol relative to the numerical value - Left of value or Right of value.

Allow missing fractional part - specifies whether the fractional part of the number is obligatory or not. If this option is selected, the program will find such numbers as '12.' and '12.-'.

Allow missing separator - specifies whether the fractional part separator is obligatory or not. If this option is selected, the program may find integers without separators.

See also

Creating and deleting elements

An overview of element properties

Search area

Additional search constraints


Table

Table is an element of a FlexiLayout used to detect tables of different structures, including tables specific to financial documents and any data arranged in a tabular form.

In the tree of elements, Table elements are marked with [image].

For more information on creating FlexiLayouts for documents with tables, see Working with Tables.

See also

An overview of element properties

Search area

Additional search constraints

Table element


Repeating Group

Repeating Group is an element used to detect repeating groups of elements (the number of repetitions may not be known in advance). A group may repeat either on one and the same page or on a multi-page sheet.

In the project tree, Repeating Group elements are marked with [image].

If a Group elements recurs within a document, you may describe its properties only once, and specify the number of possible repetitions rather than describe each group separately

Possible uses:

  • Searching for a running name on each page of a multi-page document.
  • Searching for repeating data, where the exact number of repeating instances is not known in advance (e.g. tables with complex rows).

A Repeating Group element is different from a Group element in that it has certain additional search constraints and a repetition parameter.

The properties of a Repeating Group element which define the parameters of the object to be detected

The properties that define the parameters of the object to be detected are specified on the Repeating Group tab of the element's Properties dialog box. To open the Properties dialog box, right-click the element in the FlexiLayout window and select Properties… on the shortcut menu.

There are two ways to search for instances of a repeating group - either in the entire document or on individual pages. Correspondingly, you specify the minimum and maximum number of group instances either for the entire document or for individual pages.

If a repeating group contains a required element, it serves as the identifier for matching the instance. For example, if you specify the name of a repeating group of fields as a required element, the program will create as many instances as the number of names it detects.

The quality of the null hypothesis is specified for one instance and not for the entire set of instances. This parameter also serves as a criterion for forming an instance: if the quality of the generated hypothesis is lower than the quality of the null hypothesis, no instance is formed.

To search for group instances in the entire document, select the Document mode option and specify the following:

  • Min repetitions - the minimum number of group instances in the document

  • Max repetitions - the maximum number of group instances in the document

If the possible number of group instances is not detected in the document, the Repeating Group is considered not detected. If the maximum number of instances is detected, the search stops. In this default search mode, a group instance (which, just like the usual Group element, consists of hypotheses for its subelements) may stretch over several pages of the document.

To search for group instances on individual pages, select the Page mode option. In this mode, each instance may occur only with one page of the document. You can use this mode to search for a running name, for example. In this mode, the search is carried out top to bottom, from the first possible page to the last one. The following search parameters are available in this mode:

  • Min repetitions on page – specifies the minimum number of instances per page. If the minimum number of instances is not detected on the current page, the Repeating Group is considered not detected.
  • Max repetitions on page – specifies the maximum number of instances per page. If a required number of instances is detected on the current page, the search stops on the current page and continues on the next one.

Location of instances

The following constraint is imposed on the instances of an element: no two instances may intersect. This is achieved by forcibly excluding (Exclude) the already detected instances. On the Relations tab, you can set constraints for the next instance based on already detected instances.

For example, you can tell the program that it must look for each next instance below the previous one. On the Relations tab, set the BELOW constraint for your Repeating Group:

Note: It recommended that you specify a Nearest relation for a subelement in the group, defining its position relative to the to edge of the page. Otherwise, the program will select the next instance of the group by applying the best quality criterion to all the instances in the search area (below the last detected instance). The program will look for the next instance below the current instance (whose quality is higher), which may cause the instances of poor quality located above the instance with higher quality not to be detected at all.

See also

Creating, copying, and deleting elements

An overview of element properties

Search area

Additional search constraints

Additional search constraints for a Repeating Group element


Labeled Field

Labeled Field is a compound element which is used to search for fields that have names. A Labeled Field element includes the following subelements:

  • Static Text, which contains the name of the field
  • White Gap, which describes the gap between the name and the data of the field
  • an element which described the content in the field; the type of this field depends on the type of content in field

Labeled Field elements are marked with [image] in the tree.

If required, a Labeled Field element may be represented as a group.

When searching for the name, the program will consider the Recognized Words and Recognized Lines objects detected by pre-recognition and falling within the element's search area. Once the name of the field is detected, the program searches for a field with the content as specified by the element.

Name properties

The name of the field is described by a Static Text element.

The properties of the name are specified on the Label tab of the element's Properties dialog box. To open the element's Properties dialog box, in the FlexiLayout window, right-click the element and select Properties… from the shortcut menu.

Position of a field relative to its name

The position of a filed relative to its name is specified on the Field Position tab.

Field position specifies the position of the field relative to its name (to the right, to the left, above, below).

Field alignment specifies the alignment of the field's search area relative to the name rectangle. The value here depends on the value of the Field position field:

  • if the field is positioned to the right or to the left of the name, its search area may be aligned by the top or bottom boundary, or it may be centered
  • if the field is positioned above or below the name, its search area may be aligned by the left or right boundary, or it may be centered

Search area width specifies the width of the search area (in user-defined units of measurement)

Search area height specifies the height of the search area (in user-defined units of measurement)

Min indent specifies the minimum space between the name and the field (in user-defined units of measurement)

Detect indent size - a flag that specifies whether a White Gap element should be used to detect the distance between the field and its name. If this option is cleared, the search area of the distance starts from the value specified in the Min indent field. Otherwise, starting from this distance, an auxiliary White Gap element is generated and the search area begins after this element.

Field search constraints

The search constraints for the field are specified on the Field Position tab.

Content type specifies the type of the field's content. Depending on the type of the field, the Field Position tab may include additional search constraints:

Fixed variants

This type coincides with type Static Text and has the same properties.

Number

This type has the following properties:

Minimum number of digits specifies the minimum number of digits

Maximum number of digits specifies the maximum number of digits

Max error percentage specifies the maximum percentage of errors

Allow separators specifies whether separators are allowed in numbers. The set of digits used in the search is supplemented with a set of separators with an allowed share of 30%.

Currency

This type has the property Currency names, which is completely identical to the property of the Currency type of the same name.

Phone

This type has the properties Min number of digits and Max number of digits, which are completely identical to the corresponding property of type Phone of the same names.

Regular expression

This type has the following properties:

Regular expression specifies the expression to be used as the search pattern. This property is completely identical to the property of type Character String of the same name.

Min length specifies the minimum length of the string

Max length specifies the maximum length of the string

More

Creating, copying, and deleting elements

An overview of element properties

Search area

Additional search constraints


Region

Region is an element in a FlexiLayout which defines an area on an image without imposing any restrictions on the data inside. The search area of an element may consist of several discontinuous regions. Region elements are marked with [image] in the tree.

This element is used to compute regions regardless of the objects they contain.

More

Creating, copying, and deleting elements
An overview of element properties
Search area
Additional search constraints


Header and Footer

The program uses Header and Footer elements to detect the beginning and the end of a document. These are Group elements and have all the properties of Group elements, but may occur in a FlexiLayout only once.

In the tree of elements, the Header element is marked with [image] and the Footer element is marked with [image]. The Header and Footer elements are located at the top of the tree.

To add a Header or Footer element, right-click in the FlexiLayout and select Header/Footer.

A Group element may be converted into a Header or Footer element by selecting the Header or Footer command on its shortcut menu. You can also convert a Header or Footer element into a common Group element by selecting Group on its shortcut menu.

To test the Header and Footer elements on a particular page, use the Test Header and Test Footer commands.

See also

Multi-page FlexiLayout

Using Header and Footer elements to detect the beginning and the end of a document


Search area

A search area is defined by a set of search constraints and relations. It tells the program where to look for the objects described by the elements.

Search areas are made up of one or more rectangles which need not have common boundaries, i.e. search areas may be discontinuous.

A search area may be defined by absolute search constraints, i.e. by coordinates, or by relative search constraints, i.e. by relations to other elements. When specifying relative search constraints, you can use any elements located above the described element in eth FlexiLayout tree (the image object corresponding to this element can only be found by using information about the already found objects described by the elements higher up in the tree).

Specifying the absolute coordinates of a search area

An absolute search area is defined on the Search Constraints tab of the element's Properties dialog box.

For multi-page documents, you can select a range of pages on which to search for an element. You can specify the absolute local coordinates of a search area in the Region property.

Excluding an element from the search area

The Exclude elements property allows you to exclude from the search area the region of the found hypothesis for an element. If no hypothesis of the excluded element is found, this constraint will not affect the search area of the element.
Note: An exception to this are cases where the user has specified additional constraints for some of the boundaries of the hypothesis for the excluded element in the Advanced pre-search relations pane. In this case, if the program fails to find the excluded element, it will cut out the rectangular search area of this element from the surrounding search area. See the Fuzzy rectangle section for details about internal rectangles.

Specifying a search area relative to another element

A relative search area is defined on the Relations tab of the element's Properties dialog box. To define a relative search area, specify a reference element relative to which the boundaries will be defined and specify the relations of types "right of," "left of," "above," and "below" (the Relations property). You can specify any number of search areas for any element. The boundaries of a search area may specified relative to different reference elements. If no relative search area has been specified, the program will look for the object everywhere on the image. Each of the search constraints specifies a half-plane. The intersection of the half-plane and the image produces a rectangular part of the search area. The intersection of all the search constraints with the image produces the search area of an element.

The boundaries of a search area can be specified more accurately by means of the Element boundary and Offset properties.

The Element boundary property specifies a boundary of a search area relative to the top, bottom, left or right boundary of an element. By default, this property is set to <whole>.

When calculating a relative search area, the program may fail to find the reference element specified in the Reference element property. Lets us consider how the program calculates a relative search area both when the relative element has been found and when the relative element has not been found. If the reference element is optional and there are no objects on the image meeting the conditions specified in the element, the program will formulate a null hypothesis. The region of the null hypothesis for the reference element will coincide with the rectangle enclosing the search area of the element. If the reference element has been found, the region of the hypothesis will be built from the regions of the detected objects participating in the hypothesis and will be located inside the search area of the element.

If the reference element has been found, and the Element boundary is set to <whole>, a Right of constraint will mean "to the right of the right boundary of the reference element", a Left of constraint will mean "to the left of the left boundary of the reference element", etc. (i.e. To the right of, to the left of, below or above the <whole> hypothesis). If no hypothesis for the reference element has been formulated, this means that it could be located anywhere in the search area of the reference element ( but could not be located outside the search area). Thus, a Right of constraint, when applied to a non-found hypothesis, means "to the right of any area where the hypotheses for the reference element could be located". Mathematically, this means "to the right of the left boundary of the search area of the reference element". Similarly, a Left of constraint, when applied to a non-found hypothesis, will mean "to the left of the right boundary of the search area of the reference element", a Below constraint will mean "below the top boundary of the search area of the reference element", and an Above constraint will mean "above the bottom boundary of the search area of the reference element".

If the Element boundary property is set to one of the specific values - "left", "top", "right" or "bottom" - the search area will be calculated relative to the specified boundary of the hypothesis for the reference element, no matter whether the hypothesis has been found or not. For example, in the case of a non-found hypothesis a Right of constraint coupled with the Element boundary set to "right" will mean "to the right of the right boundary of the search area of the reference element".

The Offset property shifts a boundary of the search area by a certain distance. A positive Offset value means that that the boundary will be moved in the same direction as specified in the Relation property. A negative Offset value moves the boundary in the direction opposite to the direction specified in the Relation property.

E.g.
A FlexiLayout contains a YourPlanetName element of type Static Text which enables the program to find the YOUR PLANET NAME: field name on the image. We need to find text entered by the user in this field (in this case "MARS (satellite Phobos)"). Create a Planet element of type Character String and specify a search area located to the right of the Planet element, i.e. set the Element boundary property to Right of. The location of the search area is shown in the figure below:

Move the boundary of the search area to the right, i.e. in the same direction as specified in the Right of relation. To do this, select a positive Offset value, e.g. 200. The new location of the boundary is shown in the figure below:

Now move the boundary of the search area to the left, i.e. in the direction opposite the direction specified in the Rightof relation. To do this, select a negative Offset value, e.g. -200. he new location of the boundary is shown in the figure below:

Selecting the element located closest to a certain object

The Nearest property tells the program that, all other things being equal, it must look for a hypothesis located closest to certain element or point on the image. Specify the closest element, point, or coordinate axis in the Nearest property of the element.

Viewing a search area

Each property of an element translates into a search constraint. When matching a FlexiLayout, the program first calculates the search area of the element by using all of the specified constraints. Next, the program checks if the image objects located in the search area have the same properties as the elements. If a wrong object has been found as a result of matching the FlexiLayout, you can find out why this happened by looking at the search area of the element.

To display the search area of an element:

  1. Match the FlexiLayout with an image.
  2. Right-click the hypothesis corresponding to the element and select the Show Search Area command from the shortcut menu. The search area will be displayed in the Image window.

More

Specifying the absolute search area

Specifying the search area relative to another element

Using instances of a Repeating Group as reference or excluded elements

Additional search constraints


Search constraints

Search areas are specified on the Search Constraints tab in the Properties dialog box which is displayed whenever you create a new element.

To open the Properties dialog box of an existing element:

  • right-click the element in the FlexiLayout tree and select the Properties… command from the shortcut menu, or
  • double-click the element in the FlexiLayout tree.

Specifying the absolute coordinates of a search area

For a multi-page document, you can specify the pages on which to search for an element. Select an item form the Pages drop-down list: All, Even, Odd, Last or Range. If you select Range, enter the numbers of the desired pages separating them with commas and/or specify a page range using a hyphen: 2, 4, 6-8, 15.

You can define the absolute coordinates of a search area in the Region property. Enter the coordinates in the following format: [left, top, right, bottom]. You can specify the coordinates of several rectangles in this field. Keep the <whole page> option to search for the element in the entire area of the pages from the range. Use the Measure tool to determine the absolute coordinates of objects.

Once you have specified the properties of the search area, click Add. The search area will appear in the Search areas list. To edit a search area, enter the desired values in the Pages list or in the Region field and click Replace. If the Region field is empty, the program will search for the element in the entire search area of the pages from the specified range, as if you specified <whole page> for the field.

Excluding an element from the search area

The Exclude elements property allows you to exclude from the search area the region of the found hypothesis for an element. If no hypothesis of the excluded element is found, this constraint will not affect the search area of the element.

Note: An exception to this are cases where the user has specified additional constraints for some of the boundaries of the hypothesis for the excluded element in the Advanced pre-search relations pane. In this case, if the program fails to find the excluded element, it will cut out the rectangular search area of this element from the surrounding search area. See the Fuzzy rectangle section for details about internal rectangles.

To exclude an element's region from the search area, click the Add… button next to Exclude elements. In the Select Element to Exclude dialog box, select the element whose region must be excluded from the search area.

More

Relative search area

Additional search constraints


Relative search area

On the Relations tab of an element's Properties dialog box, you can specify a search area relative to other elements. The Properties dialog box is displayed when you create a new element.

To open the Properties dialog box for an existing element:

  • Right-click the desired element in the tree of elements and select Properties… on the shortcut menu or
  • Double-click the desired element in the tree of elements and select Properties… on the shortcut menu

In the Properties dialog box, click the Relations tab.

Specifying the boundaries of a search area relative to another element

In the New relation pane, enter a new relation:

  1. In the Relation field, select the type of relation: Left of, Right of, Above or Below.
  2. Select a reference element by clicking the [image] button next to the he he Reference element field and then select the element relative to which you will define the search area boundaries. For instructions on defining a search area relative to subelements of a repeating group, see Using instances of a repeating Group as reference, excluded, or source elements.
  3. In the Element boundary field, select the boundary of the element's region relative to which you will define the boundary of the search area.
  4. In the Offset field, set the offset value for the boundary of the search area.
  5. Click the Add button. The new relation will be added to the Relations table.

Note: The elements used as reference elements and the elements excluded from the search area must be located lower down the tree of elements than the element for which the constraint is being specified.

Tip
ABBYY FlexiLayout Studio allows you to have several Properties dialog boxes opened simultaneously. To copy a property that defines the boundary of a search area, select it in the Relations table and drag it into the Properties dialog box of another element. In the same way, you can copy the constraints specified on the Advanced tab.

Selecting the element closest to a certain object

The Nearest property tells the program that, all other things being equal, it must look for a hypothesis located closest to certain element or point on the image. Specify the closest element, point, or coordinate axis in the Nearest property of the element.

To instruct the program to select the element that is closest to a certain object on the image, select the Nearest option and then select the desired object from the To drop-down list: Element, X coordinate, Y coordinate, Point, Page top edge, Page bottom edge, Page left edge, Page right edge. If you select Element, enter the name of the element in the Reference element field. If you select X coordinate or Y coordinate, specify the corresponding coordinate. If you select Point, specify the coordinates of the point.

Note: The element closest to the given element is selected based on the shortest distance between element centers.

See also Using Nearest and FuzzyQuality to search for elements.

More

Specifying the absolute search area

Additional search constraints


Using instances of a Repeating Group as reference or excluded elements

Using instances of a Repeating Group as reference, excluded or source elements

You can use the element selection dialog box to select:

  • a reference element on the Relations tab of an element's Properties dialog box
  • an excluded element on the Search Constraints tab of an element's Properties dialog box
  • a Source element in a block's Properties dialog box

For simple elements, their names are used. For a Repeating Group element, a reference to the hypotheses for the repeating group (taking into account the number of the instance) is used to create relations.

When matching a FlexiLayout, several instances of hypotheses for the repeating group will correspond to one Repeating Group element in the tree of elements. Therefore, when specifying relations between a Repeating Group and other elements, you must specify which instance should be used. When you specify a reference to a hypothesis rather than a full name, the name of the Repeating Group is followed by a full stop and a description of the referenced instance.

The instance may be:

  • LastFound - the last detected instance of the Repeating Group at the moment when a hypothesis is generated for the given subelement
  • AllInstances - all the detected instances of the Repeating Group
  • Instance(#) - a particular number of the instance
  • CurrentInstance - the current instance; used when specifying relations between a subelement of a Repeating Group to refer to the current hypothesis for the group itself, i.e. to already detected subelements of the group that are located above the given subelement in the tree

The syntax of the reference in the element selection dialog box is the same as the syntax used in code you type in the Advanced sections to access the instances of a Repeating Group and their subelements. For example:

SearchElements.RepeatingGroup.LastFound.RepeatingGroup1.Instance(1). StaticText.

An instance of a group is selected in the dialog boxes where you select a reference element or an excluded element. In the selection tree, the instance numbers are indicated next to the names of repeating groups. When you select a repeating group, a Repeating instance field becomes available, where you can select the desired instance. The changes you make will be reflected both in the tree and in the result string.

When you select CurrentInstance for a child group CurrentInstance is automatically set for all the groups above it. If you change the CurrentInstance of a parent group to something else, the instances of all the child groups will be reset to the default value of LastFound.

When you select AllInstances for a parent group, AllInstances is automatically set for all the child groups. If you change the AllInstances of a child group to something else, the AllInstances of the parent groups will be reset to the default value of LastFound.

When creating a reference manually in the Advanced code, keep in mind that CurrentInstance can only be specified for a parent group, and if you specify CurentInstance for a group, all the groups above it must also have CurrentInstance specified for them. If AllInstances is specified for a group, all the groups below it must also have AllInstances specified for them. When you select group instances in the dialog box, the correct values are enforced automatically.

See also

Search constraints

Relative search area

Additional search constraints


Additional search constraints

You can also specify search constraints in a special FlexiLayout language.

You can specify additional search constraints on the Advanced tab of the element's Properties dialog box.

Note: For a Repeating Group element, an Advanced for All Instances is available. See Additional search constraints for a Repeating Group element.

The program offers a code editor where you can enter code for additional search constraints. The code editor can highlight different types of lexemes, suggest possible methods and properties (point suggestions), and carry out find and replace operations for any strings.

Full stop suggestions

The full stop suggestion technology is used in ABBYY FlexiLayout Studio 9.0 to offer suggestions to the user when writing macros in the FlexiLayout object-oriented language. The technology makes it easier to enter the names of methods and fields for objects of various types available ion the language.

If an expression typed in by the user is the name of an object, when you enter the full stop character (".") after the name, the program offers a drop-down list with the names of methods and fields for this object.

When you start typing, the selection in the list will automatically move to the name that starts with the characters typed after the full stop.

Pressing the Space, Tab or Enter buttons or entering a separator character (~!#%^&*()-=+\|/?><{}[];:.,'") which cannot be used in the names of methods or fields will change the text typed after the full stop to the name of the method or field selected in the list. Alternatively, you can double-click the desired name in the list to substitute the text after the full stop with that name.

Pressing the left arrow, right arrow, Insert, Delete, Home, End, Page Up, Page Down or Escape buttons, clicking anywhere outside the list or pressing a keyboard shortcut (e.g. Ctrl+V) will close the list without making any substitutions.

Use the up and down arrows to go up and down the list of suggestions.

Press BACKSPACE to delete characters typed after the full stop without closing the list of suggestions. However, if you delete the full stop itself, the list will close.

Additional search constraints can be of two types:

  1. Advanced pre-search relations - sets search constraints for an element and creates a search area
  2. Advanced post-search relations - penalizes generated hypotheses based on the properties of the corresponding elements

Element fields

An element field is a typed variable that belongs to an element. Element fields are defined in the External fields section on the Advanced tab and are used in additional search constraints. The value of a field can be changed only in the element to which it belongs. The value of a field may be used in the additional search constraints of the element itself and of the elements below the element in the tree. For more about element fields, refer to the Element fields section.


Advanced pre-search relations

Advanced pre-search relations set search constraints and element properties in a special FlexiLayout language. The pane where you can enter the code can be found on the Advanced tab in the Properties dialog box.

The code entered into the Advanced pre-search relations pane is executed immediately before search for the image object which corresponds to the FlexiLayout element. First, the program will use the properties you specified on the first three tabs to the right of the Advanced tab, and then run the code. If one and the same parameter is set both on the first tabs of the Properties dialog box and in the code, the code will have priority. If some parameter is specified on the first three tabs of the Properties dialog box but is absent in the code, the program will use the value of the parameter from the Properties dialog box. If you have specified some properties on the first three tabs of the Properties dialog box, you can translate them into code by clicking the Code button on the Advanced tab. The displayed code can be copied or edited.

Note: The additional constraints entered in the Advanced pre-search relations pane may only refer to elements located above the current element in the FlexiLayout tree. The only exception are subelements of the same Repeating Group element, which may refer to previous instances of subelements located in the same group below the given element.

Examples

Specifying different values for the same parameter

Sometimes you will need to assign different values to one and the same parameter. This can be done by using the "if ... then" operator:

if Element1.IsNull then {
MaxErrors: 3, 0.25;
} else {
MaxErrors: 5, 0.5;
}

Limiting the search area

The search area may be specified by using any of the types which define an image area: Rect, RectArray, Region. It can also be specified by using an expression which returns any of these types. The result of calculating the expression is passed as an argument to the RestrictSearchArea() function:
  1. RestrictSearchArea( Rect(Rect( Page( 1 ).RectGlobal.Left, Page( 1 ).RectGlobal.Top+20*mm, Element1.Left.Start, Element2.Ycenter.Start ) );
  2. let rect1 = Element1.Rect;
    let rect2 = Element2.Rect;
    RestrictSearchArea( rect1 or rect2 );
Cancelling the search for an object

For some documents the presence of one object on the image automatically excludes another object. In still other cases you may wish to look for a particular object only if certain conditions have been met. You can tell the program not to look for a specific object by using the DontFind() command. This command prevents the program from looking for the object. Once the command is executed, the program will formulate a null hypotheses for the corresponding object:

if Element1.IsNull() then DontFind().

Selecting a hypothesis

Sometimes several image objects meet the conditions specified in an element. This means that the program will formulate several hypotheses. If you need to select from this set only the hypothesis that is located closest to some other object or point on the image, you can use the Nearest, NearestX, and NearestY functions:

Nearest( [name of element] ) - sets the name of the closest element.

Nearest( x1, y1 ) - sets the coordinates of the closest point.

NearestX( x1 ) - sets the X coordinate of the closes vertical line.

NearestY( y1 ) - sets the Y coordinate of the closest horizontal line.

Note: You cannot use several Nearest functions at a time.

See also

FlexiLayout language


Advanced post-search relations

Advanced post-search relations allow you to penalize a generated hypothesis depending on the properties of the element. The purpose of these constraints is to adjust an already generated hypothesis.

Important!

The major difference between Advanced post-search relations and Advanced pre-search relations is that the program starts to consider the post-search relations only after the hypothesis has been formulated.

Note: Do not write the name of the element in the code of the Advanced post-search relations. For example, to access the Width property of some Element1, write simply Width.

Constraints set in the Advanced post-search relations pane are applied to each formulated hypothesis of the element independently of the other hypotheses. Different hypotheses for one and the same element cannot be compared. You can only adjust the quality of a specific hypothesis by studying its properties and imposing certain constraints on it.

Any command or constraint in the Advanced post-search relations pane returns an estimate of the quality of the hypothesis for the given element. Estimates obtained by applying different constraints are multiplied.

Note: Additional constraints set on the Advanced tab in the Advanced post-search relations pane may only refer to the current element and the elements located above the current element in the FlexiLayout tree. If this condition is not met, the program will highlight the illegal element.

You can use this pane to do the following:

Apply constraints to the properties of a hypothesis

E.g.:
The constraint Width > 5*cm for a hypothesis 3cm long will return a quality of 0, which will cause the program to stop formulating hypotheses for the element and its subelements.

Check the properties of a hypothesis

E.g.:
The following condition checks the height of the hypothesis and, depending on the result, limits or adjusts its width.
if Height > 3*cm then Width > 5*cm;

Adjust the quality of a hypothesis

You can adjust the quality of a hypothesis by calling the Quality(q) function, where q is a variable of type Quality. Executing this command multiplies the quality of the hypothesis by q.

Important!
Use of this feature requires caution. Do not use it if you are not sure of the results.


Additional search constraints for a Repeating Group element

The Properties dialog box of a Repeating Group element provides two tabs where you can specify additional search constraints: Advanced and Advanced for All Instances. On the Advanced tab, you can specify additional search constraints for individual instances of the group. On the Advanced for All Instances tab, you can specify additional search constraints for all the instances of the group.

In the Pre-search relations section, you can use all the methods available for a Group element. For example, you can specify relations with already detected instances:

// Each subsequent instance is located below the previous instance

if SearchElements.RepeatingGroup.HasInstances then {

Below: SearchElements.RepeatingGroup.LastFound, 0 * dot;

}

In the Pre-search relations for all instances section, you can use the following methods:

  • MinRepetitions

  • MaxRepetitions

  • PaginalMode

  • MinRepetitionsOnPage

  • MaxRepetitionsOnPage

In the Post-search relations section, you can provide an estimate for a particular instance. In the Post-search relations for all instances section, you can provide an estimate for all the detected instances.

In the Pre-search relations section, you can use all the methods available for a Group element.

Accessing element instances

Use the following pre-defined names to access element instances:

  • LastFound - the last detected instance

  • CurrentInstance - the current instance when searching inside a repeating element

  • Instance( n ) – instance No. n

  • AllInstances - all instances

You can access subelements of a Repeating Group element even they are located lower down the tree of elements.

The following methods of the FlexiLayout language can also be used to work with element instances:

  • HasInstances - checks if any instances have already been found

  • InstancesCount - returns the number of detected instances

Sample code for Post-search relations:

// Checking the hypotheses for the subelements StaticText1 and StaticText2 in a repeating group. The last detected instance is used.

if StaticText1.Width() < 200dt and StaticText2.Width() < 200dt then Quality: 0.98;

Sample code for Post-search relations for all instances:

if InstancesCount() < 5 and LastFound.Pages.End <= 2 then Quality: 0.98;

Condition for stopping the search for element instances

The search for instances stops (in the given branch) if the program encounters an empty hypothesis for a group (i.e. a group that has an empty region) or if the program cannot generate any more hypotheses (there are no more hypotheses in the search area). In Paginal mode, this rule applies to search on one page only. When the program finishes search on one page, it goes on to the next page. MinRepetitionsOnPage, MaxRepetitionsOnPage, MinRepetitions, and MaxRepetitions also affect the hypotheses generation process.

You can use the following methods to change the standard hypotheses generation process:

  1. The last detected instance must be the last one:

    2. if SearchElements.RepeatingGroup.HasInstances and <condition for SearchElements.RepeatingGroup.LastFound> then DontFind;

    This condition must be entered in Advanced pre-search relations.

  2. The last detected instance (and it is this instance that we are creating the constraint for) is "bad" and the previous instances must be the last (if there re no other "good instances detected"):

    If <condition for SearchElements.RepeatingGroup.LastFound> then Quality: 0;

    This condition must be entered in Advanced post-search relations.

See also

FlexiLayout language


Finding and replacing code strings on the Advanced tab

You can write expressions in the FlexiLayout language to specify element properties.

You can specify additional search constraints on the Advanced tab of the element's Properties dialog box.

"Find and replace" is carried out in the code of the current element and all of its subelements. Therefore, to perform "find and replace" in the code of all elements, you must select the FlexiLayout (i.e. the root element in the tree). If you need to perform "find and replace" in only one layout alternative, select this alternative in the tree.

This feature is useful, for example, when replacing the name of an element: you do not have to open all the Advanced tabs in the properties of various elements.

To find and replace a code string:

  1. Select the element in which to search.
  2. Open the Find in Advanced Code dialog box (Tools>Find in Advanced Code… or select Find in Code in element local menu).
  3. In the Find what field, enter the string to find. In the Replace with field, enter the string with which to replace the found code fragment. Select Match case if the search must be case sensitive.
  4. Click Find All to find all instances and Replace All to replace all the found code fragments. The results will be displayed in the Results field.


Units of measurement

ABBYY FlexiLayout Studio 9.0 allows you to use different units of measurement for objects: millimeters, centimeters, inches, dots (1/300 of an inch), or points (1/72 of an inch). You can use the selected units to specify object sizes, intervals, fuzzy intervals, etc. The program will convert all the sizes into dots and use them to match the FlexiLayout. For this reason, the maximum accuracy of all measurements is 1 dot.

You can select the desired unit of measurement in the Options dialog box (Tools>Options…). When you change the current unit of measurement, all the sizes are converted and displayed in the new units.

The current unit of measurement is displayed in th right-hand corner of the status bar.

See also

Measure Tool dialog box


Fuzzy interval

A fuzzy interval is a tool enabling the program to assess the quality of hypothesis based on its length. A fuzzy interval may be measured in units of length (dots, millimeters, etc.) or in characters (in the case of lines). For a fuzzy interval, four values must be specified which define the optimal and possible ranges of values.

Suppose you have a fuzzy interval [f1,f2,f3,f4] and the length of the detected string of characters (or the length of the detected space) is L. If the length L is in the range from f2 to f3 (i.e. L>=f2 and L<=f3), the quality of the hypothesis is 1. If the length is in the range from f1 to f2, the quality of the hypothesis changes in direct proportion from 0 to 1 (Quality(f1) = 0, Quality(f2) = 1). Similarly, if the length is in the range from f3 to f4, the quality of the hypothesis changes in direct proportion from 1 to 0 (Quality(f3) = 1, Quality(f4) = 0). If the length does not fall in the range from f1 to f4 (i.e. L<f1 or L>f4), the quality of the hypothesis is 0 (Quality(L) = 0). The quality of the hypothesis for the detected object is multiplied by the value of the Character count property. The value of this property is selected depending on the length of the detected object.

Note: The quality of any chain of hypotheses for several elements is calculated by multiplying the hypotheses for each element. If the chain is relatively long and the quality estimates of the constituent hypotheses are too low as a result of too strict constraints, the resulting quality of the entire chain may be too low.

Make sure that the selected hypothesis has the biggest quality estimate possible. On the other hand, you need to be able to distinguish hypotheses by their qualities, so as to be able to select the best one. Therefore, you need to set up fuzzy intervals so that acceptable hypotheses are not penalized too much.

You can also use negative values for the left boundary of the fuzzy interval (even though in reality there are no strings of negative length). This may be useful, as it will make the dependence of quality in the range from 0 to 1 less steep, thereby reducing the penalty. If at the same time you need to set the bottom limit for this parameter (e.g. the length of the string cannot be smaller than 10 characters and the fuzzy interval for the length of the string is [-10,20,30,40]), you can do so directly on the Advanced tab by typing Value.Length >= 10 in the Advanced post-search relations pane.

In general, it is advisable not to set too rigid intervals. This is particularly important when processing images of varying quality. On some images for example, there may be spaces within letters due to poor quality of the source document or bad scanning options. In this case the program may interpret one character as several characters, which may lead to a drastic reduction of the quality of the hypothesis if the fuzzy interval was too rigid. As a result, the program will discard a hypothesis which is in essence correct and select another hypothesis. For this reason, if you need to select between Character String hypotheses by comparing their lengths, you would do best by specifying additional constraints in the Advanced post-search relations pane.

Fuzzy interval visual editor

ABBYY FlexiLayout Studio 9.0 offers a visual editor to make specifying fuzzy intervals easier. You can open the fuzzy interval editor from the Properties dialog box of a Character String element (Character String tab, [image] buttons) or from the main menu by selecting Tools>Fuzzy Interval Editor….


Specifying databases and text files in the FlexiLayout language

The program interface and the FlexiLayout language allow you to refer to databases and text files to specify, for example, strings to be found on an image.

The ADO (Microsoft ActiveX Data Objects) interface is used to refer to databases. A database and its properties are set by the standard connection string, i.e. a set of arguments separated by semicolons which specify the connection parameters. These parameters include Provider, Data Source and others.

An SQL query starting with the SELECT command is used to search for fields in the database table. The resulting set obtained by a query must contain only one field. If a query returns more than one database field, the data from the first field are used. In its simplest form, a query gets the required field from a specified database table.

A text file is accessed by file name, which is specified relative to the folder that contains the FlexiCapture Studio project. Each search string must start on a new line. Empty lines are ignored.

When you export a FlexiLayout in order to add it to a document definition in ABBYY FlexiCapture 9.0, the text files are copied to the folder <FileName>Res, where FileName is the name of the FlexiLayout file or classifier file. This folder is placed in the same folder that contains the exported file. When you subsequently import a FlexiLayout, ABBYY FlexiCapture 9.0 will place the text files into appropriate folders automatically. For more about the locations of text files, see the ABBYY FlexiCapture Help system. 9.0

Text files may be in ANSI or Unicode encoding. A Unicode file must start with the standard header consisting of the special Unicode character 0xFEFF. To convert an ANSI file to Unicode, the current system code page will be used.

When matching a FlexiLayout with a page, the results of queries to the database may be stored within the program. Any changes to the database or the text file will be taken into account only when the program has switched to the next page. If an error occurs related to the database or the text file, FlexiLayout matching will be interrupted and the FlexiLayout will be considered as not matched.

Note: To speed up FlexiLayout matching, the first 1,000 strings in the file are used by default. To use more strings, specify the required number in the SearchTextFromFile command (Advanced pre-search relations > Advanced).


Blocks

FlexiLayout blocks correspond to fields on the forms from which data must be captured. A block specifies the type of data that the field may contain and the coordinates of the image area where the field is likely to be found.

The blocks branch is marked with [image] in the FlexiLayout tree.

ABBYY FlexiLayout™ Studio supports the following block types:

  • Text (marked with [image] icon) is used to extract text data
  • Barcode (marked with [image] icon) is used to read barcodes
  • Checkmark (marked with [image] icon) is used to recognize checkmarks
  • Picture (marked with [image] icon) is used to process objects which were not identified as text during pre-recognition
  • Table (marked with [image] icon) is used to extract data from tables
  • Group (marked with [image] icon) is used to logically group blocks
  • Checkmark Group (marked with [image] icon) is used to create checkmark groups. Only checkmark blocks can be added to this type of group - you cannot create or move blocks of other types here.
  • Repeating Group (marked with [image] icon) is used to create a repeating group of blocks
  • Non-Recognized, (marked with [image] icon) is used to exclude an area from recognition

The blocks for which at least in one layout alternative no image area is specified, have an empty square in the top right corner of the icon: . If only one FlexiLayout is selected (via the Select Layout item of the element's shortcut menu, or via the same item in the FlexiLayout / Classifier section, or via the Select Alternative Layout item of the FlexiLayout's shortcut menu), the program will check for the image area only in this FlexiLayout.

Note: Data from the blocks are extracted in a data capture application such as ABBYY FlexiCapture.

Block properties

Name - the name of the block. The name of a block may contain letters (Roman characters, Roman characters with diacritics, Cyrillic characters), digits, and underscores. The name of a block must start with a letter or an underscore. Block names must not contain blank spaces or special symbols.

Type - the type of the block (selected upon creation). The type of the block must correspond to the type of object(s) located in the area enclosed by the block.

Comment - a comment provided by the user (optional).

Has repeating instances - shows that the block will consist of several instances. Select this property if, for example, all the instances of a Repeating Group element will be used as the block region.

Instance sort order - sets the order in which group instances must be united into a block. The property is only available if Has repeating instances is selected. Possible values:
Top to bottom - the instances are united into a block in accordance with their location on the image, top to bottom
Left to right - the instances are united into a block in accordance with their location on the image, left to right
Right to left - the instances are united into a block in accordance with their location on the image, right to left
In order of finding - the instances are united into a block in the order in which hypotheses are generated. Hypotheses are generated in the order of decreasing quality. If the user specified additional conditions for instances, hypotheses are generated in the user-defined order. Thus, if you need an order different from the standard order used by the program, you can specify the desired order by means of additional conditions.

The following properties specify the area on the image from which data must be extracted.

For Layout selects the layout alternative where the search area is specified.

Source element - specifies an area which coincides with the region of an element. Once the program matches the FlexiLayout, it will detect the object(s) which correspond to the selected element. It is from these objects that the date will be captured. For a repeating group, you can select either one of the instances or use all the instances (AllInstances).

Expression - sets an area on the image which does not coincide with any of the element regions. For example, you can merge the regions of some elements and the space among them into one block, expand the region of an element by a certain value, or specify the coordinates of the block without relying on any elements. In this case the region of the block can be described in the FlexiLayout language.

Note: The region of a block is continuous. This means that if you create a region from rectangles which stand apart, the spaces between them will be filled by thin additional rectangles to make the region continuous.
However, a block may consist of multiple regions if all the instances of a repeating group are used as a reference element. The region of a group block is calculated based on the regions of the child blocks, just like the region of hypotheses. The resulting region is slightly expanded for better viewing.

A checkmark group and a common group of blocks have no other parameters than name and comments.

The parameters of a repeating group of blocks are the same as those of non-group blocks. The Has repeating instances option is always enabled for them. Child blocks may either have the Has repeating instances option or not, but an "Output instances" variable is always created for them. If a block inside a repeating group of blocks has the option Has repeating instances, this means that it can repeat inside each instance of the parent block.

Specifying a block region by means of instances of a repeating group

If a block is defined uys8ing several instances, the block region will consist of several separate regions. If you use a particular instance of a repeating group (e.g. LastFound), the block regions is defined just like for any other element. However, you can use all the detected instances (AllInstances). To use multiple instances, select the option Has repeating instances.

You can also write code for the block using the predefined OutputInstances variable. For example:
OutputInstances = SearchElements.PageHeader.AllInstances.UnionRect;

ABBYY FlexiCapture 9.0 processes blocks with the Has repeating instances option enabled as follows:

  • for non-tables blocks, the specified instances will be the instances of the corresponding field
  • for a table block, the specified instances will be treated as one instance of the field, i.e. ABBYY FlexiCapture 9.0 will process a block like this as a field of type Table with a discontinuous region.

Rules for creating references to elements for repeating groups of blocks

A repeating group of blocks refers to a repeating element. To create instances of a repeating group of blocks, you need at least several element instances. Therefore, one of the Ids must be AllInstances. Since the elements that are located below the element with AllInstances may not have other Ids, this condition also means that the lowermost repeating element has AllInstances.

Child blocks of a repeating group of blocks refer to child elements of the repeating group of elements to which the parent block refers. The reference must have the same Id for instances.

Example: If a repeating group block has the following reference: SearchElements..RepGr1.Instance(1).RepGr2.AllInstances, its child blocks may refer to the element RepGr1..RepGr2.Element only as follows: SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.Element.

If there is no HasRepeatingInstances attribute, you can only refer to subelements of the basic group which have no repeats inside it, and vice versa, if there is a HasRepeatingInstances attribute, you can refer to elements which have repeats inside the basic group (and you can only refer to all the instances at once).

Examples:

There is a HasRepeatingInstances attribute

SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.RepGr3.AllInstaces.Element

SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.RepGr3.AllInstaces.RepGr4.AllInstances.Element

There is no HasRepeatingInstances attribute

SearchElements.RepGr1.Instance(1).RepGr2.AllInstancess.Gr3.SubElement (where Gr3 is a simple group) SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.SubElement

Note: If references are created via Source element, the check will be performed when the FlexiLayout is built, and if references are created using Advanced code, an error will be detected when matching the FlexiLayout.

Using the FlexiLayout language to describe the location of a block

To specify the region of a block, use the Expression field. Depending on the type of the block and whether the Has repeating instances option is selected for it, one of the following predefined variables is used: OutputRegion (of type Region), OutputTable (of type TableHypothesis), and OutputInstances (of type HypothesisInstances or of type TableHypothesisInstances). For more about the predefined variable that can be used in the Expression field, see Predefined variables

Getting and expanding the region of an element by 3mm in width and by 5mm in length:

OutputRegion = SomeElement.Rect;
OutputRegion.Inflate( 3*mm, 5*mm );
Merging the region rectangles of two elements and getting the rectangle which circumscribes the merged rectangles:

Rect outputRect;
outputRect = Element1.Rect Or Element2.Rect;
OutputRegion = outputRect;
Merging the rectangles circumscribing the regions of two elements into one region:

RectArray outputRects;
outputRects = RectArray( Element1.Rect );
outputRects.Add: Element2.Rect;
OutputRegion = Region( outputRects );
Merging the regions of the objects corresponding to two different elements into one region:

RectArray outputRects;
outputRects = Element1.Rects;
outputRects.Add( Element2.Rects );
OutputRegion = outputRects.Region;
Merging the regions of the objects which belong to the region of Element1 and removing the regions of the objects which belong to the region of Element2:

OutputRegion = FormRegion( Element1.Rects, Element2.Rects );

Using a Table element to specify a Table block:

OutputTable = SearchElements.TableElement;

Using instances of hypotheses for a certain element to specify a Table block:

OutputInstances = SearchElements.RepeatingGroup.AllInstances.TemplateElement;

You can also use a pre-defined IsNull variable to describe the region of a block. This variable signals whether the region of the block has been found when matching the FlexiLayout. The value false means that the region has been found, the value true means that the region has not been found.

The IsNull variable is initialized with the value false, i.e. the region of the block is considered to be found. However, sometimes you may wish to check certain conditions before making a conclusion.

Using the IsNull variable
  1. To tell the program to consider the region of the block found if the width of the region of the source element exceeds 50 dots, enter the following code in the Region Expression field:
    if Element1.Width < 50dt then IsNull = true;
  2. To tell the program to consider the region of the block of Element1 has been found, enter the following code in the Region Expression field:
    IsNull = Element1.IsNull
  3. Suppose you need to use Element1 and Element2 to look for a block. If at
  least one of the elements has not been found the block is considered not
  found.
Rect outputRect;
Let FieldLeft = Element1.Rect.Left;
Let FieldRight = Element2.Rect.Right;
Let FieldTop = Element1.Rect.Top;
Let FieldBottom = Element2.Rect.Bottom;
outputRect = Rect( FieldLeft, FieldTop, FieldRight, FieldBottom);
if ((Element1.IsNull == True) or (Element2.IsNull == True) ) then {IsNull =
  true;}
OutputRegion = outputRect;

Note: This code will work correctly only if the search area of Element1 is above and to the left of the search area of Element2. In the example above, checking this condition is not included for the sake of simplicity. In actual code, this check is required and the values of the FieldLeft, FieldRight, FieldTop, and FieldBottom variable must be adjusted. Otherwise calling the Rect function will return an error.


Creating, editing, and deleting blocks

To create a new block:

  1. Switch to the FlexiLayout window.
  2. Select the Blocks branch in the FlexiLayout tree.
  3. In the FlexiLayout menu, select Add Block>[Type of block] (or select New>[Type of block] in the shortcut menu).
  4. In the dialog box, specify the properties of the block:
  • In the For layout list, select the layout alternative where the search area is specified.
  • if the region of block will coincide with the region of an element, select Source element and click [image]. In the Select Element dialog box, select the element whose region coincides with the region of the block. If you select a repeating group as a reference element, select its instance form the Repeating instance drop-down list. When selecting values for AllInstances, check the Has repeating instances option in the properties of the block, as in this case the block region may be discontinuous.
    Note: To facilitate recognition, the region of a text block is one dot larger in each direction than the region of the source element.
  • if the region of the block does not coincide with the regions of any elements, select Expression end enter code in the Expression field. Click Check to check the code for errors.

Note: You can create blocks before you have created elements, but in this case you can specify the location of the blocks on the image only by directly entering their coordinates. However, in most cases block coordinates are unpredictable and the locations of the blocks can only be described through the locations of image objects.

To edit the properties of a block:

  1. Switch to the FlexiLayout window.
  2. Select the block whose properties you wish to edit.
  3. Right-click the block and select Properties… from the shortcut menu.

    Note: You can also display the Properties dialog box by double-clicking the block.

  4. Make the necessary changes.
    Note: You can only change the name and region of a block. You cannot change the type of a block.

To delete a block:

  1. Switch to the FlexiLayout window.
  2. Select the block you wish to delete.
  3. Right-click the block and select Delete
    4. from the shortcut menu.


Working with tables

ABBYY FlexiLayout Studio allows you to create formalized descriptions of documents with tables, including tables on financial documents. More generally, the program can be used to describe any data that have a table-like structure, even if there are no explicit grid lines. Your table must not contain merged cells. Tables with merged cells can be described by means of a Repeating Group element .

Tables may spread over several pages, starting and ending anywhere on a page.

For the purposes of creating a FlexiLayout, a table can be divided into three logical parts - header, body, and footer. The body of a table contains the data that must be recognized and extracted.

The header and footer function as the top and bottom boundaries of the body. Additionally, the header contains the names of the columns. This information is used by the program to correctly divide the table into columns.

The program detects cells by relying on the black separator lines and white gaps which may divide a table into columns and rows.

To create a FlexiLayout for a table:

  1. Create a Table block and list the columns that the table may contain.

  2. Create a Table element in which:

  1. Select the Table block corresponding to the Table element;

  2. Set the search constraints for each column of the table;

  3. Set the order of the columns in the table;

  4. Set the search constraints for the header of the table;

  5. Set the search constraints for the footer of the table;

  6. Specify how the table should be divided into rows;

  7. Set the search area for the entire table;

  8. If required, set additional search constraints.

Table element


Table block

A Table block is used for carries over to FlexiCapture the coordinates of the detected tables. The data from the detected tables will be extract in the FlexiCapture. A Table block is different from other types of block in that it returns not only a region enclosing the entire block, but also rectangles drawn around each table cell. Compared to other types of block, a Table block has an additional property - a list of columns that the table may contain. A FlexiLayout may contain one or more Table elements telling the program where and how to look for the columns specified in the block.

Note:

  1. Upon creating a Table element you need to 'bind' it to the already created Table block. So you usually need to start with creating a block. You can first specify its approximate search area, then create one or more elements to look for the block, and then use these Table elements to finalize the search area of the block.
  2. You can create several elements each of which describes its own algorithm of finding one and the same Table block. You can instruct the program to select the Table element which best fits the table block after the block has been found. This is done by means of a Region expression.

Table blocks are marked with [image] in the FlexiLayout tree.

To create a Table block:

  1. Switch to the FlexiLayout window.

  2. Select the Blocks branch in the FlexiLayout tree.

  3. From the FlexiLayout menu, select Add Block>Table or select New>Table from the shortcut menu.

  4. Specify the properties of the block.

  5. On the Table block tab set the following:

  • the name of the block;

  • your commentary to the block (optional);

  • if the region of the block and division of the table into rows and columns will coincide with the region returned by a Table element, select the Source element option and click [image]. In the Select Element dialog box, select the Table element whose region coincides with the region of the block and click OK.

  • if the region of the block does not coincide with the region of any of the Table elements, select the Region expression option and enter the required code in the Region expression field. Click Check to check the code.

  6. On the Columns tab, specify the columns that may occur within the block. To do this, click Add… and enter the name of a column. You may find it convenient to use the names of columns as they occur on the test images. To change the name of a column, click Edit… and in the Edit Table Column dialog box, enter a new name for the column. Use the [image] (Down) and [image] (Up) buttons to arrange the columns in the same order in which they must occur in data capture application

An example of specifying which block region to select

To specify the region of a block, use the pre-defined variable OutputTable of type TableHypothesis.

The code in the example below selects the Table element in which the most rows have been found

let T1 = SearchElements.TableElement1;

let T2= SearchElements.TableElement2;

if T1.RowsCount > T2.RowsCount then OutputTable = T1; else OutputTable = T2;

Note: The table elements SearchElements.TableElement1 and SearchElements.TableElement2 in the example must refer to the same Table block whose Region expression field contains the above code.


Table element

A Table element is used to detect tables of different structures, including tables on financial documents. Additionally, a Table element can be used to detect any data which have a table-like structure. The program will rely on black separator lines and white gaps to look for table cells.

Table are marked with [image] in the FlexiLayout tree.

  1. Switch to the FlexiLayout window.

  2. Go down the FlexiLayout tree to the nesting level where you wish to create a new element (select SearchElements for the first level).

  3. Select the required type of element (FlexiLayout>Add Element>Table).

  4. Specify the properties of the element:

  • On the General tab, enter a name for the element and add your comment (optional). Then specify whether the element is optional or required;
    Note: The name of an element must start with a letter or an underscore, which may be followed by letters and/or digits. You cannot use spaces or the following special symbols: '.', ',', ':', '-', '\', '/'. The name of an element must not coincide with any of the reserved words;

  • On the Columns tab, specify the table block bound to the element. Once you have specified the Table block, a list of all the columns of the selected block will appear in the Columns of selected table block field. For each column, specify its search constraints;

  • On the Order tab, specify the orders in which the columns may occur in the table on the images;

  • On the Header tab, specify the properties of the header of the table;

  • On the Footer tab, specify the properties of the footer of the table;

  • On the Rows tab, specify the properties of the rows;

  • On the Search Constraints and Relations tabs, specify the search area for the entire table, including its body, header, and footer;

  • If required, specify additional search relations on the Advanced tab.

More

An overview of FlexiLayout element properties

Search area

Additional search constraints


Selecting a Table block and specifying search constraints for columns

You can select the Table block to bind to the current Table element on the Columns tab of the element's Properties dialog box.

Selecting a Table block

Each Table element must correspond to a Table block, for which search it intends. To select a Table block, click the Select button and select the Table block which corresponds to the current Table element. A list of all its columns will appear in the Columns of selected table block field. Set the properties for each of the columns - these will be used as search constraints when looking for the columns.

Note:

  1. The list of the columns of the block displayed on the Columns tab in the element's Properties dialog box cannot be edited in this dialog box. To edit the list, you need to open the Properties dialog box of the block.
  2. To better understand how an element and its corresponding block are connected, consider the following: a Table block serves as an interface between the FlexiLayout and a data capture application, whereas a Table element is the implementation of that interface. A Table element contains the instructions about how to find the Table block. You can create several program implementations for any interface. Likewise, you can create several Table elements for a Table block (but not the other way round).

When you select a Table block on the Columns tab of an element, by default the program uses the names and order of the columns in the Table block to set the search constraints for each of the columns (see Setting search constraints for table columns) and to set the order of the columns (see Order of table columns).

Disabling a table column

When testing your FlexiLayout, you may need to disable a column without removing it from the FlexiLayout altogether. Disabling a column retains all the information about the column in the FlexiLayout but tells the program to ignore the column when testing the FlexiLayout. To disable a column, select the column you wish to disable in the Columns of selected table block field and click Disable. This will clear the check mark next to the name of the column. To enable the column, select its name in the list and then click Enable.

Note: When you disable a column, it is automatically disabled in all of the order lists on the Order tab.

Setting search constraints for table columns

The search constraints for table columns are set in the columns' Properties dialog box. To open the Properties dialog box of a column, select the column in the Columns of selected table block field and then click the Properties… button next to the field.

The names of the columns located in the header of the table play an important part in column detection. To help the program to detect the names of the columns, you can use keywords which can be found in the header. Alternatively, the name of a column can be detected by relying on another element, whose region will be considered also the region of the column name.

Using key words to detect the names of columns

To detect the name of a column by means of keywords, select the Detect by keyword in name option. In the field below, enter the keywords or phrases which occur in the column name on the test images. Press Enter after typing each keyword.

If you wish the program to use only whole words when looking for the names of the columns, select the Whole words only option.

In a narrow column, words in the name will often be carried over to the next line. Select the Multi-line name option to detected column names like that.

Since one and the same column may have different names on different images, the list of keywords must include all the possible variants which may actually occur. However, on some of the images the column may have no name at all or may be absent altogether. For this reason, the name of a column is always optional. This means that the name of a column need not be found when matching the FlexiLayout with the images. If a keyword is not found (either because it is actually absent or because the quality of the image is inadequate for OCR), the hypothesis will be penalized - its quality will be multiplied by the quality of the null hypothesis for the non-detected keyword. The penalty for the hypothesis is set in the Missing keyword penalty field. The default value is 0.97.

Using the region of another element to detect the names of columns

You can use an already found element to find the name of a column. This allows you to set additional search constraints on the keyword. This method also allows you to look not only for Static Text, but also for a Character String, for Inverted Text, or just for a region.

To find the name of a column by means of an already found element, select the Use found element as column name option, next click [image] and in the Select Element dialog box, select the element whose region will be considered also the region of the column name.

Note: The element you use to detect the name of a column must be located above the described Table element in the FlexiLayout tree. When describing a multi-page table, it is recommended to use repeating elements to search for a column name (refer to Detecting multi-page tables for more information about multi-page tables).

Checking whether the column has been detected correctly

When looking for columns, the program uses not only information about their names, but also the information about their content. Thus, if you know that a particular column contains a particular type of data, you can specify this in order to help the program detect the column more reliably. To enable FlexiLayout Studio to check the data type in a column, select the Check content type option and in the Type of column content field specify one of the available data types that the column is likely to contain:

  • Text;

  • Currency;

  • Date;

  • Regular expression;

  • Number.

If you selected the Regular expression type, you need to enter the code of the regular expression which describes the format of the data in the column.

Regular Expression Alphabet
Name in the list | Symbol in the field | Example
Any character | * | "k"*"t" – allows 'kit', 'kat', etc.
Letter | C | C"at" – allows cat, bat, Rat, mat, etc.
Upper case letter | A | A"at" – allows Cat, Bat, Rat, Mat, etc..
Lower case letter | a | a"at" – allows car, bat, rat, mat, etc.
Letter or digit | Х | X – allows any single letter or digit.
Digit | N | N"th" allows 5th, 4th, 6th, etc.
String | "" | "cat"
Or | | | "dr"("i"|"u")"nk" – allows "drink" or "drunk".
Character from the set | [] | [hm]"at" – allows 'hat' or 'mat'.
Character not from the set | [^] | [^b]"at" – allows 'cat', 'mat', 'rat', but does not allow bat.
Any number of repeats (applies to the expression or sub-expression to the left) | {-} | [AB74]{-} – allows any combination of A, B, 7, 4 of any length.
Number of repeats is n | {n} | N{2}"th" allows 25th, 84th, 11th, etc.
n to m repeats | {n-m} | N{1-3}"th" allows 5th, 84th, 111th, etc.
0 to n repeats | {-n} | N{-2}"th" allows th, 84th, 4th, etc.
n or more repeats | {n-} | N{2-}"th" allows 25th, 834th, 311th, 34576th, etc.
Subexpression | () |

If the data type in the column does not coincide with the data type in the Type of column content field, the hypothesis will be penalized. The field Missing content penalty contains the coefficient by which the quality of the hypothesis will by multiplied if the column content does not correspond to the data type you specified.

Specifying the coordinates of the search area

You can specify the coordinates of the search areas of the left and right boundaries of a column. In the Absolute area constraints property, enter the coordinates of each of the search areas in the Left boundary and Right boundary fields respectively.


Order of table columns

Since the order and composition of columns may vary from image to image, you need to list all the possible orders of the columns in the table. If an element describes all the possible columns of a table and you can find all the possible orders of columns by analyzing the images, specify all the possible orders in the properties of the element. If you cannot provide an exhaustive list of all the possible column orders, or if the columns are interspersed by other columns which need not be detected, you can write a special rule to describe multiple column orders.

Note:

  1. If you simply list possible column orders, you can specify contradictory column orders, for example: "Column1; Column2; Column3" and "Column3; Column2; Column1". When matching the FlexiLayout with an image, the program will select the column order which best suits the image.
  2. If you use a rule to describe multiple column orders, you cannot specify contradictory orders. When matching the FlexiLayout with an image, the program will look for a column order which meets all the conditions. If two rules specify contradictory conditions (e.g. "Column1 << Column2 << Column3" and "Column3 << Column2 << Column1"), the program will fail to match the FlexiLayout.

You can specify column order in the Properties dialog box of a Table element (Order tab).

Listing fixed column orders

If the columns have exactly the same order on all of the test images, this order is said to be fixed. For example, a table may contain three columns, say, Date, Quantity, and Price, which are always arranged in this order.

Sometimes, you will be able to find several different column orders on the test images. For example, on some of the images the order might be Date, Quantity, Price, while on others the order might be Date, Price, Quantity.

The program allows you to specify any number of such orders.

To specify fixed column orders, select the Fixed column order option. By default, when you create a Table element the program specifies one fixed order of columns by listing all of the columns in the same order as you specified when creating the table block. This order is given the default name of Standard.

You can make changes to the Standard order to adjust it to the column order on the test images. You can also add new orders or delete orders from the list.

To edit a fixed column order:

  1. Select the column order you wish to edit and click Edit…. The Edit Fixed Column Order dialog box will open.
  2. In the Order name field, enter a new name for the column order. This name is only used to identify the order in the FlexiLayout and is displayed in the properties of the hypothesis for the current Table element. This name will help you identify which of the column orders the program has selected.
  3. The Available columns field contains a list of all table columns. Select the desired column and click [image] to add it to the Selected columns list. Clicking [image] will add all the columns to the list. Clicking [image] removes a column form the Selected columns list, and clicking [image] removes all the columns from the Selected columns list. The [image] and [image] move columns up and down in the Selected columns list. Use this buttons to change the order of columns as required and click OK.

To create a new column order:

  1. Click the Add… button. The Add Fixed Column Order dialog box will open.
  2. In the Order name field, enter a name for the new column order.
  3. The Available columns field contains a list of all table columns. Select the desired column and click [image] to add it to the Selected columns list. Clicking [image] will add all the columns to the list. Clicking [image] removes a column form the Selected columns list, and clicking [image] removes all the columns from the Selected columns list. The [image] and [image] move columns up and down in the Selected columns list. Use this buttons to change the order of columns as required and click OK.

To delete a fixed column order, select the order in the list and click Delete.

Using rules to specify the order of columns

If analyzing the test images does not allow you to determine one or more fixed column orders, you can write a rule to describe the possible orders.

Each rule sets a condition like the following: "The Date column always precedes the Item column" or "The Price column always follows the Item column". Rules allow you to limit the search areas of columns and reduce the number of possible combinations.

To specify the order of columns by means of a rule, select the Rules for column order option.

To create a rule:

  1. Click the Add… button. The Edit Column Order Rule dialog box will open.
  2. The Available columns field contains a list of all table columns. Select the desired column and click [image] to add it to the Selected columns list. Next, select the column which always goes after the previously selected column (but not necessarily immediately follows it).
    Clicking [image] will add all the columns to the list. Clicking [image] removes a column form the Selected columns list, and clicking [image] removes all the columns from the Selected columns list. The [image] and [image] move columns up and down in the Selected columns list. Use this buttons to change the order of columns as required and click OK.
  3. The created rule will be displayed in the Rules for column order field. The << symbol indicates that one field always precedes the other.

To edit a rule:

  1. Click the Edit… button. The Edit Column Order Rule dialog box will open.
  2. Use the [image], [image], [image], [image] and [image] buttons to set the required order and click OK.

To delete a rule, click Delete.


Table header

A header contains the names of the columns in the table. Data are not extracted from this part of the table. The header merely helps the program to locate the top boundary of the table body and divide the table into columns. The search constraints for the header are set on the Columns tab.

The following properties can be specified for a table header:

Look for header tells the program whether it should look for a header when matching the FlexiLayout. The option is selected by default.

Header is optional tells the program that the table may have no header. This will not prevent the FlexiLayout from matching. The option is selected by default.

The Null hypothesis quality field sets the quality of the null hypothesis for the header (this hypothesis is generated if the header is not found). The default value is 0.95.

In the Number of hypotheses field, enter the maximum number of hypotheses to generate when looking for the header. The default value is 1.

Header is on each page specifies that the header of a multi-page tables occurs on every page. The option is selected by default.

The Absolute area constraints option allows you to specify the coordinates of the header search area. If you wish to enter the coordinates, select this option and in the field next to it, enter the coordinates in the following format: [left, top, right, bottom]. You can enter the coordinates of only one rectangle in this field.


Table footer

A footer of the table helps the program to locate the bottom boundary of the table body. No data are extracted from the table footer. Since table footer may be absent on some of the images, it is not looked for by default. You can use keywords or phrases to look for a footer. Alternatively, you can use an element to look for a footer. The region of this element will be considered to be also the region of the footer.

The following properties can be specified for a table footer:

Look for footer tells the program whether it should look for a footer when matching the FlexiLayout. The option is not selected by default.

Footer is optional tells the program that the table may have no footer. This will not prevent the FlexiLayout from matching. The option is selected by default.

The Null hypothesis quality field sets the quality of the null hypothesis for the footer (this hypothesis is generated if the footer is not found). The default value is 0.97.

Selecting a method of finding the footer

The Search by keyword option allows you to use keywords or phrases to look for the footer. If you wish to use keywords, select this option and then enter the keywords in the field next to it. Press Enter after typing each word.
Tip: If you want to restrict the search constraints for the footer of the table, select the Whole words only option. If this option is selected, the specified keywords or phrases must be found in whole when searching for the footer of the table with the help of keywords. For example, if you have specified "Pages" as a keyword, the word "Page" will not be considered.

The Use found element as footer option allows you to use an element to look for the footer. The region of the found element will be considered to be also the region of the footer. You can use an element of any type to look for the footer. For example, you cam find a horizontal White Gap and use it as the bottom boundary of the table.
If you wish to use an element, select this option and then click [image]. In the Select Element dialog box, select the element whose region will be used as the region of the footer.

Note: The element you use for the footer must be located above the current Table element in the FlexiLayout tree.

Footer is on each page specifies that the footer of a multi-page tables occurs on every page. If the option is not selected, the footer may only occur on the last page. Once the program detected the footer it will stop looking for the other parts of the table. The option is selected by default.

The Absolute area constraints option allows you to specify the coordinates of the footer search area. If you wish to enter the coordinates, select this option and in the field next to it, enter the coordinates in the following format: [left, top, right, bottom]. You can enter the coordinates of only one rectangle in this field.


Table rows

After the program has detected the columns, it starts to look for rows. FlexiLayout Studio can detect rows automatically by relying on the black separators and white gaps.

Sometimes a column may contain a fairly large fragment of text (e.g. a long description of a product). In this case the text is often carried over to the next line and white gaps between these lines should be ignored when dividing the table into rows. If the number of text lines in a cell varies from column to column, you can use one or more 'master' columns to divide the table into rows. The rows of the 'master' columns will be used as a pattern for the entire table.

You can select a method of dividing a table into rows and specify the properties of the rows in the Properties dialog box of the Table element (Rows tab).

Automatic detection of rows

To detect rows automatically, select the Detect rows automatically option. The program will rely on the black separators and white gaps present in all of the columns to divide them into rows.
If you wish each line of text to be marked as a row, select One line of text corresponds to one row.

Using master columns to detect rows

If a table has columns whose data define the splitting of the table into rows, you must select the Use master columns to detect rows option and specify the desired columns in the list of the so-called Master columns. The first Master column detected on the image will be used to detect rows of the table.

Select the columns whose rows will be used to divide the rest of the columns into rows. Since the composition of columns may vary from image to image, the list of master columns must cover all the possible variations. To create a list of master columns:

Click the [image] button next to the Use master columns to detect rows option

In the Select Master Columns dialog box, select the required columns from the Available columns list and click [image]. The names of the selected columns will be displayed in the Selected columns list. Then use the [image] and [image] buttons to arrange the columns in order of priority. The top-most column that the program finds on the image will be used for detecting rows.

Click OK to display the selected columns in the Use master columns to detect rows list.

To edit the list of master columns, click [image]. Then use the [image], [image], [image], [image], and [image] buttons to make the necessary changes to the Selected columns list.

To specify how text within the cells of the master columns should be aligned, use Master column text alignment. Top specifies alignment by the top border and Bottom specifies alignment by the bottom border.

Select One line of text corresponds to one row if you wish the program to draw a row for each line of text in master column.

Words and phrases for which the program must not draw rows

Some tables may contain narrow columns which contain numerical data accompanied by units of measurement (e.g. sums of money with currency symbols). If the unit of measurement does not fit on the same line, it may be carried over to the next line. In this case the column will contain additional lines of text. To prevent the program from drawing separate rows for such lines, you can add such carried currency symbols, units of measurement etc. to the list of Words not to be treated as a separate line of text.

To create a list of stop words or phrases which do not merit a separate row, type such words or phrases into the Words not to be treated as a separate line of text field. Press Enter after typing each word or phrase.

Note: Words you type in the Words not to be treated as a separate line of text field are used both when detecting rows automatically and when detecting rows by means of master columns.


Detecting multi-page tables

What is a multi-page table?

ABBYY FlexiLayout Studio 9.0 can detect multi-page tables, i.e. tables that stretch over several pages of a document, the order and number of their columns being the same on all the pages. The width and the exact location of the columns may vary slightly from page to page (the maximum variation allowed by the program is 1 inch).

For the sake of brevity, we use the term one-page subtable for each part of a multi-page table located on one page.

The header and footer of a multi-page table

Multi-page tables may have a header that either repeats on every page or occurs only once on the first page. The option Header is on each page tells the program whether the header must be detected on every page. If the option is disabled, ABBYY FlexiLayout Studio 9.0 will search for the header only on the first one-page subtable.

The same applies to the footer of a table, which can occur either only once on the last page or at the bottom of every page. The Footer is on each page tells the program whether the footer must be detected on every page. If the option is disabled, ABBYY FlexiLayout Studio 9.0 will search for the footer only on the last one-page subtable.

Searching for a multi-page table

The program starts searching for a multi-page table from the first page of the search area specified by the user and continues the search on the subsequent pages. The search stops when any of the following conditions is met:

  1. If the footer must occur only on the last page and it has been detected.
  2. If the program has come to the end of the search area specified for the table.
  3. If the program has not detected any one-page subtables on a page, i.e. it has not found the header, the footer, or the table body.

Using the region of another element to detect the name of a column in a multi-page table

In the case of multi-page tables, you can still use two methods to search for the header and footer of a table or its subtables: either by specifying keywords (the Detect by keyword option) or by turning an already detected element into header or footer (the Use found element as... option). If you use the first method, the program will search for the specified keywords on those pages where the header or footer may occur (defined by the Header/Footer occurs on every page option). If keywords cannot reliably detect the column names on the images being processed, use the Use found element as... option.

If the header and footer of a multi-page table occur only on the first and the last page respectively, you can use already detected simple elements, just like for one-page tables. This method is used in Sample 3 (see the project in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Invoice). However, if the header or the footer must be detected on every page, the best strategy is to use the subelements of an already detected Repeating Group. Using a Repeating Group, you can find the header on every page by describing it only once in the Repeating Group and specifying the possible number of instances for the Repeating Group. If the Table element is described below the Repeating Group in the tree of elements, use all the instances (AllInstances) of the desired subelements to reference column names to the Repeating Group. For an illustration of this approach, see the sample project in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Invoice with Repeating Groups).

Note: If there are several instances of the selected Repeating Group on a page, the first instances will be used as the name of the column.

Searching for repeating tables

In some documents, there may be several identical tables on a page (the tables arrangement and order of columns in these tables may be the same). Sometimes, the last table in the series may be interrupted and continue on the following page. In between the tables there may occur textual data or visual formatting elements, e.g. table captions or explanatory notes.

You can detect tables like these by placing the Table element that describes one instance of the table inside a Repeating Group. This allows you to describe the entire set of tables in one Table element and specify the repetitions of the instances in the properties of the Repeating Group that encompasses the Table element.

If you are using the Use found element as... option to detect column names bases on an already detected element, it is more convenient to place this element into the same Repeating Group above the Table element. In this case, when you select an auxiliary element that will be used to detect the column name, reference the current instance (CurrentInstance) of the auxiliary element within the Repeating Group. Now when the program will search for each instance of the column name, it will use its corresponding instance of the auxiliary element. For an illustration of this approach, see the sample project in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Prices).

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.


Hypotheses and trees of hypotheses

A hypothesis is an assumption made by the program that the detected object(s) correspond(s) to a particular element, i.e. meet(s) the properties and search criteria specified for the element.

Important!
There may be several objects or sets of objects in the element’s search area, all of which correspond to the element. In this case, the program will formulate a hypotheses for each detected object.

Hypotheses are characterized by their quality.

The quality of a hypothesis measures how well the detected object matches the description contained in the corresponding element and is a numerical value from 0 to 1.

The quality of a hypothesis is calculated as [Pre-search quality]*[Post-search quality], where

  • Pre-search quality is the quality of the settings made in the Properties dialog box and in the Advanced pre-search relations field
  • Post-search quality is the result of applying the conditions specified in the Advanced post-search relations field.

The quality of a hypothesis for a Group element is calculated by multiplying the qualities of the hypotheses for all the constituent elements.

For optional elements the program formulates a null hypothesis.

A null hypothesis is a hypothesis which the program formulates if it has detected no objects corresponding to an optional element in the search area.

This means that if the program does not find any objects corresponding to an optional element, it does not stop matching the FlexiLayout, but formulates a null hypothesis and assigns it a quality set by the user when creating the optional element.

For the sake of convenience, we use the term hypothesis to refer to the set of objects included in a particular hypothesis.

Hypotheses: a practical example

Suppose we need to create two elements which will be used to find two static texts on our images. The first static text is "mother", the second static text is "father", and we know that the text "father" is always located below the text "mother" The first Static Text element, StaticText1, will be used to look for the text "mother", and the second Static Text element, StaticText2, will be used to look for the text "father". We assume also that both elements are optional and the quality of the null hypotheses for each of them is set to 0.97.

We will not set any constraints on the search area for StaticText1. As we know that the text "father" is always located below the text "mother", we can specify that StaticText2 must be always located below StaticText1. We will do this by typing the corresponding constraint on the Relations tab in the Properties dialog box of the StaticText2 element: Below: SearchElements.StaticText1;.

The figure below displays the results of matching the FlexiLayout with an image on which the word "mother" occurs twice (above and below the word "father") and one OCR error has been made in the word "mother" located above the word "father".

Matching the FlexiLayout has generated two hypotheses for the StaticText1 element. The first hypothesis corresponds to the word "mother" recognized with one OCR error and located above the word "father" and has a quality of 0.98. The second hypothesis corresponds to the word "mother" located below the word "father" and has a quality of 1.

At this stage, the quality of each chain is the same as the quality of the corresponding hypothesis. Therefore, the best chain consists of the hypotheses with a quality of 1.

Since we told the program to look for the StaticText2 below the StaticText1 element and since the program has generated two hypotheses for the StaticText1 element, now it is trying to find the required static text in two search areas. If the program pursues the second hypothesis with a quality of 1, which has found the word "mother" below the word "father", it will fail to find the StaticText2 element below the StaticText1 element and, consequently, it will generate a null hypotheses with a quality of 0.97. The quality of the resulting chain of hypotheses will be 1x0.97=0.97

If the program pursues the first hypothesis with a quality of 0.98, which has found the word "mother" above the word "father", it will successfully detect the StaticText2 element below the StaticText1 element and generate a hypothesis with a quality of 1. The quality of the resulting chain of hypotheses will be 0.98x1=0.98.

As a result, the program selects the chain with an overall quality of 0.98.


Hypotheses and optimizing the search

When the program matches a FlexiLayout with an image, it attempts to find the objects on the image which correspond to the elements in the FlexiLayout. The program then estimates how well a particular object matches its element. An estimate is a number form 0 to 1. A quality of 1 means that the detected object is a 100% match. If the quality is not 0, matching the FlexiLayout results in creating regions for the blocks.

The program looks for elements consecutively in the order in which they follow in the FlexiLayout tree, top to bottom. For each element the program may find several matching objects (or sets of objects) in the search area. The program formulates a hypothesis for each object in the search area and estimates its quality - the better the match, the higher the quality of the hypothesis.

The location of the detected object determines the location of the objects down in the FlexiLayout tree. The program uses each of the hypotheses of the current element as starting points to look for the subsequent elements located below the current element. Thus, the hypotheses for elements branch out, which results in a tree of hypotheses that contains many more branches than the tree of elements.

If several elements are joined into one Group element, the entire group is considered as one element for which several hypotheses are formulated. The quality of a Group element is calculated by multiplying the hypotheses for the constituent elements. The entire FlexiLayout may considered as a Group element whose quality can be calculated by multiplying the qualities of the hypotheses for all of its elements.

When matching a FlexiLayout with images, the program needs to find the best complete branch of hypotheses. A branch is complete if it includes all of the elements, from the top element to the bottom element. A generic solution would be to consider all the possible combinations of hypotheses for all the elements, building a complete set of possible complete branches and selecting the branch with the highest quality. This is not practical, since it would take too much time. Moreover, if the number of elements is fairly large and their search areas are only approximate, a combinatorial explosion may occur resulting in an uncontrollable growth of the number of hypotheses.

The program uses several methods of optimizing the search to keep the number of hypotheses to a minimum.

Search optimization

Each element in the FlexiLayout has an important parameter called Number of surviving hypotheses. The user can use this parameter to limit the number of hypotheses which the program may use when looking for the subsequent element. By default, this parameter is set to 5 for simple elements, and to 1 for Group elements. That means that if the program finds 15 hypotheses for a given element, it will select the best five, leaving the other 10 chains of hypotheses incomplete. Group elements, as a rule, are detected more reliably than simple elements. Therefore, the best hypothesis for a Group elements usually turns out to be the correct one.

In most cases the program has several incomplete chains of hypotheses and, consequently, several possible search directions. The program looks for the best hypothesis using the classic "wide search" algorithm. This algorithm means that the program always tries to complete the chain which has the best quality at the moment, irrespective of its length.

Suppose we have a FlexiLayout which describes 30 elements for which two chains of hypotheses have been created: a chain of 29 elements which has an estimated quality of 0.89 and a chain of 2 elements which has an estimated quality of 0.92. The program will attempt to complete the smaller chain, which is better in terms of quality, until such time when the qualities of all its extensions become worse than the first chain.

In the case of a Group element, the program uses so-called quality optimization. When the program finds an ideal complete chain of hypotheses for a given Group element (that is, the quality of this chain is 1), it ignores all the other variants.

The total number of hypotheses for each element is limited to 10,000.

More

How hypotheses are generated and assessed


How hypotheses are generated and assessed

Once the program has formulated a hypothesis (i.e. detected the object that best matches the description provided in the element), it draws the region of the element on the image.

A region is an area on the image consisting of several rectangles drawn so as to enclose the object. The region of a null hypothesis is the entire search area of the element.

The search area of an element may contain several objects which match the description contained in the element, i.e. the program can formulate a hypothesis for each one of them. When describing an element, you can specify the maximum number of hypotheses — this will limit the number of candidate variants the program will consider when looking for objects described by the element. Hypotheses for the elements that come next in the tree are formulated on the basis of the best hypotheses for the preceding element. The maximum number of best hypotheses for a particular element is set in the element's Properties dialog box (General tab). For simple elements, the default value is; for Group elements, the default value is 1.

Important!

We do not recommend changing the default maximum number of hypotheses.

The quality of a hypothesis depends on the properties of the corresponding elements.


Hypotheses for Static Text elements

When the program looks for static text on an image, the recognized text need not exactly match the text specified in the properties of the element.

For example, you can specify the properties of a Static Text element in such a way as to make the program consider the object "Supplier" as a valid hypothesis for the expected static text "Supplier".

You can set the following parameters in the Element Properties dialog box:

  • Max number of errors – the maximum number of incorrect characters in the word
  • Max error percentage– the percentage of errors allowed in the word (calculated as a ratio of the number of errors in the hypothesis to the total number of characters in the hypotheses)

If the number of errors exceeds the set threshold, the detected object will not be considered a valid hypothesis. The greater the number of errors, the poorer the quality of the hypothesis. Since the number of characters in the object is not known in advance and depends on what images are processed, the program will use either the threshold set in absolute numbers or the threshold set in percentage points. When formulating and evaluating a hypothesis, the program will use the more stringent of the two conditions, i.e. if the detected object meets one criterion but does not meet the other criterion, the object will not be considered a valid hypothesis.

A Static Text hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Keyword | Lists the found keywords which you set in the Search text field. For each word, the program shows the number of errors.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relationss field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Static Text

Search area

Additional search constraints


Hypotheses for Separator elements

When formulating these hypotheses, the program will consider only the Separator objects detected during pre-recognition.

A Separator hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Orientation | The orientation of the detected separator.
Relative length | The length of the detected separator relative to the length of the search area.
Space length | The absolute length of the space within the detected separator.
Relative space length | The relative length of the space within the detected separator.
Orthogonal shift | The distance between the separator objects in one hypothesis, measured orthogonally to the orientation of the separators.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Separator

Search area

Additional search constraints


Hypotheses for White Gap elements

The program formulates White Gap hypotheses by creating the histograms of candidate objects.

By default, the program looks for a White Gap between Raw Text objects. To look for a White Gap between other types of object (e.g. between Separators), you need to write a corresponding constraint on the Properties dialog box of the White Gap element (Advanced tab, Advanced pre-search relations field). For example, if you need to find a White Gap in an area where all types of objects may occur, you need to write the following expression: Type: PictureObject + SeparatorObject+ AnyText + PunctuationMark + CheckMarkObject;.

A histogram is created as follows:

The program projects all the objects of a certain type which have been detected in the search area on the horizontal or vertical axis. The projection is a sum total of the objects' widths or heights. When looking for a horizontal gap, the program creates a projection on the vertical axis. When looking for a vertical gap, the program creates a projection on the horizontal axis; when looking for a horizontal gap, the program creates a projection on the vertical axis. The linear size of each object of the given size is added to the projection. For example, to find a vertical White Gap among the text objects, the program sums up the heights of all the text objects located in the search area above a particular point on the horizontal axis and intersecting the search area of the element.

Then the program looks for regions where the height of the histogram is less than a particular value. These regions will correspond to areas in which the number of objects is relatively small and their projection is less than a certain pre-defined value. The program must allow a certain number of objects to be present in the White Gap because real images often contain speckles and other noise introduced during scanning and which must be ignored when looking for gaps between columns or paragraphs. Background noise does not much affect the overall profile.

Suppose we have text objects H1, H2, ..., H9 in the search area. In the figure below, these objects are highlighted in black. Let the search contain other types of objects (highlighted in red).

To find the vertical White Gap, we need to find the sum up the projections of the text objects on the horizontal axis. The resulting histogram is shown in the figure below. You can see that non-text objects are ignored in the histogram.

Next, we need to find the histogram Maximum (marked as Max in the figure). The value of the maximum level is then multiplied by the value set in Threshold coefficient (%) (K=0.2). The result is the maximum allowed level of the White Gap (marked as White Gap threshold in the figure). If the resulting White Gap threshold>0, other objects may be present in the area of the White Gap.

Once the White Gap threshold has been calculated, it is compared with the values set in Lower threshold limit and Upper threshold limit. If White Gap threshold<Lower threshold limit, the White Gap threshold is assigned the value of the Lower threshold limit and this value will be used to look for the White Gap. If White Gap threshold>Upper threshold limit, the White Gap threshold is assigned the value of the Upper threshold limit.

Next, the heights on the histogram are compared with the White Gap threshold in order to find areas where the level of the histogram is less than the White Gap threshold.

The Min width/height property sets the minimum absolute width of the White Gap. If the value is W2, the two other hypotheses will be discarded.

A White Gap hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Orientation | The orientation of the detected White Gap.
Histogram maximum in search area | The peak of the histogram in the search area.
White Gap threshold | The point in the histogram below which the program starts formulating White Gap hypotheses.
Histogram maximum within hypothesis | The peak of the histogram maximum within the hypothesis.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

White Gap

Search area

Additional search constraints


Hypotheses for Barcode elements

The program formulates Barcode hypotheses by considering the Barcode objects detected during pre-recognition.

A Barcode hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Text | The recognized value of the barcode.
Type | The type of the detected barcode.
Orientation | The orientation of the detected barcode.
Number of suspicious symbolsuncertain characters | The number of unreliably recognized characters.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Barcode

Search area

Additional search constraints


Hypotheses for Character String elements

If a regular expression has been specified in the properties of an element, the program will look for any strings in the search area that meet the conditions in the regular expression. If no regular expression has been specified, the program uses the user-defined alphabets.

The program considers all the text objects which horizontally intersect the search area (vertically the objects must fit within the search area in their entirety). The text objects are then grouped into lines. Lines are built left to right. The program stops building a line when the maximum length of space (set in the Max space length property) is exceeded.

In the resulting lines, the program identifies character strings, each of which contains characters only from one of the user-defined alphabets. In a similar fashion, the program divides lines into fragments.

Next, the program formulates a hypothesis for each of the fragments. Depending on whether the Allow embedded hypotheses option is selected or not, hypothesis are formulated on two different principles.

Suppose the program detected three fragments at a previous stage. If the Allow embedded hypotheses option is selected, hypotheses are formulated as follows:

hypothesis 1: fragment 1
hypothesis 2: fragment 1 + fragment 2
hypothesis 3: fragment 1 + fragment 2 + fragment 3
hypothesis 4: fragment 2
hypothesis 5: fragment 2 + fragment 3
hypothesis 6: fragment 3

For each hypothesis, the program will check that the portion of characters of each alphabet does not exceed the value set in the Percentage of alphabet characters field. Similarly, the program checks that the percentage of non-alphabet characters does not exceed the value set in the Percentage of non-alphabet characters field. If it least one of the checks fails, no hypothesis is formulated.

If the Allow embedded hypotheses is not selected, the embedded hypotheses in the list above will be discarded. Embedded hypotheses are those which are contained within another hypothesis in the list above. If the checks were successful for all of the hypotheses, only the following hypothesis will remain: fragment 1 + fragment 2 + fragment 3.

Thus, if the Allow embedded hypotheses option is not selected, the program formulates hypotheses of maximum length which meet all of the conditions. Even though embedded hypotheses are excluded, hypotheses may intersect. This may be a stand-alone character or word, or a string of characters which are part of other hypotheses but for which no separate hypotheses have been formulated. For example, the program may formulate two hypotheses (i.e. two strings) - one ending in a certain word or phrase and another starting with that word or phrase.

E.g.

hypothesis 1: fragment 1 + fragment 2
hypothesis 2: fragment 2 + fragment 3

Once all the possible hypotheses have been generated, the program calculates the Pre-search quality for each (this is an estimate of how well a hypothesis meets the search constraints set in the Properties dialog box on the Character String tab and on the Advanced tab in the Advanced pre-search relations field). At this stage, the quality is calculated based on whether the length of the hypothesis in characters falls within the fuzzy interval specified in the Character count property, on whether the length of the total gap in the line falls within the fuzzy interval specified in TotalGapLength, and on whether the number of words in the line fall within the fuzzy interval specified in the Word count property.

The overall quality of a hypothesis is calculated by multiplying all the qualities.

A Character String hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Text | The characters in the hypothesis.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Character String

Search area

Additional search constraints


Hypotheses for Text Fragment elements

A Text Fragment hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Text | The text in the hypothesis.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Text Fragment

Search area

Additional search constraints


Hypotheses for Date elements

The program formulates Date hypotheses by considering the dates detected in the search area if they are written in the specified format. The expected format of the date is set in the element’s properties.

A Date hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Day | The day in the detected date.
Month | The month in the detected date.
Year | The year in the detected date.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Date

Search area

Additional search constraints


Hypotheses for Object Collection elements

The program formulates Object Collection hypotheses by considering all the objects in the search area which meet the properties and search criteria specified for the element.

An Object Collection hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Object Collection

Search area

Additional search constraints


Hypotheses for Group elements

Elements may be grouped together to form Group elements. This allows the program to consider the grouped elements as one entity for which it has already formulated a single hypothesis (which actually consists of the hypotheses for each constituent element). The program examines the combinations of hypotheses for the constituent elements of the group and selects only the best (their number is set by the user). These hypotheses are then used to formulate hypotheses about subordinate elements.

Note: The tree of elements itself may be regarded as one Group element.

A Group element allows you to create a single search constraint for all the constituent elements. The search area for a particular constituent element will be the intersection of the search area specified for the constituent element and the search area specified for the entire group.

Important!
The intersection of the search area of a constituent element and the search area of the group may be empty. If the intersection is empty, the constituent element will not be found. Therefore, we recommend either specifying only simple relations for Group elements, e.g. "Above: PageRect.Top + PageRect.Height/2;" (= look for the element in the upper half of the image), or not specifying any relations at all, so as to avoid any contradictions between relations describing the search area of the group and relations describing the search area of a constituent element.

A Group hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Group elements

Search area

Additional search constraints


Hypotheses for Phone elements

The program formulates Phone hypotheses by considering the Phone objects detected during pre-recognition and having the format specified in the corresponding Phone element.

A Phone hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Number | The detected telephone number.
Prefix | The found phone prefix.
Prefix rect. | The coordinates of the rectangle which surrounds the region of the phone prefix.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Phone

Search area

Additional search constraints


Hypotheses for Currency elements

The program formulates Currency hypotheses by considering the Currency objects detected during pre-recognition and having the format specified in the corresponding Currency element.

A Currency hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Value | The detected numerical value.
Currency name | The found currency name.
Currency name rect. | The coordinates of the rectangle which encloses the region of the currency name.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Currency

Search area

Additional search constraints


Hypotheses for Table elements

The program looks for tables and divides them into columns and rows by relying on the Separators and White Gaps on the image. Additionally, table headers and footers are used to facilitate table detection. Headers and footers serve as top and bottom boundaries for table bodies, No information is extracted from them. The header contains the names of the columns which may be used to divide the table into columns. Once a table has been detected, the program formulates hypotheses for the entire table element, its columns, rows, and cells.

A Table hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Header found | Shows whether the table header has been found.
Footer found | Shows whether the table footer has been found.
Body found | Shows whether the table body has been found.
Order name | The name of the detected order of columns in the table.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

A Table header hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Column name list | Shows the found table columns.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

A Table footer hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

A Table body hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Order name | Shows the name of the found column order.
Found columns | Shows the names of the found columns.
Rows number | Shows the number of rows found in the table.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Working with tables

Search area

Additional search constraints


Hypotheses for Repeating Group elements

A Repeating Group hypothesis has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which which the element was detected.
Surrounding rect | The coordinates of the rectangle which surrounds the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Detected | Shows whether the object described by the element has been found (true) or whether a null hypothesis has been formulated (false).
From the best path | Shows whether the found hypothesis belongs to the best path in the tree of hypotheses (true) or not (false).
Pre-search quality | How well the hypothesis matches the properties of the element specified by the settings in the Properties dialog box and by the code in the Advanced pre-search relations field.
Post-search quality | The quality of the hypothesis after the conditions in the Advanced post-search relations field have been applied.
Chain quality | The quality of the chain of hypotheses, from the first subelement of the group to the current subelement. Chain quality is calculated by multiplying the qualities of all the subelements in the chain and is used to compare rival chains of hypotheses.

More

Repeating Group elements

Search area

Additional search constraints


How hypotheses for Labeled Field elements are generated and assessed

A Labeled Field element is a compound element with pre-defined components. Hypothesis for this element are generated and assessed in the same way as for Group element.

A hypothesis generated for a Labeled Field element has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which the element has been detected.
Surrounding rect | The coordinates of the surrounding rectangle that encloses the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Detected | Indicates whether the area of the element has been detected (True) or a null hypothesis has been generated (False).
From the best path | Indicates whether the hypothesis belongs to the best path in the tree of hypotheses (True) or not (False).
Pre-search quality | Indicates the quality of the hypothesis required for the hypothesis to satisfy the properties of the element, specified either directly or via Advanced pre-search relations.
Post-search quality | Indicates the quality of the hypothesis required for the hypothesis to satisfy the conditions in Advanced post-search relations.
Chain quality | Indicates the current quality of the segment of the chain of hypotheses, from the first subelement of the current group to and including the current subelement. The quality of the chain is calculated by multiplying the qualities of all the subelements in the chain. Chain quality makes it possible to compare rival chains.

The hypotheses generated for subelements have all of the above properties supplemented with the following properties.

LabeledField.Name subelement

Property | Description
Keyword | Indicates the keywords included in the hypothesis. For each keyword, the number of errors is indicated.

LabeledField.Gap subelement

Property | Description
Orientation | Indicates the orientation of the detected gap.
Histogram maximum in search area | Indicates the histogram maximum in the search area.
White Gap threshold | Indicates the calculated threshold to treat the gap as detected.
Histogram maximum within hypothesis | Indicates the histogram maximum in the region of the gap hypothesis.

LabeledField.Field subelement

A hypothesis generated for this subelement may have different properties depending on the type of field:

Field type | Property | Description
Any text | Text | The text of the hypothesis.
Fixed variants | Keyword | The keywords included in the hypothesis. For each keyword, the number of errors is indicated.
Number | Text | The text of the hypothesis.
Currency | Value | The detected numerical value.
 | Currency name | The detected name of the currency.
Date | Day | Day.
 | Month | Month.
 | Year | Year.
Phone | Number | The detected telephone number.
 | Prefix | The detected telephone prefix.
Regular expression | Text | The text of the hypothesis.

More

Search area

Additional search constraints


Hypotheses for Region elements

When generating hypotheses for a Region element, any objects that fall within the search area are ignored.

A hypothesis generated for a Region element has the following properties:

Property | Description
Element name | The full name of the element.
Page | The number of the page on which the element has been detected.
Surrounding rect | The coordinates of the surrounding rectangle that encloses the region of the hypothesis.
Width | The width of the region of the hypothesis.
Height | The height of the region of the hypothesis.
Detected | Indicates whether the area of the element has been detected (True) or a null hypothesis has been generated (False).
From the best path | Indicates whether the hypothesis belongs to the best path in the tree of hypotheses (True) or not (False).
Pre-search quality | Indicates the quality of the hypothesis required for the hypothesis to satisfy the properties of the element, specified either directly or via Advanced pre-search relations.
Post-search quality | Indicates the quality of the hypothesis required for the hypothesis to satisfy the conditions in Advanced post-search relations.

More

Search area

Additional search constraints


Tree of hypotheses

When matching each layout alternative with an image, the program successively generates hypotheses for each of the elements. Hypotheses for the elements are generated one by one: from the first (topmost) element in the tree to the last (bottom) element. From the generated hypotheses, a tree of hypotheses is built. If the layout alternative is successfully matched with the image the tree of hypotheses is displayed in the Hypotheses window. If more than one layout alternative match the image, the tree of hypotheses for the first alternative is displayed. If none of the alternatives can match the image, the tree of hypotheses for the first alternative is displayed.

Note: The number of hypotheses created for an element may exceed the number set in the Number of surviving hypotheses field. In this case, only the user-defined number of the best hypotheses will make it into the tree of hypotheses.

In the tree of hypotheses, the program will then look for the best path, i.e. the best-quality path to the hypotheses of the last element. The quality of the path is calculated by multiplying the hypotheses for the elements in this path.

The hypotheses in the best path are used to detect the blocks.

The tree of hypotheses is displayed in the Hypotheses window. To view the tree of hypotheses for a particular image:

  1. Open the image.

  2. Match the FlexiLayout with the image (select Match from the Image menu or from the shortcut menu).

To view the hypotheses for elements which are part of a Group element:

  1. Select the hypothesis for the Group element.

  2. Press Enter or select the Show Details command from the shortcut menu.

To go one level up, press Ctrl+Enter or select the Go One Level Up command from the shortcut menu.

Note: The tree of hypotheses built for the current image is deleted when you close that image. The best path (the chain of hypotheses that was used to build the Matched Layout) is preserved. You can view these hypotheses when you open the image again. The program does not store the entire tree of hypotheses, because it may take up too much memory.

The tree of hypotheses consists of the following parts:

The left-hand column contains the elements of the first nesting level in the order in which they go in the FlexiLayout tree.

The right-hand column contains hypotheses generated for each of the elements. Each hypotheses is marked with an icon. The hypotheses are joined by thin lines which show the order in which they were generated. The hypotheses in the best path are joined by green lines, other hypotheses are joined by gray lines.

Icon | Description
 | A hypothesis from the best path.
 | A hypothesis not from the best path.
 | A null hypothesis from the best path.
 | A null hypothesis not from the best path.
 | An incomplete chain of hypotheses for a Group element (Group, Repeating Group, Header, Footer). You can view an incomplete chain of hypotheses to locate a non-detected element.
, [image] , [image] , | The branch of the element displays the hypothesis from the best path. To view all the hypotheses, press "+" or select Expand Active in the shortcut menu.
, [image] , [image] , | Displays all the hypotheses in the branch of the element. To hide the hypotheses which are not from the best path, press "-" or select Collapse Active in the shortcut menu.
, [image] , [image] , [image] , | The sub-branch of hypotheses for the element was discontinued at this point.


Debugging the FlexiLayout

We recommend debugging your FlexiLayout as you add blocks and elements to it. To test a FlexiLayout, build it and match it with all the test images. Check that the FlexiLayout has no errors and that it enables the program to detect all of the objects and blocks.

A FlexiLayout may fail to find elements or blocks on an image because the searched object is outside the search area or does not match the parameters specified for the element. Therefore, debugging a FlexiLayout consists in finding images with errors, adjusting the description, and re-applying it to the images. A corrected FlexiLayout must be applied both to problem pages (to make sure that the error has been rectified) and to the rest of the pages (to make sure that your corrections have had no adverse effect on them).

Additionally, when you add new elements, be sure that they are matched correctly on all the pages of the test batch. This means that you will review the results of matching many times while your are creating a FlexiLayout. If there are several dozen images in the batch, this procedure may be very tiresome. To make debugging your FlexiLayout easier, you can create a so-called Reference layout, i.e. the layout you consider to be correct and which you wish to use as a benchmark. When matching your FlexiLayout with a page for which a Reference layout is available, the program will automatically detect the differences between the benchmark and the matching results (Matched layout). The difference between the Reference layout and the Matched layout is represented as a percentage ratio of the areas of the blocks of each layout. You must aim to make Matched layout as close to Reference layout as possible. A complete match of Matched layout and Reference layout corresponds to the value of 0% in the Missing Areas and Excess Areas columns in the Batch window. The higher the percentage points in these columns, the worse the match.

You can use a reference layout to debug your FlexiLayout.

Tip: You can disable an element when testing a FlexiLayout (FlexiLayout>Disable). You can also hide an active block or element on the image (Image>Hide Active Blocks or Elements).

More

Building a FlexiLayout

Matching a FlexiLayout

Reference layout

Disabling an element

Testing elements


Building the FlexiLayout

When the program builds a FlexiLayout, it checks the FlexiLayout for errors.

The program will check:

1. The properties of the elements and search constraints.

  • The properties of an element and its search constraints may link only to the elements which are located above this element in the FlexiLayout tree. If the program detects an element that does not meet this requirement, the faulty element will be highlighted.

2. The properties of the blocks. Blocks may not refer to non-existent or disabled elements.

3. The expressions written in the FlexiLayout language (Advanced tab).

  • The code of the expressions must have no syntax errors.
  • Additional constraints set on the Advanced tab in the Advanced pre-search relations field must refer only to the elements located above the given element in the FlexiLayout tree. Additional constraints set on the Advanced tab in the Advanced post-search relations field must refer only to the element itself and to elements located above the given element in the FlexiLayout tree. If the program detects an element that does not meet this requirement, the faulty element will be highlighted.
  • All the global constants used in the code must be specified.
  • All the variables used in the code must be declared and initialized.
  • The code may refer only to entities available in the corresponding sections of the code.
  • The properties of blocks may refer only to the regions of elements.
  • For an element of a particular type, you can specify only properties available for this type. For example, you cannot specify Max width for a Static Text element.

Note: A FlexiLayout is built automatically when you match it with an image and when you save it.


Matching the FlexiLayout with images

When the program matches a FlexiLayout with an image, it attempts to detect objects on the image which correspond to the elements and uses the detected objects to draw blocks on the image.

The program will go down the FlexiLayout tree trying to find all the objects described by the elements and then draw blocks using the search constraints specified in the FlexiLayout.

Example:

Suppose we have a Group element A (which consists of simple elements a and b and a Group element B) and simple elements c and d. Elements A, c and d have the same nesting level. Now when the program matches this FlexiLayout with an image, it will look for objects corresponding to these elements in the following order: a, b, aa, bb, c, and d.

Element A

Element a

Element b

Element B

Element aa

Element bb

Element c

Element d

If the program finds all the objects corresponding to all the non-optional elements (and the objects which the program fails to find were marked as optional), the FlexiLayout will be matched successfully. If the program fails to find at least one object corresponding to a non-optional element, the matching process will be stopped and you will need to adjust the FlexiLayout.

To match the FlexiLayout with an image/images:

  1. Select one or several images in the batch.
  2. Select the Match command from the Batch menu or from the shortcut menu.

To match the FlexiLayout with an image and view the tree of hypotheses:

  1. Open an image.
  2. Select the Match command from the Image menu or from the shortcut menu.


Reference layout

You can create a reference layout for each image in the batch. The reference layout shows the desired location of blocks on the image. You can create a reference layout manually or by using the results of matching the FlexiLayout. You can edit a reference layout by adding or removing blocks, changing their sizes and locations, etc.

Reference layouts are used when debugging FlexiLayouts, as it allows you to compare the results of matching your FlexiLayout with the desired block locations on each of the images.

Reference layouts are created in Reference layout mode. Click [image] on the toolbar to switch to the Reference Layout mode.

The Difference mode( [image] button on the toolbar) displays the difference between the reference layout and the results of matching the FlexiLayout. Areas which are present in the blocks of the reference layout but are absent in the blocks detected by matching the FlexiLayout (Missing Areas) are highlighted in red. The areas which are absent in the blocks of the reference layout but present in the blocks detected by matching the FlexiLayout (Excess Areas) are highlighted in green. The Batch window displays the percentages of Missing Areas and Excess Areas.

To create a reference layout manually:

  1. Open the image for which you wish to create a reference layout.
  2. Match the FlexiLayout with the image.
  3. Switch to Reference layout mode.
  4. Draw the required blocks on the image. (Use the Block-Drawing Tools.)
  5. Click [image] on the toolbar to save the reference layout.

To create a reference layout on the basis of a matched FlexiLayout::

  1. Open the image for which you wish to create a reference layout.
  2. Match the FlexiLayout with the image.
  3. Select Copy Matched Layout to Reference from the Image menu or from the shortcut menu.
  4. Adjust the locations of the blocks if required.
  5. Click [image] on the toolbar to save the reference layout.

You can also use the Copy Matched Layout to Reference command from the shortcut menu of the batch to save as a reference layout the results of matching the FlexiLayout with selected batch pages.

Reference layout tools

The commands for creating and editing blocks can be found in Page>Select Tool. The buttons corresponding to these commands can be found on the toolbar.

Select ( [image] button on the toolbar) selects an existing block on the image and moves its borders.

To move a block border:
  1. Click the Select tool on the toolbar or select it in Page>Select tool.
  2. Place the mouse pointer on the block border you wish to move.
  3. Hold down the left mouse button and drag the border in the required direction.
  4. Release the mouse button.

Note: If you place the mouse pointer in the corner of the block, dragging the mouse will move both the vertical and horizontal block borders.

To move a selected block:
  1. Click the Select tool on the toolbar or select it in Page>Select tool.
  2. Place the mouse pointer on the desired block. The mouse pointer will change its shape, indicating that you can move the block.
  3. Hold down the left mouse button and drag the border in the required direction.
  4. Release the mouse button.

Tip: Sometimes a block may be too small to be moved, as its borders are very close to one another and pointing the mouse on any of them will activate the "change size" mode. Hold down the Ctrl key to move such blocks.

Create Block ( [image] button on the toolbar) creates a new block on the image.

To create a new block:
  1. Click the Create Block tool on the toolbar or select it in Page>Select tool.
  2. Place the mouse pointer in the corner of the future block. Hold down the left mouse button and drag the corner diagonally in the required direction.
  3. Release the mouse button.
  4. In the Create Block dialog box, enter a name for the new block.
Delete Block ( [image] button on the toolbar) deletes a block form the image.

To delete a block:
  1. Click the Delete Block tool on the toolbar or select it in Page>Select tool.
  2. Click the block you wish to delete.
Add Block Part ( [image] button on the toolbar) adds a rectangular area to the selected block.

To add a rectangular area to a block:
  1. Click the Add Block Part tool on the toolbar or select it in Page>Select tool.
  2. Place the mouse pointer inside the block to which you wish to add a rectangular area.
  3. Hold down the mouse button and drag the pointer diagonally in the required direction.
  4. Release the mouse button.

The rectangle will be added to the block.

Cut Block Part ( [image] button on the toolbar) cuts out a rectangular area from the selected block.

To cut out a rectangular area from a block:
  1. Click the Cut Block Part tool on the toolbar or select it in Page>Select tool.
  2. Place the mouse pointer inside the block from which you wish to cut a rectangular area.
  3. Hold down the left mouse button and drag the pointer diagonally in the required direction.
  4. Release the mouse button.

The rectangle will be cut from the block.

Note: When you cut out top or bottom block areas, the program will also cut out the adjoining right-hand up to the border of the block. This is done because only continuous text blocks may be recognized by the OCR engine. This constraint does not apply to left- and right-hand areas.

Add Vertical Separator ( [image] button on the toolbar) adds a vertical separator to the selected table block.

To add a vertical separator:
  1. Click the Add Vertical Separator tool on the toolbar or select it in Page>Select Tool.
  2. Rest the mouse pointer over the desired location in the Table block. The mouse pointer will change its appearance.
  3. Click the block.
Add Horizontal Separator ( [image] button on the toolbar) adds a horizontal separator to the selected table block.

To add a horizontal separator:
  1. Click the Add Horizontal Separator tool on the toolbar or select it in Page>Select Tool.
  2. Rest the mouse pointer over the desired location in the Table block. The mouse pointer will change its appearance.
  3. Click the block.
Delete Separator ( [image] button on the toolbar) deletes a separator from the selected block.

To delete a separator:
  1. Click the Delete Separator tool on the toolbar or select it in Page>Select Tool.
  2. Rest the mouse pointer over the desired location in the Table block. The mouse pointer will change its appearance.
  3. Click the block.
Block columns shortcut menu.

To create a reference layout fro columns of a Table block:
  1. Select the Table block on the image.
  2. Use the [image], [image], [image] tools to divide the block into cells.
  3. Right-click the column and select the name of the column from the shortcut menu.

To delete a column from a Table block, right-click the column and select Delete Column form the shortcut menu.


Reference document assembly

You can create a reference assembly which tells the program how exactly the pages should be assembled into documents.

A reference assembly, like a reference layout, is used to debug a FlexiLayout. It allows you to compare how pages are assembled into documents based on your FlexiLayout with a reference assembly which is known to be correct.

You can view the reference assembly in Reference layout viewing mode. Click the [image] button on the toolbar to activate the mode.

Activate the Difference viewing mode ( [image] button on the toolbar) to review the differences between the reference document assembly and the assembly obtained by means of your FlexiLayout. The beginning and the end of the document specified in the reference assembly but not detected by the current FlexiLayout will be indicated by red markers in the corners. The beginning and end of the document detected by the FlexiLayout but not specified in the reference assembly will be indicated by green markers in the corners.

To create a reference document assembly:

  1. In the Batch window, select the desired pages.
  2. Right-click the selection and select Assemble to Reference Documents… on the shortcut menu.
  3. In the Assemble to Reference Document dialog box, select how the pages must be grouped into documents: you can either assemble all the selected pages into one document (select One document) or specify the number of pages in a document (select Group by page count and type in the number of pages in a document).
  4. Select First page of document matches Header if the Header element must be matched with the first page of a document. Do not select this option if no Header element is used to assemble documents (i.e. a set number of pages is used instead) or if there is no Header element on the selected pages or it cannot be reliably matched.
  5. Select Last page of document matches Footer, if the footer element must be matched with the last page of a document. Do not select this option if no Footer element is used to assemble documents (i.e. a set number of pages is used instead) or if there is no Footer element on the selected pages or it cannot be reliably matched.
  6. Click OK. The reference assembly will be displayed in Reference layout viewing mode: the beginning and end of the document will be indicated by green markers in the corners.

You can clear the First page of document matches Header and Last page of document matches Footer options for individual pages (e.g. if there is no footer in a document) - the pages will still be assembled (the program will detect the end of the document based on the Header element detected on the first page of the next document).

To select/clear the First page of document matches Header and Last page of document matches Footer options:

  1. Select the desired page(s).
  2. right-click the selection and select Change Reference Header/Footer… on the shortcut menu.
  3. Select or clear the First page of document matches Header and Last page of document matches Footer options.

Information about the reference assembly is also displayed in the Reference Document Number and Reference Sequence Number columns in the Batch window. The Reference Document Number column displays the number of the document to which the page belongs and the Reference Sequence Number columns displays the number of the page in the document. The letters H or F in brackets show whether the Header or Footer element must be matched with the page.

The Matched Document Number and Matched Sequence Number columns display similar information for a matched FlexiLayout. You must aim to create a FlexiLayout whose Matched Document Number and Matched Sequence Number columns coincide with the Reference Document Number and Reference Sequence Number columns of the reference assembly.


Disabling an element

Sometimes, when debugging a FlexiLayout, you may need to disable an element without removing it from the FlexiLayout tree. In this case you may disable such element. All the information about the element will be stored in the FlexiLayout, but it will be ignored during the matching process.

Note: If the disabled element is referred to by other elements, these elements will be marked with an error icon. In this case, you can either disable the dependent elements, or delete the references to the disabled elements in their properties.

To disable an element:

  1. Select the element in the FlexiLayout tree.
  2. Select the Disable command from the FlexiLayout menu.

To enable an element:

  1. Select the element in the FlexiLayout tree.
  2. Select the Enable command from the FlexiLayout menu.


Testing elements

During the FlexiLayout matching the program analyzes only those hypotheses for each of the elements whose quality meets the specified parameters.

Testing allows you to view all the hypotheses generated for the selected element on the current test image. You can test any element, including Group elements. The search area of the tested element is the entire page unless you have specified additional search constraints in the Absolute search area constraints or Advanced pre-search relations. Advanced pre-search relations are also taken into consideration when testing the element. As a result, the Hypotheses window displays all generated hypotheses rated by their quality (from best to worst), and in the Image window the areas of all detected hypotheses are highlighted.

Note: The FlexiLayout to be tested must not contain errors, and the image must be opened in the Image window.

To test an element:

  1. Select the desired element in the FlexiLayout tree.

  2. In the shortcut menu of the desired element, select the Test Element command or select the Test Element command in the FlexiLayout menu. Use the Test Header and Test Footer commands to test the Header and Footer elements respectively.

Tip: To switch from one hypothesis to another in the Hypotheses window, you may use the → and ← keys on your keyboard.

To quit test mode and switch to any other mode (Matched layout, Reference layout, Difference), click a corresponding button on the toolbar.


Classifiers

Classifier is a separate FlexiLayout intended for preliminary identification of individual pages and classifying them based on the FlexiLayout (including those having multiple alternatives) or based on a layout alternatives.

Classifiers are useful in projects with very many FlexiLayouts where the parent document of a page must be quickly and reliably identified. A classifier can quickly identify the first pages of a document based on a group identifying element.

Classifiers may be used for the following:

  • To debug the Headers of all documents in one FlexiLayout Studio project.
  • To speed up the selection of a document definition to be matched. The use of a classifier prevents going through all document definitions one by one in search fro the best match. Instead, the program can select the matching document definition based on the classifying attributes. The order of the search is determined by the user, who select the appropriate classifying attributes and builds a classifier tree. Speed gains are most noticeable in large projects with large numbers of document definitions.
  • To arrange the classifying attributes in the classifier tree. In the topmost node, you can select documents coming in from a certain company based on the presence of a field carrying the name of the company. In the next node, you can classify documents based on their titles or, say, the number of separators on a page.
  • To control the matching of third-party FlexiLayouts. It may happen that FlexiLayouts developed by a third party are matched incorrectly with the wrong documents. In this case, you can use a classifier to control the matching of document definitions without contacting the developer.
  • To speed up projects that contain document definitions in different languages. If a classifier is used, instead of using all the languages of all the document definitions in the project, the program will pre-recognize the documents twice: first, when classifying them and then when matching them with the selected document definition.

Within a project, a hierarchy is created whose nodes represent classification stages (i.e. classes). Each classification stage contains a set of identifier elements. In the course of classification, the program tries matching the sets of identifier elements, one by one, with each page in the batch. If a set matches a particular page, the page is deemed to belong to the corresponding class. The classification results (the name of the FlexiLayout or layout alternative) are saved in the properties of the page.

The classification stages form a hierarchy. For example, you can group documents from a particular company into a class of their own, and describe the various types of documents from this company as its subclasses. Then, at the first classification stage, you will be able to use the Static Text identifier element containing the name of the company, and at the second stage, define the Invoice, Letter, etc. subclasses.

The set of identifiers of a class is an obligatory compound element Id, which, in turn, may include required, optional, and prohibited elements. Additionally, you can specify the minimum number of detected subelements to consider the compound element detected.

Uniqueness of classification stages

Each classification stage is assigned a degree of uniqueness. The uniqueness of a stage is indicated by the following icons:

  • Uniquely in project ( [image]) - the classification stage is unique within the classifier (i.e. is globally unique). These stages should be used if you can select a good identifying element for the document type. Documents of this type will be classified quickly and reliably. The Id element in this node unambiguously identifies the document type, i.e. it contains all the distinguishing features of the type. If the identifying element used in this stage has been matched successfully, the other stages can be skipped.
  • Uniquely on its tree level ( [image]) - the classification stage is unique within the previous stage (i.e. is locally unique). As a rule, these stages are used to distribute the identifying features among the parent and child stages. The identifying element of a locally unique stage distinguishes document types within the parent stage. Therefore, in the identifying element of the parent stage you can place the features common to all the document subtypes (e.g. "Name_of_Company_1"), and in the Id elements of its substages you can place only the features that distinguish the subtypes from one another (e.g. the keywords "Agreement," "Invoice" or a separator grid characteristic of the subtype). At the same time, a neighboring node may exist with an identifying element that contains the "Name_of_Company_2" and similar subtypes with the keywords "Agreement," "Invoice," etc.
  • Non-uniquely ( [image]) - the classification stage is not unique or is not intended for identification (i.e. is to be used only to group subclasses). These stages are mainly used in order to group child elements. For example, documents from company A and company B do not bear the name of the company or do not have some other feature characteristic of all documents from this company but you need to group together the descriptions of different documents from these companies in separate folders for ease of use. Then you can create two non-unique stages and within these stages place unique classification stages whose identifying elements contain the required document features.

Order of classification

The classification is carried out stage by stage, starting from the root element. At each stage, classes are selected to which the document may belong (see below). Next, their subclasses are explored, etc. If, at some stage, there are no matching subclasses, the current class is added into the classification results.

The choice of class for subsequent matching is made as follows:

  1. The globally unique classes are matched (in the order in which they are defined in the classifier). If an identifier is matched successfully, the matching ends and the corresponding class is the only possible path to continue.
  2. The locally unique classes are matched (in the order in which they are defined in the classifier). If an identifier is matched successfully, the matching ends and the class is added to the set of possible paths.
  3. If there are no matching unique classes, non-unique classes are checked. All the matching non-unique classes are added to the set of possible paths.

For example, consider this classifier:

Classification starts from the root element, ClassificationTree. First, the program tries matching the FirstCompany identifier. If is matched successfully with a page, only the subclasses of this class will now be used. Otherwise, the program will start matching the classes SecondCompany and UnknownCompany. Either one of them or both may match, as these classes are not unique.

If a page is classified as belonging to the class FirstCompany, only its subclasses will be checked. The Invoice subclass will be checked first, as it is globally unique, whereas the Price subclass is only locally unique. If none of the subclasses match, the page is classified as FirstCompany. Next, consider what happens if the FirstCompany identifier does not match any pages.

If only one of the two classes matches, its subclasses are matched, one by one, as described above. If both classes match, the program tries matching the subclasses of each of the two classes:

  • If the SecondCompany.Invoice is a good match, the matching process ends and the page is classified as belonging to this subclass, as it is globally unique
  • If the subclasses of different classes are good matches (e.g. if both SecondCompany.Price and UnknownCompany.Price match), they both are added into the classification results.
  • If there are no matching subclasses in a class, the class itself is added to the classification results.

More

Classifier properties

Creating a classifier

Elements


Classifier properties

When creating a classifier, specify its properties:

Name - the name of your classifier; the default name is ClassificationTree

Version - the version of the classifier; this parameter allows you to create different versions of the same classifier and distinguish among them in the future

Comment - user's comment (optional); this field may contain any information about the classifier

Pre-recognition parameters (Text languages, Text type, Mode) - these parameters define pre-recognition

To select or view the properties of a classifier, select Properties… from the FlexiLayout menu (or select Properties… from the shortcut menu of the classifier's root element).

More

Pre-recognition

Pre-recognition parameters


Creating a classifier

To create a classifier, you must build a hierarchy of classes and specify a set of identifiers for each class.

Creating a new classifier project

To create a new classifier project:

  1. Select File> New Project...
  2. Select Classifier Project… A Create Project dialog box appears.
  3. Provide a name for your project and select a folder where to store project files.

Adding a class

To add a class:

  1. Activate the Classifier window.
  2. In the classifier tree, go to the level where you wish to add your new class (for the first level, select ClassificationTree).
  3. In the shortcut menu, select the Add Class item.
  4. Specify a name and properties for the new class:
    • In the ID element identifies document type section, specify the uniqueness of the node.
    • In the Use this FlexiLayout for identified document type field in the Use FlexiLayout for identified document type section, specify the name of the FlexiLayout or layout alternative in the format FlexiLayoutName.AlternativeLayoutName. The program will apply this FlexiLayout (or layout alternative) to any document that corresponds to this classification node.

Adding identifiers

When a new class is created, the application automatically creates an empty Group ID element. Identifier elements can be added, removed, or changed in the usual manner. An identifier may include any number of any elements with the exception of Table elements. You can also import the Header from an existing FlexiLayout Studio project to use it as an identifier. To import a Header, select Import ID… in the shortcut menu of the classifier node and specify the project from which to import the Header.

More

Debugging a classifier

Elements


Debugging a classifier

Debugging classifiers is similar to debugging FlexiLayouts with some minor differences.

Compiling a classifier

To build a classifier, select the Build Classifier item in the shortcut menu of the root element (ClassificationTree by default).

Reference classification

For each image in the batch, you can specify a reference classification. You can then compare any classification results you obtain against this reference classification and make changes to the classifier if necessary. To select the reference classification:

  • in the shortcut menu of the batch, select Copy Matched Layout to Reference and copy the appropriate classification result from the FlexiLayout Name column, or
  • in the shortcut menu of the batch, select Properties… and in the Page Properties dialog box, select Reference FlexiLayout name.

Viewing classification logs

Classification logs can be viewed in the Classifier log window. For each page, the following information is logged:

  • classifier matching results
  • the list of classes against which the page was matched and whether the match was successful

See also

Debugging the FlexiLayout


Exporting FlexiLayouts

FlexiLayouts can be exported into data capture applications as *.afl files. Exported FlexiLayouts are securely encrypted to prevent unauthorized use.

To export a FlexiLayout:

  1. Select the Export… command from the File menu.
  2. In the Export FlexiLayout dialog box, enter a name for the file and select the folder where it should be saved.

The resulting file can be added to an ABBYY FlexiCapture document template or used in other data capture applications.


Identifying and processing FlexiLayouts in ABBYY FlexiCapture

You can process an unlimited number of 'fixed' and 'flexible' templates in one FlexiCapture batch (a 'flexible' template is created from a FlexiLayout). If a batch contains several flexible templates, it is desirable to have the same pre-recognition parameters (i.e. language, text type, mode) in all the FlexiLayouts which are used to create the flexible templates. In this case, pre-recognition will be run only once and the pre-recognition results will be used for other templates. This will reduce the processing time, as pre-recognition usually takes up to 90% of the time required to match the template.

FlexiCapture runs pre-recognition on a page for each set of pre-recognition parameters specified in all of the flexible templates in the batch. If all the templates have the same pre-recognition language, pre-recognition is run only once, the detected objects are saved and used for the other templates in the batch. If one of the templates has a different pre-recognition language (or text type, or mode), FlexiCapture will need to pre-recognize the page twice, which will double the time required for template matching. For this reason, we recommend keeping the sets of pre-recognition parameters to a minimum.

In some cases, you can speed up FlexiLayout matching by skipping pre-recognition. This is possible if the FlexiLayout elements include only Separator, Barcode, White Gap, Region and Object Collection elements and all the White Gap and Object Collection elements meet one of the following requirements:

  • no text is specified in the element's search constraints
  • the UseRawText property of the element is true.

When fixed-layout forms and flexible-layout forms are processed within one batch, the program will attempt to match the fixed templates first. If the fixed templates are successfully matched with their forms, no FlexiLayouts are applied. If there are no matching fixed templates, the program will find suitable matches among the FlexiLayouts.

Classifiers

Classifiers are used to automate the selection of a FlexiLayout or a layout alternative. Classifier is a special project created in FlexiLayout Studio and imported to FlexiCapture. The project describes the tree-like structure of the classes to which a document may belong. Each class contains a set of elements that identifies a certain type of document. Upon classification, the names of the FlexiLayouts (or layout alternatives) to be used are saved in the properties of each classified page. For more information about classification projects, refer to Classifier project.

Selecting a FlexiLayout without the use of a classifier

If no classifiers are used, identifier elements are created in the FlexiLayout to make the selection of the appropriate FlexiLayout by FlexiCapture more reliable and to speed up the process itself. Practically any type of element can be used as an identifier. The only requirement is that it should be reliably detected on all of the forms of the given type. In practice, the most commonly used identifiers are Static Text, Barcode, and Character String elements. Sometimes more than one element are used to identify a form type.

The higher the identifier element in the FlexiLayout tree, the faster the template selection.

One way to create an identifier element is to clear the Optional element property - the object corresponding to the element must be present on all of the images. If the object described by the element is not detected, the template will not be matched with the image.

Additionally, you can identify a form by using the DontFind() function in the Advanced pre-search relations field. This will tell the program not to look for an optional element.

Another method of identifying a flexible template is to use the Quality property of the element hypothesis. Setting the Quality of any element to 0 in the Advanced post-search relations field (the corresponding code is Quality: 0;) will result in failure to match the template. Before setting the quality of an element to 0, you need to analyze the properties of the elements located above the current element in the FlexiLayout tree.


FlexiLayout language

The Advanced tab in the Properties dialog box has two fields where you can enter code written in a special FlexiLayout language. This language allows you to specify element properties, relations between elements, and set additional constraints for formulated hypotheses.


Lexical conventions

Identifiers

An identifier is a sequence of characters used to denote one of the following:

  • Block name
  • Element name
  • Constant name
  • Variable name
  • Keyword

Identifiers are case-insensitive.

Identifier Syntax

identifier :

nondigit
identifier nondigit
identifier digit

nondigit : one of

_ a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

digit : one of

0 1 2 3 4 5 6 7 8 9

Punctuators

. , ( ) * / + - = < > { } : ; ! & |

The punctuators ( ) and { } must appear in pairs.

Operator precedence and associativity

The highest precedence level is at the top of the table.

Operator | Meaning | Associativity
( ) | Function call |
: | Function call |
. | Member selection | Left to right
+ – | Unary positive Unary negative |
* / | Multiplication Division | Left to right
+ – | Addition Subtraction | Left to right
NOT | Logical NOT (unary) |
 | Comparison operations (have equal priority) |
< | Less than | Left to right
> | Greater than | Left to right
<= | Less than or equal to | Left to right
>= | Greater than or equal to | Left to right
== | Equality | Left to right
!= | Inequality | Left to right
AND | Logical AND | Left to right
OR | Logical OR | Left to right

Assignment operator

The "=" operator assigns a value to a variable.

For example:

Distance a;
a = Page( 1 ).RectGlobal.Width;

The data type of the expression must be compatible with the data type of the variable.

Constants

The FlexiLayout language uses only global constants. Global constants are set in the FlexiLayout Properties dialog box (see Global Constants) and can be accessed from any section of any block or element description.

Comments

You can add comments to the code. The comments have the same format as in the C language and can be written in one of the following ways:

  • The /* (slash, asterisk) characters, followed by any sequence of characters (including new lines), followed by the */ characters.
  • The // (two slashes) characters, followed by any sequence of characters. A new line not immediately preceded by a backslash terminates this form of comment.


Reserved keywords

The following table lists reserved keywords which cannot be used to name blocks, elements, constants, or variables.

AllInstances

and

AndElement

array

AttributeDefinitions

begin

bool

boolean

break

case

char

chose_if

class

const

continue

CurrentInstance

default

delete

div

do

double

Elements

else

end

EndOfAndElement

EndOfElement

EndOfOrElement

enum

error

explicit

extern

ExternalType

false

finally

FinalRelations

FlexibleTemplateHeader

float

for

Function

goto

if

Import

IndependentRelations

InitScript

inline

Instance

int

is

LastFound

let

like

long

mod

namespace

new

not

nothing

null

of

on

operator

or

OrElement

ParamDefinitions

Params

private

PrivateRelations

protected

public

RecognitionParams

RegionalDecimalPoint

register

Relations

return

set

short

sizeof

static

string

struct

switch

template

then

this

to

true

typedef

typeid

typename

unsigned

using

Variants

void

while

with

xor


Function-call operators

Function and method parameters are set in one of the following ways:

  • Using the "()" operator (parentheses)
  • Using the ":" operator (colon)

Parameters are separated by "," (comma).

If the list of arguments of a function or method is empty, you can omit the "()" operator. The ":" operator is not used in this case.

() | Mode( Horizontal ); MaxErrors( 2, 0.25 );
: | Mode: Horizontal; MaxErrors: 2, 0.25;
 | DonFind(); DontFind;


Statements

Statements are separated by ";" (semicolon).

One or more statements can be enclosed in curly braces to form a compound statement. Compound statements are commonly called "blocks" (not to be confused with FlexiLayout blocks).


Name scope

Names of elements, constants and variables can be used only in certain sections of a program. This is called the "scope" of the name. The scope of a variable also determines its lifetime.

The name of a variable declared in the Region expression, Advanced pre-search relations or Advanced post-search relations section is accessible within that section, and only after the point of declaration.

A name declared within a block is accessible only within that block and the blocks enclosed by it, and only after the point of declaration:

{
Int a; a = 5;
}

Element hypotheses can be accessed through the names of the elements. In the Advanced pre-search relations and Advanced post-search relations sections, you can access the hypotheses for all the elements which are located above the current element in the FlexiLayout tree. In the Advanced pre-search relations section, you can also access the hypothesis formulated for the current element itself. In the Region expression section of a block description, you can access the hypotheses for all the elements located on the "best branch" of the tree of hypotheses.

The code in the Advanced pre-search relations section is executed separately for each hypothesis independently of the hypotheses which are located on other branches of the tree of hypotheses. This means that when the program executes the code of a particular section of an element description, it can access only one hypothesis for each superordinate element, namely the hypothesis which is located on the same branch.

Element hypotheses and their properties are accessed in read-only mode.

Hypotheses for a superordinate element are called by the full name of the element, for example: SearchObjects.Group1.Group2.FirstItem. When accessing one subelement of a group from another subelement, you need not specify the name of the group. For example, in the Advanced… sections of the element SearchObjects.Group1.Group2.SecondItem, you can call the element SearchObjects.Group1.Group2.FirstItem in one of the following ways: SearchObjects.Group1.Group2.FirstItem, Group1.Group2.FirstItem, Group2.FirstItem, FirstItem.

The shortcut name will always refer to the most nested element.

Suppose we have the following tree of elements:

SearchElements

FirstItem

Group1

FirstItem
SecondItem

If you are in SearchElements.Group1.SecondItem and use the name FirstItem, you will call the SearchElements.Group1.FirstItem element, and not the SearchElements.FirstItem element.


Element fields

An element field is a typed variable that belongs to an element. Element fields are defined in the External fields section on the Advanced tab. The following format should be observed:

Type1 Name1;
...
TypeN NameN;

where Name is the name of the variable and Type is its type.

When fields are created, they are initialized as follows: numerical fields are initialized with zero values, rectangles and regions are initialized with empty values, etc.

Fields may be used in the element to which they belong and in any of the elements located below their element. The value of a field can be changed only in the element to which it belongs, and in other elements it is available as read only.

The value of a complex expression that characterizes the hypothesis for an element may be computed and written into this property. This value may be accessed from any of the elements below, without computing it each time it is needed. This reduces the time required to match the FlexiLayout. obviates the need to copy a large expression into each of the elements, and makes the code more readable.

To access a field of an element, the full name of the field is used in the following format: ElementName.FieldName (e.g. SearchElements.StaticText1.x). Within an element, its field may be accessed by name: x. In the case of a compound element, its subelements (at any level of nesting) may also access its elements by their short names.

Within an element, the names of the fields must be unique. The names of elements of a compound element may not coincide with any of the field names in its subelements (at any level of nesting). Additionally, the names of the fields of a compound element may not coincide with any of the names of its subelements.

Example

This example searches for two address components: city (character string City) and subway station (character string Station). The subway station is specified only if the city is Moscow. To speed up FlexiLayout matching, we specify a fromMoscow property for the City element. This property is true if the City element is detected and has the value Moscow, and false in all other cases.

Code for the City element:

User-defined properties
logic fromMoscow;

Advanced post-search relations
if( not IsNull and Value.Find( "Moscow" ) >= 0 ) then fromMoscow = true;
else fromMoscow = false;

Subsequently, we use this property to search for the subway station. To speed up the matching process, we search for the station only if Moscow is detected as the City element.

Code for the Station element:

Advanced pre-search relations
if not City.fromMoscow then dontfind;

Note: Because of the fields, elements of the same type are not treated as identical. Thus, constructions of the following type are prohibited:

Let e = SearchElements.StaticText1;
e = SearchElements.StaticText2; // element of the same type


Variables

You can create and use variables in any section where code is entered. The name of a variable cannot coincide with the name of a global constant or the name of an element.

Variables can be created in one of two ways.

  1. You can declare a variable by specifying its type and name.

    The syntax is as follows:

    [type name] [variable name];

    For example:
    Int a;
    String s;
    Logic isElementLongEnough;

    to call the value of a variable, you must first initialize it by using an assignment operator. Calling a variable that has not been initialized will result in an error during compilation or when executing the code.

  2. You can declare a variable and initialize it at the same time.

    You can declare and initialize a variable using an expression, e.g. an element name, an element property or another variable. The syntax is as follows:

    Let [variable name] = [expression]

    For example:
    Int a;a=3; Let a1 = a + 5;
    Let myElement = SearchObjects.Group1.Group2.FirstItem
    Let myRect = SearchObjects.Group1.Group2.FirstItem.Rect

    The system creates a variable with the specified name. The type of the variable is implicitly defined by the type of the expression it refers to. At the same time the variable is initialized using the value of the expression.

    Variables created using this method can be conveniently used as shortcut names for deeply nested elements and other objects to make the notation shorter.


Coordinates and units of measurement

Two dimensions – vertical and horizontal – are used to describe positions of objects on the page and distances between them. The (0,0) reference point is located in the top left-hand corner of the image. X-coordinates increase left to right, Y-coordinates increase top to bottom.

In a multi-page sheet there are two coordinate systems - a global coordinate system and local one. The former covers the entire multi-page sheet and all the objects on it and uses the top left corner of the first page as the origin of coordinates. The latter covers only one page and its objects and uses the top left corner of each page as the origin of coordinates.

Units of measurement for coordinates and distances:

Unit of measurement | Description
dot (dt) | 1/300 of an inch
inch (in) | inch
pt | paper point, 1/72 of an inch
mm | millimeter
cm | centimeter

Constants for distances can be represented using one of two formats:

Format | Example
A numerical value immediately followed by a unit of measurement | 5cm 200dot 4in
A numerical value followed by the multiplication operator followed by a unit of measurement. You can insert spaces between any members of the representation. | 5*mm 17 *dt 3 * inch


Predefined types

Type | Description
Void | Type Void is used to declare functions that return no value.
Logic | Boolean type. A variable of this type can have values true and false. All conditional expressions return a value of type Logic.
Operators |
Not | Logical NOT, unary operator.
And | Logical AND, binary operator.
Or | Logical OR, binary operator.
String | String type represents variable-length sequence of Unicode characters.
Methods |
Int Length() | Returns the number of characters in the string. Read-Only.
Int Find(String subStr, Int startPos = 0) | Returns the beginning of the substring subStr of the string. Starts the search from the startPos position. Can be used without the startPos argument, in which case it assumes the default value of 0. Returns -1 if the string does not include a startPos substring.
String Mid ( Int start, Int count ) | Returns a substring of the string which is 'count' characters long and starts with the character number start.
String Mid ( String subStr, Int startPos = 0 ) | Returns the beginning of the substring subStr of the string. Can be used without the startPos argument, in which case it assumes the default value of 0. Returns -1 if the string does not include a startPos substring.
Int Compare( String str ) | Compares the specified string with the string set by the argument. If the strings are equal, returns 0. If the given string alphabetically precedes str, the function returns -1, if the given string alphabetically follows str, the function returns 1.
Int CompareNoCase( String str ) | Compares the specified string with the string set by the argument ignoring the case of the characters. If the strings are equal, returns 0. If the given string alphabetically precedes str, the function returns -1, if the given string alphabetically follows str, the function returns 1.
Operators |
== | Checks if the two strings are equal. Binary operator. Returns a result of type Logic. Returns true if the strings are equal, otherwise returns false. Case-sensitive.
!= | Checks if the two strings are not equal. Binary operator. Returns a result of type Logic. Returns true if the strings are not equal, otherwise returns false. Case-sensitive.
+ | Concatenates two strings. Returns a value of type String.
Int | Integer type. Corresponds to a 32-digit integer.
Methods |
Int abs( Int ) | Returns the absolute value of an integer.
Operators |
- | Changes the sign. Unary operator.
+ | Adds integers. Binary operator.
- | Subtracts one integer from another. Binary operator.
* | Multiplies integers. Binary operator.
/ | Divides integers. Binary operator.
<, <=, >, >=, ==, != | Operators of comparison: less than, less than or equal to, greater than, greater than or equal to, equal to, not equal to. Binary operators. Return a value of type Logic.
Distance | Integer type (measured in dots) that represents distances.
Methods |
Distance abs( Distance ) | Returns the absolute value of a distance.
Operators |
- | Changes the sign. Unary operator
+ | Adds values of type Distance. Binary operator.
- | Subtracts values of type Distance. Binary operator
* | Multiplies a value of type Distance by a value of type Int. Binary operator. Returns a value of type Distance.
* | Multiplies values of type Distance. Binary operator. Returns a value of type Area.
/ | Divides a value of type Distance by a value of type Int. Binary operator. Returns a value of type Distance.
<, <=, >, >=, ==, != | Binary operators of comparison. Compare two values of type Distance: less than, less than or equal to, greater than, greater than or equal to, equal to, not equal to. Return a value of type Logic.
XCoordinate | Integer type used to represent X-coordinates.
Operators |
+ | Adds a value of type XCoordinate to a value of type Distance. Binary operator. Returns a value of type XCoordinate.
- | Subtracts a value of type Distance from a value of type XCoordinate. Binary operator. Returns a value of type XCoordinate.
- | Subtracts a value of type XCoordinate from a value of type XCoordinate. Binary operator. Returns a value of type Distance.
<, <=, >, >=, ==, != | Compares two values of type XCoordinate: less than, less than or equal to, greater than, greater than or equal to, equal to, not equal to. Binary operators. Return a value of type Logic.
YCoordinate | Integer type used to represent Y-coordinates.
Operators |
+ | Adds a value of type YCoordinate to a value of type Distance. Binary operator. Returns a value of type YCoordinate.
- | Subtracts a value of type Distance from a value of type YCoordinate. Binary operator. Returns a value of type YCoordinate.
- | Subtracts a value of type YCoordinate from a value of type YCoordinate. Binary operator. Returns a value of type Distance.
<, <=, >, >=, ==, != | Operators that compare two values of type YCoordinate: less than, less than or equal to, greater than, greater than or equal to, equal to, not equal to. Binary operator Return a value of type Logic.
Real | Real number
Operators |
- | Changes the sign. Unary operator
+ | Adds two real numbers. Binary operator.
- | Subtracts a real number from another real number. Binary operator.
* | Multiplies two real numbers. Binary operator.
/ | Divides by a real number. Binary operator.
<, <=, >, >=, ==, != | Compare two real numbers: less than, less than or equal to, greater than, greater than or equal to, equal to, not equal to. Binary operators. Return a value of type Logic.
Quality | Real number from 0 to 1. Represents the returned value of the methods controlling the quality of an element hypothesis.
Area | Integer type (measured in dot*dot) used to represent the area of an image region.
- | Changes the sign. Unary operator
+ | Adds two values of type Area. Binary operator.
- | Subtracts a values of type Area from another value of type Area. Binary operator.
* | Multiplies a value of type Area by a number of type Int. Binary operator. Returns a value of type Area.
* | Multiplies a value of type Area by a number of type Real. Binary operator. Returns a value of type Area.
/ | Divides by a number of type Int. Binary operator
<, <=, >, >=, ==, != | Compare two values of type Area: less than, less than or equal to, greater than, greater than or equal to, equal to, not equal to. Binary operators. Return a value of type Logic.
ImageObjectType | Type used to represent classified image objects.
Operators |
+ | Joins two values of type ImageObjectType.
DateFormats | Integer type used to represent the format of date.
Operators |
+ | Joins two values of type DateFormats.
DayFormatVariants | Integer type used to represent the format of day in the date.
Operators |
+ | Joins two values of type DayFormatVariants.
MonthFormatVariants | Integer type used to represent the format of month in the date.
Operators |
+ | Joins two values of type MonthFormatVariants.
YearFormatVariants | Integer type used to represent the format of year in the date.
Operators |
+ | Joins two values of type YearFormatVariants.
XInterval | Type used to represent a range of X-coordinates on an image.
Operators |
+ | Adds a value of type XInterval to a value of type Distance. Binary operator. Returns a value of type Xinterval.
+ | Adds a value of type XInterval to a value of type DistInterval. Binary operator. Returns a value of type Xinterval.
- | Subtracts a value of type Distance from a value of type XInterval. Binary operator. Returns a value of type Xinterval.
- | Subtracts a value of type DistInterval from a value of type XInterval. Binary operator. Returns a value of type Xinterval.
- | Subtracts a value of type XInterval from a value of type XInterval. Binary operator. Returns a value of type DistInterval.
- | Subtracts a value of type YCoordinate from a value of type YInterval. Binary operator. Returns a value of type DistInterval.
- | Subtracts a value of type YInterval from a value of type YCoordinate. Binary operator. Returns a value of type DistInterval.
Methods |
XCoordinate Start() | Returns the X-coordinate of the beginning of the interval. Read-only property.
XCoordinate End() | Returns the X-coordinate of the end of the interval. Read-only property.
YInterval | Type used to represent a range of Y-coordinates on an image.
Operators |
+ | Adds a value of type YInterval to a value of type Distance. Binary operator. Returns a value of type Yinterval.
+ | Adds a value of type YInterval to a value of type DistInterval. Binary operator. Returns a value of type Yinterval.
- | Subtracts a value of type Distance from a value of type YInterval. Binary operator. Returns a value of type Yinterval.
- | Subtracts a value of type DistInterval from a value of type YInterval. Binary operator. Returns a value of type Yinterval.
- | Subtracts a value of type YInterval from a value of type YInterval. Binary operator. Returns a value of type DistInterval.
Methods |
YCoordinate Start() | Returns the Y-coordinate of the beginning of the interval. Read-only property.
YCoordinate End() | Returns the Y-coordinate of the end of the interval. Read-only property.
DistInterval | Type used to represent the allowed range of distances.
Operators |
* | Multiplies a value of type DistInterval by a number of type Int. Binary operator. Returns a value of type DistInterval.
/ | Divides by a number of type Int. Binary operator
Methods |
Distance Start() | Returns the minimum distance. Read-only property.
Distance End() | Returns the maximum distance. Read-only property.
Rect | Rectangle on an image.
Constructors |
Rect Rect( XCoordinate left, YCoordinate top, XCoordinate right, YCoordinate bottom ) | Constructs a value of type Rect from coordinates on the image. The boundaries of the rectangle are passed as parameters: left – left boundary, top – top boundary, right – right boundary, bottom – bottom boundary.
Operators |
Or | Unites two rectangles. The result is the smallest rectangle which contains both rectangles.
And | Intersects two rectangles. The result is the largest rectangle which is contained in both rectangles.
Methods |
XCoordinate Left() | Returns the left boundary of the rectangle. Read-only property.
YCoordinate top() | Returns the top boundary of the rectangle. Read-only property.
XCoordinate Right() | Returns the right boundary of the rectangle. Read-only property.
YCoordinate Bottom() | Returns the bottom boundary of the rectangle. Read-only property.
Distance Width() | Returns the width of the rectangle. Read-only property.
Distance Height() | Returns the height of the rectangle. Read-only property.
Area Area() | Returns the area of the rectangle. Read-only property.
Void Left( XCoordinate x ) | Sets the left boundary of the rectangle.
Void top( YCoordinate y ) | Sets the top boundary of the rectangle.
Void Right( XCoordinate x ) | Sets the right boundary of the rectangle.
Void Bottom( YCoordinate y ) | Sets the bottom boundary of the rectangle.
XCoordinate XCenter() | The X-coordinate of the centre of the rectangle.
YCoordinate YCenter() | The Y-coordinate of the centre of the rectangle.
Void Inflate( Distance xDist, Distance yDist ) | Expands the rectangle by xDist to the left and to the right, and by yDist upwards and downwards.
XCoordinate GetX( Real ratio ) | Calculates the X-coordinate located within the rectangle between the Left and Right coordinates as Left + Width * ratio.
YCoordinate GetY( Real ratio ) | Calculates the X-coordinate located within the rectangle between the top and Bottom coordinates as top + Height * ratio.
Rect GetInflated( Distance xDist, Distance yDist ) | Returns an "expanded" rectangle. Each apex is shifted by xDist and yDist in the direction that expands the figure (the top left apex is moved upwards and to the left, etc.). -The rectangle itself remains unchanged.
Logic IsEmpty() | Checks if the rectangle corresponds to a non-empty region on the image, i.e. a region whose Left < Right and top < Bottom
FuzzyRect | Fuzzy rectangle. See Fuzzy_Rect for more
Operators |
And | Unites two fuzzy rectangles, i.e. unites the ranges of the boundaries of specified fuzzy rectangles.
Or | Intersects two fuzzy rectangles, i.e. intersects the ranges of the boundaries of specified fuzzy rectangles.
Methods |
Rect ExternalRect() | Returns a copy of the external rectangle.
Rect InternalRect() | Returns a copy of the internal rectangle.
XInterval Left() | The left boundary of the fuzzy rectangle, horizontal range.
YInterval top() | The top boundary of the fuzzy rectangle, vertical range.
XInterval Right() | The right boundary of the fuzzy rectangle, horizontal range.
YInterval Bottom() | The bottom boundary of the fuzzy rectangle, vertical range.
XInterval XCenter() | The X-coordinate of the centre of the fuzzy rectangle, horizontal range.
YInterval YCenter() | The Y-coordinate of the centre of the fuzzy rectangle, vertical range.
DistInterval Width() | The width of the fuzzy rectangle, distance range.
DistInterval Height() | The height of the fuzzy rectangle, distance range.
Logic IsEmpty() | Checks if the fuzzy rectangle is empty.
RectArray | Array of rectangles
Constructors |
RectArray RectArray () | Creates an empty array of rectangles.
RectArray RectArray( Rect rect ) | Constructor with parameter Rect. Creates an array consisting of one rectangle equal to the rect rect.
RectArray RectArray( Region region ) | Constructor with parameter Region. Creates an array consisting of rectangles of the region region.
Methods |
Region Region() | Continuous region from an array of rectangles.
Rect Rect() | Rectangle circumscribing an array of rectangles.
Void Add( Rect rect ) | Adds a rect rectangle to an array of rectangles.
Void Add( RectArray array ) | Adds an array array to an array of rectangles.
Region | A region is a set of rectangles positioned one under another in such a way that the top line of the lower rectangle is the bottom line of the upper one (so that the rectangles do not overlap).
Constructors |
Region Region() | Creates an empty region.
Region Region( RectArray rectArray ) | Constructor from a value of type RectArray. Creates a region containing the rectangles from the rectArray array.
Operators |
Or | Unites two regions.
And | Intersects two regions; or a region and a rectangle. Returns a value of type Region.
Methods |
XCoordinate Left() | Returns the left boundary of the region. Read-only property.
YCoordinate top() | Returns the top boundary of the region. Read-only property.
XCoordinate Right() | Returns the right boundary of the region. Read-only property.
YCoordinate Bottom() | Returns the bottom boundary of the region. Read-only property.
Distance Width() | Returns the width of the region. Read-only property.
Distance Height() | Returns the height of the region. Read-only property.
Area Area() | Returns the left boundary of the rectangle. Read-only property.
Void Inflate( Distance xDist, Distance yDist ) | Expands the region by xDist to the right and to the left, and by yDist upwards and downwards.
Rect Rect() | Returns a copy of the rectangle circumscribing the region.
ImageObjectSet | Type used to represent the set of image objects belonging to the hypothesis.
Methods |
RectArray Rects() | Returns a copy of the array of rectangles of image objects belonging to the hypothesis.
Region Region() | Returns a copy of the continuous region created from the array of rectangles of image objects belonging to the hypothesis.
TextTypes | Type used to represent a set of text types.
Operators |
+ | Joins two values of type TextTypes.
BarcodeTypes | Type used to represent a set of barcode types.
Operators |
+ | Joins two values of type BarcodeTypes.
BarcodeOrientations | Type used to represent a set of possible barcode orientations.
Operators |
+ | Joins two values of type BarcodeOrientations.
RecognitionMode | Integer type used to represent pre-recognition modes.
Direction | Type used to represent the vertical or horizontal direction. Sets the direction of Separator and White Gap elements.
HorSearchAreaBound | Type used to represent the right and left boundaries of the element’s search area. A variable of this type can only be created by using a Let expression.
Operators |
- | Binary operator that subtracts a value of type HorSearchAreaBound from a value of type XInterval and vice versa. Returns a value of type Xinterval.
>, < | Binary operators that compare a value of type HorSearchAreaBound to a value of type XCoordinate. Return a value of type FuzzyRect.
VertSearchAreaBound | Type used to represent the top and bottom boundaries of the element’s search area. A variable of this type can only be created by using a Let expression.
Operators |
- | Binary operator that subtracts a value of type HorSearchAreaBound from a value of type YInterval and vice versa. Returns a value of type Yinterval.
>, < | Binary operators that compare a value of type VertSearchAreaBound to a value of type YCoordinate. Return a value of type FuzzyRect.
Hypothesis | Type used to call a hypothesis of the element of any type. See Hypotheses for all types of element for more details.
HypothesisInstances | Describes instances of a Repeating Group element. Has the same methods as hypotheses. For more about the methods of hypotheses, see Hypotheses for all types of element.
Methods |
YCoordinateArray GetYArray( Real ratio ) | Returns the array of Y coordinates of instance rectangles. To calculate the Y coordinate, the following formula is used: Top + Height * ratio. Null instances are ignored.
YCoordinateArray | The array of Y coordinates of the rectangles.
Constructors |
YCoordinateArray YCoordinateArray() | Constructor. Creates an empty array of rectangles specified by Y coordinates.
Methods |
Void Add( YCoordinate ) | Adds a rectangle to the end of the array
Void Add( YCoordinateArray ) | Adds another array to the end of the array.
Void InsertAt( Int index, YCoordinate ) | Adds a rectangle to position index.
Void DeleteAll() | Deletes all elements of the array
Void DeleteAt( Int index ) | Deletes the element in position index.
YCoordinate GetAt( Int index ) | Returns the element with the specified index.
Int Count() | Returns the number of elements in the array.
Void ShiftDown( Int index, Distance ) | Shift downward (increase) the coordinate of the specified element in the array.
Void ShiftUp( Int index, Distance ) | Shift upward (decrease) the coordinate of the specified element in the array.
Void ShiftDown( Distance ) | Shift downward (increase) all elements in the array.
Void ShiftUp( Distance ) | Shift upward (decrease) all elements in the array.
TableBlockColumn | Type used to call a column of the table block. A variable of this type can only be created by using a Let expression. See Hypotheses for Table elements for more details.
TableBlockColumnArray | Type used to call an array of columns of the table block. A variable of this type can only be created by using a Let expression. See Hypotheses for Table elements for more details.
Constructors |
TableBlockColumnArray( TableBlockColumn ) | Creates an array of columns from a single column. For example: TableBlockColumnArray arr; arr = Blocks.TableBlock.Column1;
Methods |
Void Add( TableBlockColumn ) | Adds the selected column to the array of columns.
Operators |
<< | Binary operator that adds an array of columns to another array of columns. For example: TableBlockColumnArray arr; arr = Blocks.TableBlock.Column1; arr << Blocks.TableBlock.Column2 << Blocks.TableBlock.Column3;
TableHypothesis | Type used to call a hypothesis of the table element. See Hypotheses for Table elements for more details.
TableHypColumn | Type used to call a column of the hypothesis of the table element. A variable of this type can only be created by using a Let expression. See Hypotheses for Table elements for more details.
TableColumnType | Type used to describe of multiple types of column content.
CurrencyPositionTypes | Type used to set the position of the currency name relative to the numerical value in a Currency element.
Operators |
+ | Joins values of type CurrencyPositionTypes. Binary operator.
PageInterval | Types used to represent the page interval of a multi-page document.
Methods |
Logic IsEmpty() | Checks if the range of a rectangle is empty. Read-only.
Int Start() | Returns the number of the first page in a range. Read-only.
Int End() | Returns the number of the last page in a range. Read-only.
PageArea | Area on a page. Returned by PageSearchAreaLocal, PageSearchAreaGlobal, PageAreaLocal, and PageAreaGlobal methods (these functions have page numbers as their arguments). Can be expressed either in global or local coordinates, depending on which function has been called.
Methods |
XInterval Left() | The left boundary of the part of the hypothesis located on the given page, horizontal interval.
YInterval Top() | The top boundary of the part of the hypothesis located on the given page, vertical interval.
XInterval Right() | The right boundary of the part of the hypothesis located on the given page, horizontal interval.
YInterval Bottom() | The bottom boundary of the part of the hypothesis located on the given page, vertical interval.
XInterval XCenter() | The abscissa of the center of the part of the hypothesis located on the given page, horizontal interval.
YInterval YCenter() | The ordinate of the center of the part of the hypothesis located on the given page, vertical interval.
DistInterval Width() | The width of the part of the hypothesis located on the given page.
DistInterval Height() | The height of the part of the hypothesis located on the given page.
FuzzyRect FuzzyRect() | The fuzzy rectangle of the part of the hypothesis located on the given page
Rect Rect() | The enclosing rectangle of the part of the hypothesis located on the given page. Coincides with the outward rectangle of the fuzzy rectangle.
Region Region() | The region of the part of the hypothesis located on the given page.
Region SimplifiedRegion() | The region of the part of the hypothesis located on the given page, simplified for better viewing.
ImageObjectSet Set() | Image objects captured by the part of the hypothesis located on the given page.
ImageObjectSet ExcludeSet() | Image objects on the part of the image excluded from the search area of the part of the hypothesis located on the given page by Exclude methods.
RectArray Rects() | The array of rectangles of the image objects capture by the part of the hypothesis located on the given page.
PageEdge | The type used to specify the Nearest function relative to a page edge. Allows you to select the hypothesis closest to the top, bottom, left or right page edge.
Page | Type returned by the Page( Int PageNumber ) function.
Methods |
Distance AverageLineHeight() | Average line height on a page.
Distance AverageInterlineInterval() | Average line spacing on a page.
Area ObjectsAreaLocal( Rect localRect, ImageObjectType ) | The area of the objects in the specified rectangle on a page of the specified type. Local coordinates are used for the rectangle.
Area ObjectsAreaGlobal( Rect globalRect, ImageObjectType ) | The area of the objects in the specified rectangle on a page of the specified type. Global coordinates are used for the rectangle.
Rect RectLocal() | The rectangle of the entire image in local coordinates.
Rect RectGlobal() | The rectangle of the entire image in global coordinates.
SearchAreaPageSetType | The type used in the RestrictSearchArea function. The predefined constants for this type are: AnyPage; OddPages; EvenPages; LastPage.


Conversion of types

The FlexiLayout language supports implicit conversion of types.

Int –> Real
Rect –> Region
XCoordinate –> XInterval
YCoordinate –> YInterval
Distance –> DistInterval

The following conversions are allowed in the language, but may result in an error. For example, conversion XCoordinate –> Distance with a subsequent conversion Distance –> YCoordinate may lead to an error of converting an X-coordinate into a Y-coordinate.

If you use such conversions in your code, the compiler will display a warning message.

Distance –> XCoordinate
Distance –> YCoordinate
XCoordinate –> Distance
YCoordinate –> Distance
DistInterval –> XInterval
DistInterval –> YInterval
Xinterval –> DistInterval
Yinterval –> DistInterval


Predefined constants

Type | Value
Logic | true; false
DateFormats | DayMonthYear; DayYearMonth; MonthDayYear; MonthYearDay; YearDayMonth; YearMonthDay
DayFormatVariants | NoLeadingZeroDay; WithLeadingZeroDay
MonthFormatVariants | DigitsNoLeadingZeroMonth; DigitsWithLeadingZeroMonth; WordMonth
YearFormatVariants | TwoDigitYear; FourDigitYear
Quality | BestQuality; WorstQuality
TextTypes | TextType_Normal; TextType_TypeWriter; TextType_Matrix
RecognitionMode | FastMode; FullMode
BarcodeOrientations | BarcodeOrientation_Autodetect; BarcodeOrientation_LefttoRight; BarcodeOrientation_Downtotop; BarcodeOrientation_RighttoLeft; BarcodeOrientation_toptoDown
BarcodeTypes | BarcodeType_Autodetect; BarcodeType_Codabar; BarcodeType_Code39; BarcodeType_Code93; BarcodeType_CheckCode39; BarcodeType_Code39WithoutAsterisk; BarcodeType_Interleaved25; BarcodeType_CheckInterleaved25; BarcodeType_EAN13; BarcodeType_Code128; BarcodeType_EAN8; BarcodeType_PDF417; BarcodeType_IATA25; BarcodeType_UCC128; BarcodeType_UPCA; BarcodeType_UPCE
ImageObjectType

The sum total of any number of elementary values that correspond to objects of various types:

  • AnyText - text
  • PunctuationMark - punctuation marks
  • PictureObject - picture
  • InvertedTextObject - inverted text
  • CheckmarkObject - checkmark
  • SeparatorObject - separator
  • VertSeparatorObject - vertical separator
  • HorSeparatorObject - horizontal separator
  • BarcodeObject - barcode
Direction | Vertical; Horizontal
TableColumnType ColumnType_Text;
ColumnType_Currency;
ColumnType_Date;
ColumnType_RegExp;
ColumnType_Number
CurrencyPositionTypes | CurrencyPos_Left; CurrencyPos_Right
SearchAreaPageRestriction | WholePage (used only in the RestrictSearchArea function)
SearchAreaPageSetType | AnyPage; OddPages; EvenPages; LastPage (used only in the RestrictSearchArea function)
PageEdge | PageTop; PageBottom; PageLeft; PageRight
TextAlignmentInTableCell | TextAlignment_CellTop; TextAlignment_CellBottom
String | RegionalDecimalPoint – the character used by the operating system to separate the integer and fractional parts of a decimal number.


Predefined variables

Name | Description
OutputRegion | Variable of type Region. Used in the Region Expression section. The value of the variable determines the region of the block. Used for blocks of all types, except table blocks.
IsNull | Variable of type Logic. Used in the Region Expression section. The value of the variable determines whether the block has been found or not. The IsNull variable is pre-initialized with value False, which means that the block has been found. To instruct the program that the block has not been found, set the variable IsNull to True. Used for blocks of all types.
OutputTable | Variable of type TableHypothesis. Used in the Region Expression section. The value of the variable is used to initialize the region and the contents of a block on the basis of a specific table element. Used only for table blocks.
OutputInstances | Variable used in the Region Expression section for blocks of all types for which Has repeating instances is enabled. For non-table blocks, the type of the variable is HypothesisInstances. For table blocks, the type of the variable is TableHypothesisInstances. The value of the variable defines the detected region of the block. The region of a block built from the instances of the elements and subelements of a repeating group is discontinuous.


Global functions

Definition | Description
Distance AverageLineHeight() The average height of the text lines on the page.
Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected document has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error.
For a multi-page document, use the corresponding method of the type Page:
Page( N ). AverageLineHeight.
Distance AverageInterLineInterval() The average distance between the text lines on the page.
Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected document has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error.
For a multi-page document, use the corresponding method of the type Page:
Page( N ). AverageInterLineInterval.
Area ObjectsArea( Rect, ImageObjectType ) | The area of the objects of the specified type within the specified rectangle. Works in global coordinates.
Rect PageRect() The rectangle of the entire image.
Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error
For a multi-page document, this function may only be used in the Pre-search relations section. See Functions which limit the search area for details.
Logic IsOnSameLine( Hypothesis, Hypothesis ) | Checks if the hypotheses intersect vertically.
Int Min( Int n1, Int n2 ) | Returns the minimum value from n1, n2.
Int Max( Int n1, Int n2 ) | Returns the maximum value from n1, n2.
Real Min( Real d1, Real d2 ) | Returns the minimum value from d1, d2.
Real Max( Real d1, Real d2 ) | Returns the maximum value from d1, d2.
Area Min( Area a1, Area a2 ) | Returns the minimum value from a1, a2.
Area Max( Area a1, Area a2 ) | Returns the maximum value from a1, a2.
Distance Min( Distance d1, Distance d2 ) | Returns the minimum value from d1, d2.
Distance Max( Distance d1, Distance d2 ) | Returns the maximum value from d1, d2.
XCoordinate Min( XCoordinate x1, XCoordinate x2 ) | Returns the minimum value from x1, x2.
XCoordinate Max( XCoordinate x1, XCoordinate x2 ) | Returns the maximum value from x1, x2.
XCoordinate MiddleBetween( XCoordinate x1, XCoordinate x2 ) | Returns the X-coordinate calculated as ( x1+ x2 ) / 2.
XCoordinate Between( XCoordinate x1, XCoordinate x2, Real ratio ) | Returns the X-coordinate calculated as x1+ ( x2 – x1 ) * ratio.
YCoordinate Min( YCoordinate y1, YCoordinate y2 ) | Returns the minimum value from y1, y2.
YCoordinate Max( YCoordinate y1, YCoordinate y2 ) | Returns the maximum value from y1, y2.
YCoordinate MiddleBetween( YCoordinate y1, YCoordinate y2 ) | Returns the Y-coordinate calculated as ( y1+ y2 ) / 2.
YCoordinate Between( YCoordinate y1, YCoordinate y2, Real ratio ) | Returns the Y-coordinate calculated as y1+ ( y2 – y1 ) * ratio.
XInterval MiddleBetween( Xinterval x1, XInterval x2 ) | Returns XInterval calculated as ( x1+ x2 ) / 2.
XInterval Between( Xinterval x2, Xinterval x2, Real ratio ) | Returns XInterval calculated as x1+ ( x2 – x1 ) * ratio.
YInterval MiddleBetween( Yinterval y1, Yinterval y2 ) | Returns YInterval calculated as ( y1+ y2 ) / 2.
YInterval Between( Yinterval y1, Yinterval y2, Real ratio ) | Returns YInterval calculated as y1+ ( y2 – y1 ) * ratio.
Region FormRegion( RectArray included, RectArray excluded ) | Creates a region that includes the array of included rectangles, and excludes the array of excluded rectangles.
String Chr( Int ) | Returns a string using the specified Unicode code of the character (code must be written in decimal system).
Quality ValidateByText( String word, String variants, Int maxErrors, Real maxErrorsPart, Logic ignoreSpaces )

Checks the specified word by comparing it with the listed variants. The maxErrors argument sets the absolute maximum number of errors in the word, and the maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces determines whether spaces should be taken into account when comparing. Returns the quality of matching between the specified word and the best match from the variants listed in the variants argument.

E.g.
if not IsNull then ValidateByText ( Value(), "ABBYY|Flexi Capture", 1, 0.3, true );

This function may be used in the Advanced Post-Search Relations field for fuzzy matching of the string value of a hypothesis returned by the Value method with specified variants.
Quality ValidateByDB( String word, String connectionString, String selectString, Int maxErrors, Real maxErrorsPart, Logic ignoreSpaces, Int maxRecordsCount = 1000 )

Checks the specified word by comparing it against a database (see Using databases and text files in the FlexiLayout language). The connectionString argument sets the string for connecting to the database. The selectString argument sets an SQL query, which starts with the SELECT command. The maxErrors argument sets the absolute maximum number of errors in the word, and the maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces determines whether spaces should be taken into account when comparing. To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000). Returns the quality of matching between the specified word and the best match from the database.

E.g.
if not IsNull then ValidateByDB( Value(), "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\FCS\\Companies.mdb", "SELECT Name FROM Companies", 1, 0.3, true, 500 );

This function may be used in the Advanced Post-Search Relations field for fuzzy matching of the string value of a hypothesis returned by the Value method with specified variants.
Quality ValidateByFile( String word, String fileName, Int maxErrors, Real maxErrorsPart, Logic ignoreSpaces, Int maxRecordsCount = 1000 )

Checks the specified word by comparing it with the variants in the fileName file, which lists possible phrase variants (see Using databases and text files in the FlexiLayout language). The maxErrors argument sets the absolute maximum number of errors in the word, and the maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces determines whether spaces should be taken into account when comparing.

Returns the quality of matching between the specified word and the best match from the text file.

To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000).

E.g.
if not IsNull then ValidateByTextFile( Value(), "Companies.txt", 1, 0.3, true, 500 );

This function may be used in the Advanced Post-Search Relations field for fuzzy matching of the string value of a hypothesis returned by the Value method with specified variants.
String UCase( String ) | Returns a string obtained from the specified string by changing all of its characters to upper case.
String LCase( String ) | Returns a string obtained from the specified string by changing all of its characters to lower case.
String RemoveSpaces( String ) | Returns a string obtained from the specified string by removing all of the spaces in the string.
Int PagesCount() | Returns the number of pages in the document.
Page Page( Int PageNumber ) | Returns the type that described the given page.
Rect DocumentRect() | Returns the rectangle of the entire document (in global coordinates).
Logic TestDBConnection( String connectionString ) | Tests the database connection. The connectionString argument contains the connection string.
Logic TestDBSelect( String connectionString, String selectString ) | Checks if the database is accessible and if the SQL query is correct (if the specified table and field exist). The connectionString argument contains the connection string. The selectString argument contains the SQL query, which starts with the SELECT command.
Logic TestFileAccess( String fileName ) | Checks if the text files is accessible.
Logic IsInt( String inputString, Logic isStrictMode = false ) | Checks that the inputString string can be securely converted to an integer number. The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits and spaces.
Int StrToInt( String inputString, Logic isStrictMode = false )

Returns the result of converting the inputString string value to an integer number. Spaces are omitted. The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits and spaces. If isStrictMode = false, and the string contains a character which is not a digit or space, all subsequent characters are omitted. It is recommended to check the possibility of conversion before invoking it. To do it, use the IsInt function.

E.g.

Int integralValue;

String valueFromDocument = SearchElements.StaticText.Value();

Logic canBeConverted = IsInt( valueFromDocument, true );

if( canBeConverted ) then integralValue = StrToInt( valueFromDocument, true );
Logic IsReal( String numberString, String separators = “.,”, Logic isStrictMode = false ) | Checks that the inputString string can be converted to a real number. The list of allowed decimal separators is set by the “separators” argument. By default, the point, comma and user-defined separator (configured in the regional settings of the OS, see RegionalDecimalPoint). The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits, spaces and separators.
Real StrToReal( String numberString, String separators = “.,”, Logic isStrictMode = false )

Returns the result of converting the inputString string to a real number. Spaces are omitted. The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits, spaces and separators. If isStrictMode = false, and the string contains a second decimal separator or a character which is not a digit or space, all subsequent characters are omitted. It is recommended to check the possibility of conversion before invoking it. To do it, use the IsReal function.

E.g.

Real realValue;

String valueFromDocument = SearchElements.StaticText.Value();

Logic canBeConverted = IsReal( valueFromDocument, "." );

if( canBeConverted ) then realValue = StrToReal( valueFromDocument, "." );
Logic ExecuteSQL( String connectionString, String queryString )

Carries out the user’s SQL query: queryString. The connectionString argument sets the database connection string.

E.g.

ExecuteSQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\FCS\\Companies.mdb", "UPDATE Companies SET total=0" );
Logic WriteToFile( String filename, String text )

Adds the “text” string to the “filename” file. If there is no file with this name, a new file will be created.

E.g.

WriteToFile( “D:\\FCS\\logFile.txt”, SearchElements.Tag.Value() );
Void SetPagesCount( Int pagesCount )

Sets the number of pages in the document. It is used in “Pre-search” or “Post-search advanced code” sections.

This function must be invoked from from the Header or Footer elements or their sub-elements.

E.g.

If the given element was matched – the document ends on the next page.

if IsFound then SetPagesCount( PagesCount + 1 );

The number of pages in the document can be seen in the PageNum field:

if PageNum.IsFound and IsInt( PageNum.Value ) then SetPagesCount: StrToInt( PageNum.Value );
The following functions invoke pre-recognition during FlexiLayout matching. The text lines intersecting with a given pre-recognition area are recognized as a whole (including the line parts that fall out of the area boundaries).
Void RecognizeText() | Recognizes text in the relative rectangle specified in the “Pre-recognition area” property in the project settings. All document pages are included in the recognition.
Void RecognizeText( IntArray pages ) | Recognizes text in the relative rectangle specified in the “Pre-recognition area” property in the project settings. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( SearchAreaPageSetType pageSetType ) | Recognizes text in the relative rectangle specified in the “Pre-recognition area” property in the project settings. Only the pages specified by the “pageSetType” part of the string are included in the recognition.
Void RecognizeText( Rect rect ) | Recognizes text in the “rect” rectangle.
Void RecognizeText( Rect rect, IntArray pages ) | Recognizes text in the “rect” rectangle. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( Rect rect, SearchAreaPageSetType pageSetType) | Recognizes text in the “rect” rectangle. Only the pages specified by the “pageSetType” part of the document.
Void RecognizeText( RectArray rectArray ) | Recognizes text in the “rectArray” array of rectangles.
Void RecognizeText( RectArray rectArray, IntArray pages ) | Recognizes text in the “rectArray” array of rectangles. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( RectArray rectArray, SearchAreaPageSetType pageSetType ) | Recognizes text in the “rectArray” array of rectangles. Only the pages specified by the “pageSetType” part of the string are included in the recognition.
Void RecognizeText( Region region ) | Recognizes text in the “region” region.
Void RecognizeText( Region region, IntArray pages ) | Recognizes text in the “region” region. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( Region region, SearchAreaPageSetType pageSetType ) | Recognizes text in the “region” region. Only the pages specified by the “pageSetType” part of the string are included in the recognition.
RectArray RecognizedRects() | A debugging function allowing printing of an array of pre-recognized rectangles.


Controlling searches

Definition | Description
Void Optional( Real q1, Real q2 ) | Makes an element optional. The q1 parameter sets the quality of the null hypothesis. The q2 parameter sets the criterion for formulating the null hypothesis: the null hypothesis will be formulated if no other hypotheses are created whose qualities exceed a certain threshold.
Void StopIfFound ( Logic Value=true ) | Stops generating hypothesis in the branch if it contains a non-null hypothesis for the given element. For more information, see the Required, optional, and prohibited elements section.
Void DontFind() | Tells the program not to look for an element. If the element is optional, only the null hypothesis will be formulated.
Void MaxHypothesesCount( Int ) | Sets the maximum number of hypotheses for an element.


Search constraints

The search area constraints are set on the Search Constraints and the Relations tabs in the Properties dialog box, and in the Advanced pre-search relations section. Before the constraints have been applied, the search area coincides with the rectangle of the page. First, the program applies the constraints set on the Search Constraints and the Relations tabs. Next, the program applies the additional constraints set in the Advanced pre-search relations section.

The following types of constraint can be set in the Advanced pre-search relations section:

  1. The search area can be limited to a rectangle (Rect variable), to a region (i.e. a continuous array of rectangles – Region variable), or to an array of rectangles which, in the general case, need not be continuous (RectArray variable). This type of constraint is set using the RestrictSearchArea function and by specifying a parameter of the corresponding type.
    Any expressions which return values of the required type can be specified as parameters.
  2. The search area can be limited to a half-plane located to the left of, to the right of, above, or below a particular point. Such constraints are set using the Leftof, Rightof, Above, and Below functions.
  3. Sometimes you may wish to set constraints for an element boundary. For example, it may be known beforehand that the left boundary of an element is always located in the left-hand part of the image, whereas the right boundary may stretch indefinitely to the right.
    The FlexiLayout language allows you to set such constraints at the stage of calculating the search area, thereby narrowing the range of possible hypotheses for an element. Such constraints are set using the LeftBound, RightBound, topBound, and BottomBound functions and the operators ">" and "<." The LeftBound and RightBound functions are used to access the left and right boundaries of the search area, and the topBound and BottomBound functions are used to access the top and bottom boundaries respectively.
  4. You can set search constraints by excluding a rectangle, an array of rectangles, a hypothesis etc. from the search area. This can be done by using the Exclude, ExcludeRect, and ExcludeSet functions.

You can specify any number of search constraints of the above types in the Advanced pre-search relations section. Each constraint will create a region on the image. All the regions created by the constraints will be intersected.
Additionally, the calculated search area for the element will be intersected with the search area for the Group element of which this element is a member.


Geometry of the search area

Imagine, for the sake of convenience, that no search constraints are specified on the Search Constraints and the Relations tabs for the element and its parent Group elements. In this case, before the program applies the constraints from the Advanced pre-search relations section, the search area of the element will coincide with the rectangle of the page. If there are no additional constraints on the Advanced tab, the program will look for the element on the entire page.

Applying constraints of type 1, 2, and 4 described in Search Constraints above will create a search area consisting of an array of rectangles. The program will take the search area to consist of one rectangle circumscribing the entire array, from which a specified set of rectangles (excluded rectangles) must be excluded.

Applying the search constraints of type 3 described in Search Constraints above will create a range of allowed coordinates for each boundary of the hypotheses – left, right, top, and bottom. Each of the boundaries is characterized by a range of coordinates on the corresponding axis, e.g. [x1, x2] or [y1, y2]. Here x1 and x2 are of type XCoordinate, and y1 and y2 are of type YCoordinate. The section of the axis must meet the following condition: x1 <= x2 for the X-coordinates, and y1 <= y2 for the Y-coordinates.

If several constraints are consecutively applied to a boundary, each constraint will change the range of allowed coordinates for the boundary.

Let the Advanced pre-search relations section contain the following constraints:

LeftBound > 5mm;

LeftBound < 15mm;

LeftBound < 10mm;

Let the search area coincide with the rectangle of the page, i.e. [PageRect.Left, PageRect.top, PageRect.Right, PageRect.Bottom], before the above constraints are applied. Then the ranges of the coordinates of the element boundaries will be:

Let the search area not be specified prior to executing these constraints. Then, in the case of a one-page FlexiLayout (the minimum and maximum allowed number of pages in a document is 1), the search area coincides with the rectangle of the page [PageRect.Left, PageRect.Top, PageRect.Right, PageRect.Bottom]. In the case of a multi-page FlexiLayout, the search area has the maximum size of [-INF, -INF, INF, INF]. The coordinate ranges of the element boundaries will be as follows:

boundary | Range for one-page FlexiLayout | Range for multi-page FlexiLayout
LeftBound | [PageRect.Left, PageRect.Right] | [-INF, INF]
TopBound | [PageRect.Top, PageRect.Bottom] | [-INF, INF]
RightBound | [PageRect.Left, PageRect.Right] | [-INF, INF]
BottomBound | [PageRect.Top, PageRect.Bottom] | [-INF, INF]

When the constraint LeftBound > 5mm is executed, only the left boundary changes. The range of its possible values becomes the segment [5mm, PageRect.Right] for one-page FlexiLayouts and the segment [5mm, INF] for multi-page FlexiLayouts.

After the LeftBound > 5mm constraint is applied, only the left boundary will change – its allowed coordinates will be [5mm, PageRect.Right].

After the LeftBound < 15mm constraint is applied, the range of allowed coordinates of the left boundary will be [5mm, 15mm].

After the LeftBound < 10mm constraint is applied, the range of allowed coordinates of the left boundary will be [5mm, 10mm].

Similarly you can set constraints for other boundaries of the element.

The specified boundaries of the search area form a so-called fuzzy rectangle.


Fuzzy rectangle

Fuzzy rectangle is a structure that describes a class of rectangles whose boundaries lie within specific allowed ranges. A fuzzy rectangle consists of two rectangles – an external rectangle and an internal rectangle.

In the FlexiLayout language, fuzzy rectangles are represented by type FuzzyRect.

As can be seen in Figure below, in the general case, when constraints for all the boundaries are set, there is a part of the search area that must fall within any hypothesis for the element. It is this part that forms the internal rectangle. The maximum-size circumscribing rectangle of the possible hypothesis forms the external rectangle.

Show me...

Let the boundaries of the element be:

LeftBound: [L1, L2], where L1 <= L2

topBound: [T1, T2], where T1 <= T2

RightBound: [R1, R2], where R1 <= R2

BottomBound: [B1, B2], where B1 <= B2

Then the fuzzy rectangle containing the information about the specified boundaries will be formed as follows: InternalRect: [L2, T2, R1, B1], ExternalRect: [L1, T1, R2, B2].

If the user sets no constraints for the boundaries of the search area, the internal rectangle degenerates and makes no geometrical sense. In this case L1=R1, L2=R2, T1=B1, T2=B2.

Suppose now that no constraints have been specified for the search area. Then, if the maximum and minimum allowed number of pages is 1, the fuzzy rectangle of the search area will be created as follows:

LeftBound: [PageRect.Left, PageRect.Right]

TopBound: [PageRect.Top, PageRect.Bottom]

RightBound: [PageRect.Left, PageRect.Right]

BottomBound: [PageRect.Top, PageRect.Bottom]

InternalRect: [PageRect.Right, PageRect.Bottom, PageRect.Left, PageRect.Top]

ExternalRect: [PageRect.Left, PageRect.Top, PageRect.Right, PageRect.Bottom]

and in the case of a multi-page document:

LeftBound: [-INF, INF]

TopBound: [-INF, INF]

RightBound: [-INF, INF]

BottomBound: [-INF, INF]

InternalRect: [INF, INF, -INF, -INF]

ExternalRect: [-INF, -INF, INF, INF]

As can be seen from the above expressions, the external rectangle coincides with the rectangle of the entire page, and the internal rectangle degenerates and has negative height and width.

Fuzzy rectangles can be united and intersected. When two fuzzy rectangles are intersected, their corresponding boundaries intersect: the right boundary of one rectangle intersects with the right boundary of the other, the left with the left, etc. This creates new ranges for the boundaries:

LeftBound: [L1’, L2’]

topBound: [T1’, T2’]

RightBound: [R1’, R2’]

BottomBound: [B1’, B2’]

The resulting fuzzy rectangle will be created using the resulting intervals: InternalRect: [L2’, T2’, R1’, B1’], ExternalRect: [L1’, T1’, R2’, B2’].

If, as a result of the intersection, at least one of the conditions for creating the fuzzy rectangle (L1 <= L2, T1 <= T2, R1 <= R2, B1 <= B2) is not met, the resulting fuzzy rectangle will be nullified: InternalRect: [0, 0, 0, 0], ExternalRect: [0, 0, 0, 0]. Usually an empty fuzzy rectangle is created as a result of contradictory conditions, e.g. if you attempt to intersect two fuzzy rectangles whose external boundaries do not intersect.

Fuzzy rectangles are united in the same way: first, the ranges of each boundary are united. As a result of uniting the two ranges, a minimum range is created which contains both specified ranges. After the boundaries have been united, a new fuzzy rectangle is formed.

In practice you will most often encounter fuzzy rectangles with a degenerated internal rectangle. Only on rare occasions will you need to set constraints on a specific boundary. However, the search area for an element is always represented by a fuzzy rectangle and an array of excluded rectangles.


Functions which limit the search area

The functions listed in the table below can only be used in the Advanced pre-search relations section. Each function specifies a fuzzy rectangle for the search area or adds rectangles to an array of excluded rectangles.

Function | Description
Void Leftof( XInterval x, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the vertical half-plane located to the left of the point x.End - offset.
Void Leftof( FuzzyRect fuzzyRect, Distance offset = 0 ) | Limits the search area to a fuzzy rectangle, fuzzyRect, moved to the left along the X-axis by a distance equaling offset.
Void Leftof( Hypothesis hyp, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the vertical half-plane located to the left of the point hyp.Left.End - offset.
Void LeftOf( HypothesisInstances hyps, Distance offset = 0 ) | Limits the search area by the vertical half-plane to the left of the point hyps.Left.End – offset. Global coordinates are used.
Void Rightof( XInterval x, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the vertical half-plane located to the right of the point x.Start + offset.
Void Rightof( FuzzyRect fuzzyRect, Distance offset = 0 ) | Limits the search area to a fuzzy rectangle, fuzzyRect, moved to the right along the X-axis by a distance equaling offset
Void Rightof( Hypothesis hyp, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the vertical half-plane located to the right of the point hyp.Right.Start + offset.
Void RightOf( HypothesisInstances hyps, Distance offset = 0 ) | Limits the search area by the vertical half-plane to the right of the point hyp.Right.Start + offset. Global coordinates are used.
Void Above( YInterval y, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the horizontal half-plane located above of the point y.End - offset.
Void Above( FuzzyRect fuzzyRect, Distance offset = 0 ) | Limits the search area to a fuzzy rectangle, fuzzyRect, moved upwards along the Y-axis by a distance equaling offset
Void Above( Hypothesis hyp, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the horizontal half-plane located above of the point hyp.top.End - offset.
Void Above( HypothesisInstances hyps, Distance offset = 0 ) | Limits the search area by the horizontal half-plane above the point hyp.top.End – offset. Global coordinates are used.
Void Below( YInterval y, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the horizontal half-plane located below of the point y.Start + offset.
Void Below( FuzzyRect fuzzyRect, Distance offset = 0 ) | Limits the search area to a fuzzy rectangle, fuzzyRect, moved downwards along the Y-axis by a distance equaling offset
Void Below( Hypothesis hyp, Distance offset = 0 ) | Limits the search area to a rectangle which is the result of intersecting the rectangle of the page with the horizontal half-plane located below of the point hyp.Bottom.Start + offset.
Void Below( HypothesisInstances hyps, Distance offset = 0 ) | Limits the search area by the horizontal half-plane below the point hyp.Bottom.Start + offset. Global coordinates are used.
Void Exclude( Hypothesis hyp ) | Excludes the region of the hyp hypothesis from the search area. If the hyp hypothesis is not found, excludes the internal rectangle of the search area of the hyp hypothesis.
Void Exclude( Rect rect ) | Excludes the rect rectangle from the search area.
Void Exclude( RectArray rectArray ) | Excludes the rectArray array of rectangles from the search area.
Void ExcludeRect( XInterval left, YInterval top, XInterval right, YInterval bottom ) | Excludes the fuzzy rectangle described by the ranges left, top, right, and bottom from the search area.
Void ExcludeSet( ImageObjectSet set ) | Excludes from the search area the array of rectangles of the set set of objects.
Void Exclude( HypothesisInstances ) | Excludes from the search area the region of the instances of the hypothesis.
Void RestrictSearchArea( FuzzyRect fuzzyRect ) | Limits the search area to the fussy rectangle fuzzyRect. Global coordinates are used.
Void RestrictSearchArea( FuzzyRect, IntArray pages ) | Limits the search area by the fuzzy rectangle fuzzyRect. Specify the local coordinates and page range pages.
Void RestrictSearchArea( FuzzyRect, SearchAreaPageSetType ) | Limits the search area by the fuzzy rectangle fuzzyRect. Specify the local coordinates and page range of the type SearchAreaPageSetType.
Void RestrictSearchArea( RectArray rectArray ) | Limits the search area to the array of rectangles rectArray. Global coordinates are used. Example You can specify that the boundaries of the search area of the current element are defined by the boundaries of the rectangles of the elements ElementName1, ElementName2, and ElementName3. If any of the elements are not detected, when accessing this function, the search area of the current element will be defined by the boundaries of the search areas of the corresponding elements. RestrictSearchArea: RectArray(ElementName1.Rect or ElementName2.Rect or ElementName3.Rect);
Void RestrictSearchArea( RectArray, IntArray pages ) | Limits the search area by the array of rectangles rectArray. Specify the local coordinates and page range pages.
Void RestrictSearchArea( RectArray, SearchAreaPageSetType ) | Limits the search area by the array of rectangles rectArray. Specify the local coordinates and page range of the type SearchAreaPageSetType.
Void RestrictSearchArea( Region region ) | Limits the search area to the region region. Global coordinates are used. Example You can specify that the search area of the current element is limited by the region of the element ElementName. RestrictSearchArea: ElementName.Region;
Void RestrictSearchArea( Region, IntArray pages ) | Limits the search area by the region region. Specify the local coordinates and page range pages.
Void RestrictSearchArea( Region, SearchAreaPageSetType ) | Limits the search area by the region region. Specify the local coordinates and page range of the type SearchAreaPageSetType. Example You can specify that the element must be searched for in the search area on even pages. RestrictSearchArea: searchArea, EvenPages;
Void RestrictSearchArea( SearchAreaPageRestriction pageRestriction, IntArray pages ) | Limits the page range on which to search without limiting the search area on the pages themselves. The pageRestriction parameter acquires the only value: WholePage. Example You can specify that the element must be searched for on pages 2, 4, 7-9. RestrictSearchArea: WholePage, 2 << 4 << 7 << 8 << 9;
Void RestrictSearchArea( SearchAreaPageRestriction pageRestriction, SearchAreaPageSetType ) | Limits the page range on which to search without limiting the search area on the pages themselves. The pageRestriction parameter acquires the only value: WholePage. Example You can specify that the element must be searched for on the last page. RestrictSearchArea: WholePage, LastPage;
Note: You can use RSA alias instead of full name RestrictSearchArea.

Note: Different constraints for the same page are used jointly, and for different pages independently. (The search is carried out on the pages for which at least one constraint has been specified.)

Auxiliary functions that define the search area

Rect PageRect() The rectangle of the current page in global coordinates used to specify a search area that depends on the page.
The PageRect can only be used to specify a search area.

Example.

To specify that the element is located in the bottom half of a page (the exact page is not known in advance), write:
Below: PageRect.Top + PageRect.Height / 2;

In all other cases use the construction Page( N ).Rect to get the rectangle of the page number N or DocumentRect to get the rectangle of the entire document. You can also use the PageNumber function to specify a search area that depends on the page.
Int PageNumber() The number of the current page. Specifies a search area that depends on the page.

Example. Suppose you have a repeating element SearchElements.PageHeader. To search on each page below the instances of this element, write

Below: SearchElements.PageHeader.AllInstances.PageAreaGlobal( PageNumber ).FuzzyRect, 0 * dot;


Functions which create a fuzzy rectangle

The RestrictSearchArea( FuzzyRect fuzzyRect ) function described in Functions which Limit the Search Area allows you to limit the search area to any fuzzy rectangle.

The table below lists the functions that can be used to obtain a fuzzy rectangle.

Function | Description
HorSearchAreaBound LeftBound() | Used to set a constraint for the left boundary of the search area. Expressions of type LeftBound() > XCoordinate return FuzzyRect.
VertSearchAreaBound TopBound() | Used to set a constraint for the top boundary of the search area. Expressions of type topBound() > YCoordinate return FuzzyRect.
HorSearchAreaBound RightBound() | Used to set a constraint for the right boundary of the search area. Expressions of type RightBound () > XCoordinate return FuzzyRect.
VertSearchAreaBound BottomBound() | Used to set a constraint for the bottom boundary of the search area. Expressions of type BottomBound () > YCoordinate return FuzzyRect.
FuzzyRect AreaLeftOf( XInterval x, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the left of the point x.End – offset.
FuzzyRect AreaLeftOf( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the left of the point rect.Left.End – offset.
FuzzyRect AreaLeftOf( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the left of the point hyp.Rect.Left.End – offset.
FuzzyRect AreaLeftOf( HypothesisInstances hyps, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the left of the point hyps.Rect.Left.End – offset.
FuzzyRect AreaRightOf( XInterval x, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the right of the point x.Start + offset.
FuzzyRect AreaRightOf( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the right of the point rect.Right.Start + offset.
FuzzyRect AreaRightOf( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the right of the point hyp.rect.Right.Start + offset.
FuzzyRect AreaRightOf( HypothesisInstances hyps, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a vertical half-plane located to the right of the point hyp.Rect.Right.Start + offset.
FuzzyRect AreaAbove( YInterval y, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located above the point y.Start - offset.
FuzzyRect AreaAbove( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located above the point rect.top.Start - offset.
FuzzyRect AreaAbove( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located above the point hyp.rect.top.Start - offset.
FuzzyRect AreaAbove( HypothesisInstances hyps, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located above the point hyp.Rect.top.End - offset.
FuzzyRect AreaBelow( YInterval y, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located below the point y.End + offset.
FuzzyRect AreaBelow( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located below the point rect.Bottom.End + offset.
FuzzyRect AreaBelow( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located below the point hyp.rect.Bottom.End + offset.
FuzzyRect AreaBelow ( HypothesisInstances hyps, Distance offset = 0 ) | Returns a fuzzy rectangle in global coordinates, which is a horizontal half-plane located below the point hyp.Rect.Bottom.Start + offset.
FuzzyRect ImageLeftOf( XInterval x, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the vertical half-plane located to the left of the point x.End – offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaLeftOf( XInterval x, Distance offset = 0 ).
FuzzyRect ImageLeftOf( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the vertical half-plane located to the left of the point rect.Left.End – offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaLeftOf( FuzzyRect rect, Distance offset = 0 ).
FuzzyRect ImageLeftOf( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the vertical half-plane located to the left of the point hyp.Rect.Left.End – offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaLeftOf( Hypothesis hyp, Distance offset = 0).
FuzzyRect ImageRightOf( XInterval x, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the vertical half-plane located to the left of the point x.Start + offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaRightOf( XInterval x, Distance offset = 0 ).
FuzzyRect ImageRightOf( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the vertical half-plane located to the right of the point rect.Right.Start + offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaRightOf( FuzzyRect rect, Distance offset = 0 ).
FuzzyRect ImageRightOf( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the vertical half-plane located to the right of the point hyp.rect.Right.Start + offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaRightOf( Hypothesis hyp, Distance offset = 0).
FuzzyRect ImageAbove( YInterval y, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the horizontal half-plane located above the point y.Start - offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaAbove( YInterval y, Distance offset = 0 ).
FuzzyRect ImageAbove( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the horizontal half-plane located above the point rect.top.Start - offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaAbove( FuzzyRect rect, Distance offset = 0 ).
FuzzyRect ImageAbove( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the vertical half-plane located to the left of the point hyp.rect.top.Start - offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaAbove( Hypothesis hyp, Distance offset = 0 ).
FuzzyRect ImageBelow( YInterval y, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the horizontal half-plane located above the point y.End + offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaBelow( YInterval y, Distance offset = 0 ).
FuzzyRect ImageBelow( FuzzyRect rect, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the horizontal half-plane located below the point rect.Bottom.End + offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaBelow( FuzzyRect rect, Distance offset = 0 ).
FuzzyRect ImageBelow( Hypothesis hyp, Distance offset = 0 ) | Returns a fuzzy rectangle, which is an intersection of the rectangle of the page and the horizontal half-plane located below the point hyp.rect.Bottom.End + offset. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the function FuzzyRect AreaBelow( Hypothesis hyp, Distance offset = 0 ).


Debug functions which return information about the search area

The functions listed below are only available in the Advanced pre-search relations section.

These functions can be used for debugging prints. You can run print commands after specifying a set of instructions limiting the search area in order to see the results of these instructions.

Function | Description
FuzzyRect SearchArea() | Created search area – a fuzzy rectangle. Read-only.
RectArray ExcludedRects() | Array of rectangles excluded from the search area. Read-only.
PageArea PageSearchAreaLocal( Int PageNumber ) | Returns the search area that intersects the given page, in the local coordinates of the page.
PageArea PageSearchAreaGlobal( Int PageNumber ) | Returns the search area that intersects the given page, in global coordinates.

Example

To print the search area of an element:

In the Advanced pre-search relations section, type the following code for the selected element:
Print: Str(SearchArea); or equivalent code Print: Str(SearchArea ());

The Str function converts the results into string format required for printing. The results (information about the coordinates and the size of the fuzzy rectangle of the selected element InternalRect and ExternalRect) will be displayed in the Properties window. To view the results, select the corresponding element in the tree of hypotheses and then point the mouse to the Pre-search print line in the Properties window. The Value may not fit within the Pre-search print line, but in the Pre-search print pane below the Properties window you will see the complete print results.

Note: When printing the results of accessing the function ExcludedRects (Print: Str(ExcludedRects());), select the Pre-search print line in the Properties window to see the results.


Nearest functions

Nearest functions tell the program that, other things being equal, it must select the hypothesis that is nearest to a certain element or point on the image that is specified by the parameters of the Nearest function. In the Advanced pre-search relations section of the element, you can use only one Nearest function. After the function is applied, only one hypotheses from a group of several hypotheses is selected. The selection occurs when hypotheses are being generated for the element, i.e. before the code entered in the Advanced post-search relations section is executed. For details, see Using Nearest and FuzzyQuality to search for elements.

Nearest functions can be used to select hypotheses for any kind of elements except Groups, Repeating Groups, and Tables.

Parameter | Description
Void NearestX( XCoordinate x ) Selects the hypothesis nearest to the vertical line which goes through the point ( x, 0 ).

E.g.
The code below specifies that the sought element is horizontally nearest to the right boundary of the ElementName element.
NearestX: ElementName.Right.Start;

Void NearestY( YCoordinate y ) Selects the hypothesis nearest to the horizontal line which goes through the point ( 0, y ).

E.g.
The code below specifies that the sought element is vertically nearest to the top boundary of the ElementName element.
NearestY: ElementName.Top.Start;
Void Nearest ( Xinterval x, YInterval y )

Void Nearest( XInterval x, YInterval y ) Selects the hypothesis nearest to the rectangle Rect( x.Start, y.Start, x.End, y.End ).

E.g. 1
The code below specifies that the sought element is closest to the center of the ElementName element.
Nearest: ElementName.XCenter, ElementName.YCenter;

E.g. 2
The code below specifies that the sought element is closest to the center of the page.
Nearest: PageRect.XCenter, PageRect.YCenter;

Void Nearest( PageEdge ) Selects the hypothesis on each page of the document that is nearest to one of the page edges - top, bottom, right or left.

Note: If several hypotheses are at the same distance from the specified boundary, several hypotheses may be selected.

E.g.
To specify that the current element is closest to the bottom edge of the page, write.
Nearest: PageBottom;

Void Nearest( Hypothesis hyp ) Selects the hypothesis nearest to the fuzzy rectangle hyp.Rect

E.g.
The code below specifies that the sought element is closest to the ElementName element.
Nearest: ElementName;

Void Nearest( HypothesisInstances ) | Selects the hypothesis closest to the set of hypothesis for the specified Repeating Group element.


Controlling the quality of a hypothesis

Parameter | Description
Quality Quality( Real ) | Sets the penalty coefficient by which the quality of the element hypothesis must be multiplied.
Quality FuzzyQuality( Int value, IntFuzzyInterval interval ) | The function calculates the penalty coefficient by which the quality of the element hypothesis must be multiplied. The function checks whether the value value belongs to the fuzzy interval interval. For more on the FuzzyQuality function, see Tips and Tricks/Using Nearest and FuzzyQuality to look for elements.
Quality FuzzyQuality( DistInterval value, DistFuzzyInterval interval ) | The function calculates the penalty coefficient by which the quality of the element hypothesis must be multiplied. The function checks whether the value value belongs to the fuzzy interval interval. For more on the FuzzyQuality function, see Tips and Tricks/Using Nearest and FuzzyQuality to look for elements.


Specifying element properties

You can change the properties of an element on the Advanced tab of the Advanced pre-search relations section. You can edit both properties you have set in the Properties dialog box of an element and some of the additional properties. See below for the list of properties you can edit in the Advanced pre-search relations section.

Note: Any properties you set on the first two tabs preceding the Advanced tab in the Properties dialog box will be interpreted by the FlexiLayout Studio compiler as a sequence of operators which are the parameters (properties) of the corresponding elements described in this chapter. To view the code generated for a property, click the Code button on the Advanced tab.

You can edit and copy the code displayed on the Code tab or use it for writing your own code which employs "if," "then," and "else" operators.

Example

The following checks whether elements Element1 and Element2 have been detected or not. If at least one of the elements have not been detected, the program is instructed to look for a vertical separator. Otherwise, the program should look for a horizontal separator.

If (Element1.IsNull == False) or (Element2.IsNull == False) then
Mode: Vertical;
Else
Mode: Horizontal;

Element properties are described in detail in the sections that follow.


Object Collection

Parameter | Description
Void Type( ImageObjectType ) | Sets the value of the Type parameter. See Dialogs. Element properties. Object Collection. Type. E.g. The code below sets a list of objects of type Barcode and pictures for the current Object Collection element Type: BarcodeObject + PictureObject; which is the same as: Type (BarcodeObject + PictureObject); Calling this property will find all the objects of the Barcode and Picture type in the search area of the element.
Void MinObjHeight( Distance ) | See Object size. Min Height You can use any units of measurement. E.g. The code below sets the minimum height to 10mm: MinObjHeight (10mm);
Void MaxObjHeight( Distance ) | See Object size. Max Height You can use any units of measurement.
Void MinObjWidth( Distance ) | See Object size. Min Width You can use any units of measurement.
Void MaxObjWidth( Distance ) | See Object size. Max Width You can use any units of measurement.
Void WholeWordMode ( Logic ) | This flag specifies whether only whole text objects should be considered as hypotheses. When set to True, hypotheses consisting of word parts are ignored. The flag is set to False by default. Note: Restrictions on the height and width of objects are applied to words if the flag is set to True and to characters if the flag is set to False.
Void UseRawText( Logic ) | Enables the use in text searches of those unrecognized text-like objects that were assigned the type Raw Text during pre-recognition. To enable this feature, call the method with parameter True. By default, only recognized text is used in text searches (i.e. the parameter is set to False).
Void MaxXOutsidePart( Real ) | Specifies the part of the object that may extend beyond the search area horizontally. The part of the character is specified by a number from 0 to 1. Those objects are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the object that may extend beyond the search area vertically. The part of the character is specified by a number from 0 to 1. Those objects are included in the hypothesis that have the specified or smaller part outside the search area.


Character String

Parameter | Description
Void AllowEmbeddedHypotheses( Logic ) See Character String. Allow embedded hypotheses.

E.g.
The code below tells the program that it must generate the longest hypothesis.
AllowEmbeddedHypotheses (False);

Void MinQuality( Real ) Sets the minimum quality of the hypothesis. Hypotheses whose quality is below this minimum will be discarded.

E.g.
The code below tells the program to ignore hypotheses whose quality is lower than 0.95.
MinQuality: 0.95;

Void MaxNonDefinedCount( Real ) See Character String. Percentage of non-alphabet characters.

E.g.
The code below tells the program that the string may contain up to 30% of characters which do not belong to any of the specified alphabets.
MaxNonDefinedCount (0.3);

Void MaxWordBreakCount( Real ) | The maximum number of word ends in the line. The line is divided into words based on the Detect words by interword space parameter (see Element Properties dialog box, Character String tab). The parameter is specified as a ratio: [number of word ends]/[number of characters in the string].
Void MinInterwordSpace( Distance ) | Enables division into words based on the width of the space (see Element Properties dialog box, Character String tab, Detect words by interword spaceDetect words by interword space and specifies the minimum width of the space to Distance (Min interword space parameter).
Void WordsCount( Int, Int, Int, Int ) | See Element Properties dialog box, Character String tab, Words count.
Void TotalChainLength( Int, Int, Int, Int ) See Character String, Characters Count.

E.g.
The code below tells the program to look for a line 5 to 10 characters long.
TotalChainLength (4, 5, 10, 11);

Void TotalGapLength( Distance, Distance, Distance, Distance ) | Specifies the maximum allowed total length of spaces in the string as a fuzzy interval. Assess the quality of the hypotheses based on the total length of the spaces.
Void MaxGapInLine( Distance ) Sets the maximum distance between neighboring characters.

When generating a hypothesis, the program will add characters to the hypothesis until the distance between two neighboring characters does not exceed MaxGapInLine.
See also Character String, Character String, Max space length

E.g.
The code below tell the program that the maximum distance between neighboring characters may not exceed 5 mm, otherwise a null hypothesis is generated.
MaxGapInLine (5mm);

Void MaxRelativeGapInLine( Real ) | The maximum distance between neighboring characters expressed as a percentage of the line height.
Void AllowChoppedWords( Logic ) | This flag specifies whether text objects which do not fit entirely within the left and right boundaries should be included into the hypothesis. The default value is True.
Void MaxXOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area horizontally. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area vertically. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void AddAlphabet( String alphabet, Real portion ) Sets the alphabet and the allowed percentage of alphabet characters in the hypothesis.

E.g.
The code below tell the program adds an alphabet which consists of the characters №, #, % and *, whose percentage in the hypothesis may not exceed 10%.
Note: You can only add characters which are not part of any of the alphabets specified for the current element.
AddAlphabet ("№#%*", 0.1);

Void RegularExpression( String ) Sets the regular expression defining the text of the hypothesis.

E.g.
Below is a regular expression which looks for a string where characters may be arranged in one of two ways: 2 digits, - (hyphen), 1 digit or letter N, digit from 1 to 5, / (forward slash), 1 to 3 digits.
RegularExpression: ("([0-9]{2}[-][0-9])|([N][1-5][/][0-9]{1-3})");
which is the same as:
RegularExpression: ("([0-9]{2}\"-\"[0-9])|(\"N\"[1-5]\"/\"[0-9]{1-3})");
Void WholeWordMode ( Logic ) This flag specifies whether only whole words must be considered as valid hypotheses. If the flag is set to True, hypotheses made up of parts of words will be discarded. The default setting is False.
Note: This property is different from AllowedChoppedWords in that AllowChoppedWords affects only formulation of hypotheses made up of words on the boundary of the search area, whereas WholeWordMode affects formulation of all hypotheses.
Void RegularExpressionFromDB( String connectionString, String selectString, Int maxRecordsCount = 1000 ) | Uses a database to set the regular expression defining the text of the hypotheses (see Using databases and text files in the FlexiLayout language). The connectionString argument sets the string for connecting to the database. The selectString argument sets an SQL query, which starts with the SELECT command). To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000).
Void RegularExpressionFromFile( String fileName, Int maxRecordsCount = 1000 ) | Uses a text file to set the regular expression defining the text of the hypotheses (see Using databases and text files in the FlexiLayout language). The fileName argument sets the name of the text file. To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000).
Void Width( Distance, Distance, Distance, Distance ) | The width of the hypothesis specified as a fuzzy interval.
Void Height( Distance, Distance, Distance, Distance ) | The height of the hypothesis specified as a fuzzy interval.


Static Text

Parameter | Description
Void MinQuality( Real ) | Sets the minimum quality of the hypothesis.
Void MaxErrors( Int ) Sets the maximum number of errors in the hypothesis.

See Max number of errors

Void MaxErrorsPart( Real ) Sets the maximum percentage of errors in the hypothesis.

See Max error percentage

Void MaxErrors( Int number, Real part ) Sets the maximum number of errors in the hypothesis: number – absolute number, part – percentage.

E.g.
The code below tells the program that the absolute number of errors may not exceed 3, and the percentage of errors may not exceed 20%.
MaxErrors (3, 0.2);
Note: Out of the two conditions the program will use the strictest.

Void MaxGapInLine( Distance ) Sets the maximum distance between neighboring characters.

When generating a hypothesis, the program will add characters to the hypothesis until the distance between two neighboring characters does not exceed MaxGapInLine.
See also Character String, Character String, Max space length

E.g.
The code below tells the program that the maximum distance between neighboring characters may not exceed 5 mm, otherwise a null hypothesis is generated.
MaxGapInLine (5mm);

Void MaxRelativeGapInLine( Real ) | The maximum distance between neighboring characters expressed as a percentage of the line height.
Void AllowChoppedWords( Logic ) The flag specifies whether text objects which do not fit entirely within the left and right boundaries should be included into the hypothesis. The default value is True.

E.g.
The code below tells the program to look for the element only among the text objects which fit entirely within the search area.
AllowChoppedWords (False);

Void MaxXOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area horizontally. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area vertically. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.

Void CaseSensitive( Logic Value=true)

Distinguishes between lowercase and uppercase letters if set to True.
Void IgnoreAccents( Logic value = true ) | Ignores/does not ignore diacritics when searching for text. If the value is set to True, diacritics are ignored. Therefore, the words "café" and "cafe" will be treated as identical.
Void SearchTextFromDB( String connectionString, String selectString, Int maxRecordsCount = 1000 )

Specifies the set of strings to be searched on an image with the help of a database (see Using databases and text files in the FlexiLayout language).

The connectionString argument sets the connection string for connecting to the database.

The selectString argument sets an SQL query, which starts with the SELECT command. The resulting set obtained by this query, which must contain only one field, represents phrase variants. In its simplest form, a query gets the required field from a specified database table. If a query returns more than one field, the data from the first field are used for the search.

To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000).

E.g.
SearchTextFromDB: "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\FCS\\DBKeywords.mdb", "SELECT Words FROM WordsTable", 500;
Void SearchTextFromFile( String fileName, Int maxRecordsCount = 1000 )

Specifies the set of strings to be searched on an image with the help of a fileName text file. (see Using databases and text files in the FlexiLayout language).

To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000).

E.g.
SearchTextFromFile: "Keywords.txt", 500;
The following methods are only available if the text to find consist of one word
Void SearchText ( String ) | Text to find.
The following methods are available if the text to find consists of several words
Void NextLinePenalty( Real ) | See Static Text. Break line penalty
Void OmissionPenalty( Real ) | See Static Text. Missed words penalty
Void WholeWordMode ( Logic ) The flag specifies whether only whole text objects must be considered as valid hypotheses. When set to True, hypotheses consisting of parts of words are ignored. The default setting is False.
Note: This method is different from AllowChoppedWords in that AllowChoppedWords affects only hypotheses generated from words on the boundary of the search area, whereas WholeWordMode affects the generation of all hypotheses.
Void AllowEmbeddedHypotheses( Logic ) E.g.
The code below tell the program that its must formulate the longest hypothesis.
AllowEmbeddedHypotheses (False);
Void MaxLineBreakDistance( Distance ) | The distance between the word in the next line and the previous line.


Text Fragment

Parameter | Description
Void MaxGapInLine( Distance ) | Sets the maximum distance between neighboring characters.
Void MaxXOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area horizontally. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area vertically. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxInterlineSpace( Distance ) | The maximum distance between the lines.
Void MaxRelativeInterlineSpace( Real ) | The maximum distance between the neighboring lines expressed as a percentage of the height of the top line.
Void MaxLineHeightSpread( Real ) | The maximum variation in the height of the lines; calculated as the difference in height between the tallest line and the smallest line divided by the height of the tallest line.
Void MaxLineLengthSpread( Real ) | The maximum variation in the length of the lines; calculated as the difference in length between the longest line and the shortest line divided by the length of the longest line.
Void MinHorLineOverlap( Real ) | The minimum horizontal overlap of the neighboring lines; calculated as the length of the common segment of the lines divided by the length of the shortest line.
Void LinesCount( FuzzyRect ) | The number of lines in the paragraph.
Void FragmentWidth( FuzzyRect ) | The width of the paragraph in characters.
Void MaxLineHeight( Distance ) | The maximum height of the characters (font size).
Void MinLineHeight( Distance ) | The minimum height of the characters (font size).
Void MaxRelativeGapInLine( Real ) | The maximum distance between neighboring characters expressed as a percentage of the line height.
Void AllowChoppedWords( Logic ) | This flag specifies whether text objects which do not fit entirely within the left and right boundaries should be included into the hypothesis. E.g. The code below tell the program that it may look for the element among the text objects that only partially fit within the search area. AllowChoppedWords (True);
Void MinQuality( Real ) | Sets the minimum quality of the hypothesis.
Void FilterStamp( Logic ) | See Text String. Remove stamp.


Separator

Parameter | Description
Void Mode( Direction ) Separator orientation.

E.g.
The code below tells the program that the separator is horizontal.
Mode: Horizontal;

See Separator, Orientation

Void MinQuality( Real ) | Sets the minimum quality of the hypothesis.
Void MinRelativeLength ( Real ) Sets the minimum length of the separator which lies within the search area relative to the length of the search area.

See Separator, Min relative length

Void PenaltyLimitForLength( Real ) Specifies the minimum quality that the hypothesis may get for its length when calculating its quality (number from 0 to 1). The longer the separator object, the higher the quality. The highest quality of 1 has the separator whose length equals the length of the search area. As the relative length of the separator decreases from 1 to 0, the quality of the hypotheses decreases inn direct proportion from 1 to PenaltyLimitForLength.
Note: This function was introduced to replace Void MaxPenalty( Real ), which is obsolete and will e removed from future versions. If you previously used Max length penalty, set PenaltyLimitForLength to (1 - [Max length penalty]).
see Element Properties dialog box, Separator tab
Void MinSeparatorLength( Distance ) | See Separator. Min length
Void MaxSeparatorLength( Distance ) | See Separator. Max length.
Void MaxSeparatorGap( Distance ) See Separator. Space. Max length

E.g.
The code below tells the program that several horizontal separators located on one level must be considered as one separator if the gap between them does not exceed 20 dots.
Mode: Horizontal;
MaxSeparatorDistance (0mm);
MaxSeparatorGap(20dt);

Void MaxSeparatorRelativeGap( Real ) | See Separator. Space. Max relative length
Void MaxSeparatorGap( Distance d, Real r ) | Sets absolute (d) and relative (r) constraints on the length of the space. See Separator. Space. Max Length
Void FitsWithinSearchArea( Logic ) Specifies that the separator must fit entirely within the search area.

See Separator, Fits entirely within search area property.

Void MaxSeparatorDistance( Distance ) See Separator. Space. Orthogonal shift

E.g.
The code below tells the program that several vertical separators must be considered as one separator if the distance between them does not exceed 1 mm.
Mode: Horizontal;
MaxSeparatorDistance (1mm);


White Gap

Parameter | Description
Void Mode( Direction ) White Gap orientation.
See Element Properties dialog box, White Gap tab and the description of the White Gap properties.

E.g.
The code below tells the program to look for a vertical gap.
Mode: Vertical;

Void RelativeGapLevel( Real ) | See White Gap. Relative upper threshold and the description of the White Gap properties.
Void MaxGapLevel( Distance ) See White Gap. Upper threshold and the description of the White Gap properties.

E.g.
The code below tells the program that the maximum gap level may not exceed 150 dots.
MaxGapLevel (150dt);

Void MinGapLevel( Distance ) | See White Gap. Lower threshold and the description of the White Gap properties.
Void MinGapWidth( Distance ) See White Gap. Min width/height and the description of the White Gap properties.

E.g.
The code below tells the program that the minimum height of the horizontal gap is 50 dot.
Mode: Horizontal;
MinGapWidth (50dt);

Void Type( ImageObjectType )

Searches for a white gap among the objects of a particular type. (By default, the program will look for white gaps among any of the objects detected on the image.)

E.g.
The code below specifies that the program must look for white gaps only among text objects.
Type: AnyText+InvertedTextObject;
Void UseRawText( Logic ) | Enables the use in text searches of those unrecognized text-like objects that were assigned the type Raw Text during pre-recognition. To enable this feature, call the method with parameter True. By default, only recognized text is used in text searches (i.e. the parameter is set to False).

More

Hypotheses for White Gap elements


Barcode

Parameter | Description
Void Type( BarcodeTypes ) | See Barcode. Barcode Type. E.g. The code below tells the program that the barcode is of Interleaved 25 type. Type: BarcodeType_Interleaved25; Void Orientation( BarcodeOrientations )
Void Orientation( BarcodeOrientations ) | See Barcode. Orientation. E.g. The code below tells the program that the barcode must be read left to right. Orientation: BarcodeOrientation_LeftToRight;
Void MaxXOutsidePart( Real ) | Specifies the part of the object that may extend beyond the search area horizontally. May assume values from 0 to 1. Those objects are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the object that may extend beyond the search area vertically. May assume values from 0 to 1. Those objects are included in the hypothesis that have the specified or smaller part outside the search area.


Date

Parameter | Description
Void DateFormat( DateFormats ) | See Date. Format. Date E.g. the code below tells the program that the date has the format mm, dd, yyyy DateFormat: MonthDayYear;
Void Language( String ) | See Date. Language
Void MinQuality( Real ) | Sets the minimum quality of the hypothesis.
Void Separators( String ) | See Date. Separators E.g. The code below tells the program that numbers in the date may be separated by dots (.) or forward slashes (/). Separators: "./";
Void DayFormat( DayFormatVariants ) | See Date. Format. Day
Void MonthFormat( MonthFormatVariants ) | See Date. Format. Month E.g. The code below tells the program that the month in the date may be written either as a word or as a two-digit number. MonthFormat: DigitsWithLeadingZeroMonth + WordMonth;
Void YearFormat( YearFormatVariants ) | See Date. Format. Year
Void MinDate( String ) | A string in the format dd/mm/yyyy which sets the Date parameter. Date interval. From
Void MaxDate( String ) | A string in the format dd/mm/yyyy which sets the Date parameter. Date interval. To E.g. The code below tells the program that the date lies between January 1, 2000 and December 31, 2004 (format is irrelevant). MinDate: "01/01/2000"; MaxDate: "31/12/2004";
Void MaxXOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area horizontally. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis, that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area vertically. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis, that have the specified or smaller part outside the search area.
Void MaxRelativeGapInLine( Real ) | The maximum distance between neighboring characters expressed as a percentage of the line height.


Currency

Parameter | Description
Void Currency( String ) | Sets possible currency names. Currency names must be separated by commas. Spaces after commas are allowed. See Currency dialog box, Currency name property. Example: Currency: "USD, $, EUR, EURO";
Void CurrencyOmissionQuality( Real ) | Sets the penalty for a missing currency name. See Currency dialog box, Missing name penalty property.
Void CurrencyPosition( CurrencyPositionTypes ) | Sets the location of the currency name – to the left or to the right of the numerical value See Currency dialog box, Currency name position property. Example: CurrencyPosition: CurrencyPos_Left;
Void MinimalValue( Real ) | Sets the minimum numerical value. See Currency dialog box, Minimum value property.
Void MaximalValue( Real ) | Sets the maximum numerical value. See Currency dialog box, Maximum value property.
Void Separators( String ) | Sets the symbols which can be used to separate the integer and fractional parts of the numerical value. See Currency dialog box, Possible fractional part separators property. Example: Separators: ",.";
Void AllowSeparatorOmission( Logic ) | Specifies whether the fractional part separator is required in the numerical value. See Currency dialog box, Allow missing separator property.
Void AllowFractionalPartOmission( Logic ) | Specifies whether the numerical value must have a fractional part. See Currency dialog box, Allow missing fractional part property.
Void FindOnlyIntegers( Logic ) | Finds only integers. Symbols set by the Separators function (or in the corresponding dialog box) will be ignored. AllowSeparatorOmission is automatically set to true and AllowFractionalPartOmission is automatically set to false.
Void MaxXOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area horizontally. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area vertically. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxRelativeGapInLine( Real ) | The maximum distance between neighboring characters expressed as a percentage of the line height.


Phone

Parameter | Description
Void MinDigitsCount( Int ) | Sets the minimum number of digits in the phone number. See the Phone dialog box, Minimum number of digits property.
Void MaxDigitsCount( Int ) | Sets the minimum number of digits in the phone number. See the Phone dialog box, Maximum number of digits property.
Void Prefixes( String ) | Sets the possible phone prefixes. Prefixes must be separated by commas. Commas may be followed by spaces. See the Phone dialog box, Prefixes for phone numbers property. Example: Prefixes: "tel, tel., phone";
Void PrefixOmissionQuality( Real ) | Sets the penalty for a missing phone prefix. See the Phone dialog box, Missing prefix penalty property.
Void Separators( String ) | Sets the symbols used to separate digits in the phone number. See the Phone dialog box, Possible digit separators property. Example: Separators: "-/";
Void AddCodeDelimiters( String, String ) | Sets the opening and closing brackets for the city code. The parameters of the function are one-character strings. The first parameter is an opening bracket, the second parameter is a closing bracket. . See the Phone dialog box, Area code/city code brackets property. Example: AddCodeDelimiters: "{", "}";
Void PossibleDigitQuality( Real ) | Sets the penalty for each missing wrong character in the phone number. The default value is 0.97.
Void UniformDigitStringQuality( Real ) | Sets the penalty for a phone number which consists of only digits evenly distributed on the image. Used to distinguish telephone numbers from other sequences of digits, such as zip codes, account numbers, etc. The default value is 0.97.
Void MaxXOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area horizontally. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxНOutsidePart( Real ) | Specifies the part of the character that may extend beyond the search area vertically. The part of the character is specified by a number from 0 to 1. Those characters are included in the hypothesis that have the specified or smaller part outside the search area.
Void MaxRelativeGapInLine( Real ) | The maximum distance between neighboring characters expressed as a percentage of the line height.


Table

Parameter | Description
Column search parameters
Void AddHeaderKeyWord( String keyWord, TableBlockColumn column, Real omissionQuality, Logic wholeWordMode, Logic multiLine ) Specifies the keyword for the column name

See Table element dialog box, Column Properties, Detect by keyword in name option.

Void AddHeaderKeyHypothesis( Hypothesis hypothesis, TableBlockColumn column ) Specifies the column name by means of the detected hypothesis.

See Table element dialog box, Column Properties, Use found element as column name option.

Void AddHeaderKeyHypothesis( DistInterval left, DistInterval top, DistInterval right, DistInterval bottom, TableBlockColumn column ) | Specifies the coordinates of the column name.
Void AddColumnType( TableColumnType type, TableBlockColumn column, String regExp ) Specifies the column type. The third parameter must only be specified if the column type is a regular expression.

See Table element dialog box, Column Properties, Type of column content property.

Void ColumnOmissionQuality( Real quality, TableBlockColumn column ) If fixed column orders are used, it sets the penalty for the hypotheses. The coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied if the column specified in the fixed column order is not detected.

If the parameter is not set, its default value is 0.9.

Void MissingContentPenalty( Real quality, TableBlockColumn column ) Sets the penalty for the hypotheses. The coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied if the actual data type in the column does not coincide with the data type specified by the user. (See Table element dialog box, Column Properties, Missing content penalty). If the parameter is not set, its default value is 0.98.

If column order rules are used, it specifies the penalty for the absence of the column in the table.

Void ColumnBounds( Distance left, Distance right, TableBlockColumn column ) Sets the right and left boundaries of the search area used to search for the column.

See Table element dialog box, Column Properties, Absolute area constraints.

Void ExactColumnBorders( XCoordinate left, XCoordinate right, TableBlockColumn ) Sets the exact column boundaries.

This parameter can be used to search for a table where the location of some (or all) of the columns is known in advance.
Parameters setting the column order
Void AddPossibleColumnsOrder( String orderName, TableBlockColumnArray array ) Specifies one of the variants of fixed column order.

See Table element dialog box, Order tab, Fixed column order option.
Void ColumnsRelation( TableBlockColumnArray ) Specifies one rule for the column order.

See Table element dialog box, Order tab, Rules for column order option.

Header search parameters
Void HasHeader( Logic ) | Specifies whether the program should look for a header. See the Table element dialog box, Header tab, Look for header.
Void HeaderOptional( Real q1, Real q2 ) | Specifies whether the header is optional, similarly to the Void Optional ( Real q1, Real q2 ) function for elements.
Void HeaderSearchArea( Rect ) Specifies the search rectangle for the header. If this function is used, the search area of the header will be calculated as the intersection of this rectangle and the one enclosing the search area of the whole table.

See Table element dialog box, Header tab, Absolute area constraints.

Void MaxHeaderHypothesesCount( Int ) Sets the maximum number of hypotheses to be generated during header search.

See Table element dialog box, Header tab, Number of hypotheses for header.

Void MinHeaderKeyElements( Int ) | Sets the minimum number of key elements required to detect the header. The default value is 2.
Void ExtendHeaderLocalization( XInterval, YInterval, XInterval, YInterval ) | Extends the localization area of the header. For example, it can be used to discard the line of unwanted information located between the header and the body of the table.
Footer search parameters
Void HasFooter( Logic ) Specifies whether the program should look for the footer.

See Table element dialog box, Footer tab, Look for footer.

Void FooterOptional( Real q1, Real q2 ) | Specifies whether the footer is optional, similarly to the Void Optional ( Real q1, Real q2 ) function for elements.
Void FooterSearchArea( Rect ) Specifies the search rectangle for the footer. If this function is used, the footer search area will be calculated as the intersection of this rectangle and the one enclosing the search area of the whole table.

See Table element dialog box, Footer tab, Absolute area constraints.

Void FooterHasTopSeparator() | Specifies that there is a separator between the footer and the body of the table. The separator can be a part of a table boundary.

FooterWholeWordMode ( Logic )

This flag is used when looking for a footer based on keywords. If this flag is set to True, hypotheses made up of only word parts are discarded.

The default setting is False.

See Table element dialog box, Footer tab, Whole words only option.

Void FooterNearestToTop ( Logic )

This flag is used when looking for a footer based on keywords. If this flag is set to True, the program selects the topmost candidate and discards the rest. If this flag is set to False, the program considers all the possible candidates.

The quality of the footer contributes to the quality of the table and then the table hypothesis with the highest quality is selected.

The default setting is True.
Void AddFooterKeyWord( String ) Specifies a keyword for the footer of the table.

See Table element dialog box, Footer tab, Search by keyword option.

Void AddFooterKeyHypothesis( Hypothesis ) Specifies the footer of the table by means of the detected hypothesis.

See Table element dialog box, Footer tab, Use found element option.

Void AddFooterKeyHypothesis( XInterval, YInterval, XInterval, YInterval ) Specifies the coordinates of the footer of the table.
Body search parameters
Void DontFindBody() | Allows skipping the body search. Used for debugging.
Void BodyOptional(Real q1, Real q2 ) | Specifies whether the body is optional, similarly to the Void Optional ( Real q1, Real q2 ) function for elements.
Void IgnoreVerticalSeparators() | Ignores vertical separators in the body of the table when dividing the table into columns (by default, separators are taken into account).
Void IgnoreSeparatorsFromHeader() | Ignores vertical separators in the header of the table at the column detection when dividing the table into columns (by default, vertical separators are taken into account).
Void AutoDetectTopAndBottom( Logic ) | Search for the top and bottom boundaries of the table automatically. The default setting is true. If the flag is set to false, the entire text inside the search area of the table element is used.
Rows detection parameters
Void SingleLineTable( Logic ) Tells the program that each line of text must correspond to one row in the table.

See Table element dialog box, Rows tab, One line of text corresponds to one row check box (if the option Detect rows automatically is selected).

Void SingleLineMasterColumn( Logic ) Tells the program that each line of text must correspond to one row in the master column of the table.

See Table element dialog box, Rows tab, One line of text corresponds to one row check box (if the option Use master columns to detect rows is selected).

Void MaxRowVerticalGap( Distance ) | Specifies the maximum vertical distance between two rows in the table. If the specified distance is exceeded, this means the end of the body of the table. By default, this distance is not limited.
Void MinRowVerticalGap( Distance ) | Specifies the minimum vertical distance between two rows in the table. If the distance is smaller than the specified distance, the rows are merged into one. The default value is 0.
Void MaxMasterColumnRowGap( Distance ) | Specifies the maximum vertical distance between two rows in the master column of the table. If the specified distance is exceeded, this means the end of the body of the table. By default, this distance is not limited.
Void MinMasterColumnRowGap( Distance ) | Specifies the minimum vertical distance between two table rows in a particular column. If the distance is smaller than specified, the rows are merged into one. The default distance is 0.
Void IgnoreHorizontalSeparators() | Ignores horizontal separators when dividing the table into rows.
Void DivideRowsBySeparators() | Detects rows relying on separators only and ignoring text.
Void DivideRowsByMasterColumn( TableBlockColumn ) Tells the program to use the text of the column when dividing the table into rows. This function can be called multiple times. If a table on an image does not have the required column, the column from the next call of the function is used, etc. If all the columns are unavailable, the rows are detected in the whole table.

See Table element dialog box, Rows tab, Use master columns to detect rows option.

Void MasterColumnTextAlignment( TextAlignmentInTableCell ) | Specifies text alignment in a table cell in the Master Column. Can be TextAlignment_CellTop or TextAlignment_CellBottom. Example: MasterColumnTextAlignment: TextAlignment_CellBottom; - the text is aligned to the bottom border of the cell.
Void AddStopWord( String ) Specifies the words for which separate rows must not be drawn.

See Table element dialog box, Rows tab, Stop words.

Void RowSplitters( YCoordinateArray, Logic isBodyTopIncluded = true, Logic isBodyBottomIncluded = true )

Specifies separators to divide the table into rows:

  • isBodyTopIncluded == true - specifies the top of the table body
  • isBodyBottomIncluded == true - specifies the bottom of the table body
  • isBodyTopIncluded == false - the top of the table body is detected automatically
  • isBodyBottomIncluded == false - the bottom of the table body is detected automatically
Any specified separators outside the table search area are ignored.

Example
let yArray = RepeatingGroup.AllInstances.GetYArray(1);
RowSplitters( yArray );
Multi-page table parameters
Void HeaderOnEachPage( Logic has = true ) Specifies that the table header occurs on every page (at the beginning of each one-page sub-table).

See Table element dialog box Header tab, Header occurs on every page property.

Void AddHeaderKeyHypotheses( HypothesisInstances, TableBlockColumn ) Specifies a column name on multiple pages by means of a set of hypotheses for a subelement of a repeating group.

See Column element dialog box, Use found element as column name property.

Void FooterOnEachPage( Logic has = true ) Specifies that the table footer occurs on every page.

See Table element dialog box, Footer tab, Footer is on every page property.

Void AddFooterKeyHypotheses( HypothesisInstances ) Specifies a table footer on multiple pages by means of a set of hypotheses for a subelement of a repeating group.

See Table element dialog box, Footer tab, Use found element as footer property.

Void PreviousInstances( TableHypothesisInstances ) | Specifies the previous table instances if the table is inside a repeating group. It is assumed that the direction of instances is top to bottom, column boundaries have no shifts within the same page and may be slightly shifted horizontally between pages. The previous instances are used to search for or improve the search for columns if the table has no Header or if the Header is not detected.


Repeating Group

The following properties of a Repeating Group element must be specified in the Pre-Search Relations for all instances section. For details, see Additional search constraints for a Repeating Group element.

Parameter | Description
Void MinRepetitions( Int ) | Sets the minimum number of group instances in the document. See Element Properties dialog box, Repeating Group tab, the Min repetitions property.
Void MaxRepetitions( Int ) | Sets the maximum number of group instances in the document. See Element Properties dialog box, Repeating Group tab, the Max repetitions property.
Void PaginalMode( Logic value = true ) | Sets the Paginal search mode for group instances. See Element Properties dialog box, Repeating Group tab, the Paginal mode property.
Void MinRepetitionsOnPage( Int ) | Sets the minimum number of instances per one page. If the minimum number of instances is not detected, the repeating group is considered not detected. See Element Properties dialog box, Repeating Group tab, the Min repetitions on page property.
Void MaxRepetitionsOnPage( Int ) | Sets the maximum number of instances per one page. If a required number of group instances is detected on a page, the search stops on this page and continues on the next one. See Element Properties dialog box, Repeating Group tab, the Max repetitions on page property.


Labeled Field

A Labeled Field element is a Group element with predefined subelements. When you work with this element as one entity, its subelements are not visible and you cannot call their methods. To be able to access the methods of the subelements, turn the Labeled Field element into a usual Group element using command on the element's shortcut menu.

A Labeled Field has no specific methods or properties. The methods and properties common to all elements are described in the following sections:

  • Functions which limit the search area
  • Controlling searches
  • Debug functions which return information about the search area


Region

A Region element has no specific methods or properties. The non-specific methods and properties are described in the following sections:

  • Functions which limit the search area
  • Controlling searches
  • Debug functions which return information about the search area


Object Collection hypothesis

Int NumberOfObjects() The number of classified objects within the region of the hypothesis.


Character String hypothesis

String Value() The value of the text on the image within the region of the hypothesis.


Static Text hypothesis

String Value() | The value of the recognized text on the image within the region of the hypothesis.
Int LineCount() | The number of lines in the text of the hypothesis.
Rect LineRect( Int n ) | The rectangle of the text line with the index n. Note: The rectangles obtained through this function are sorted in accordance with their positions on the page, top down. The rectangles with smaller indexes are located higher up on the page (the index changes from 0 to LineCount() - 1)
XCoordinate LineLeft( Int n ) | The X-coordinate of the left-most point of the rectangle of the text line with the index n.
YCoordinate Linetop( Int n ) | The Y-coordinate of the top-most point of the rectangle of the text line with the index n.
XCoordinate LineRight( Int n ) | The X-coordinate of the right-most point of the rectangle of the text line with the index n.
YCoordinate LineBottom( Int n ) | The Y-coordinate of the bottom point of the rectangle of the text line with the index n.
XCoordinate LineXCenter( Int n ) | The X-coordinate of the centre of the rectangle of the text line with the index n.
YCoordinate LineYCenter( Int n ) | The Y-coordinate of the centre of the rectangle of the text line with the index n
Distance LineWidth( Int n ) | The width of the rectangle of the text line with the index n
Distance LineHeight( Int n ) | The height of the rectangle of the text line with the index n.


Text Fragment hypothesis

String Value() The value of the recognized text on the image within the region of the hypothesis.


Barcode hypothesis

String Value() The value of the recognized barcode


Date hypothesis

Int Day() | The value of the day in the date.
Int Month() | The value of the month in the date.
Int Year() | The value of the year in the date.
String Value() | The value of the recognized text on the image within the region of the hypothesis.


Currency hypothesis

Real Value() | The found numerical value.
Rect IntegerPartRect() | The rectangle which contains digits before the separator. Always not empty.
Rect FractionalPartRect() | The rectangle which contains digits following the separator Empty if there is no fractional part.
String CurrencyName() | The found currency name. Returns an empty string if the currency name is not found.
Rect CurrencyNameRect() | The rectangle which contains the name of the currency. Empty if no currency name has been found.


Phone hypothesis

String Value() | The value of the recognized text in the region of the hypothesis.
String Prefix () | The found phone prefix. Returns an empty string if the prefix is not found.
Rect PrefixRect() | rectangle which contains the phone prefix. Empty if the prefix is not found.


Table hypothesis

The following methods can be used to get a one-page hypothesis:

Int SubTablesCount() | The number of one-page subtables.
OnePageTableHypothesis SubTable( Int number ) | Returns the subtable with the specified number.
OnePageTableHypothesis LastSubTable() | Returns the last subtable.

The methods of the one-page table hypothesis OnePageTableHypothesis:

Logic HasHeader() | Shows whether the hypothesis has a detected (non-null) header
Logic HasFooter() | Shows whether the hypothesis has a detected (non-null) footer
Logic HasBody() | Shows whether the hypothesis has a detected (non-null) body
Hypothesis Header() | The hypothesis of the header of the table
Hypothesis Footer() | The hypothesis of the footer of the table
Hypothesis Body() | The hypothesis of the body of the table
Int ColumnsCount() | The number of columns detected in the table
Int RowsCount() | The number of rows detected in the table
Logic HasColumn( TableBlockColumn) | Shows whether the hypothesis of the table contains the selected column
Int ColumnIndex( TableBlockColumn ) | The number of the selected column in the order of the table hypothesis. The count starts with 0. If the column is not detected, the method returns -1.
TableHypColumn Column( TableBlockColumn ) | The column of the hypothesis of the table element that corresponds to the selected column in the table. A call for a non-existent column will cause errors at FlexiLayout matching.
TableHypColumn Column (Int columnIndex) | Same as the TableHypColumn Column (TableBlockColumn) method, but the number of the column in the table hypothesis is used. Columns are numbered starting from 0.
Rect RowRect (Int rowIndex) | The rectangle of the table row with the index rowIndex. Rows are numbered starting from 0.
Rect CellRect (Int columnIndex, Int rowIndex) | The rectangle of the table cell located in the column with the index columnIndex and in the row with the index rowIndex. Columns and rows are numbered starting from 0.
Rect CellRect (@FormTemplateBlock TableBlockColumn column, Int rowIndex) | The rectangle of the table cell located in the specified column and in the row with the index rowIndex. Rows are numbered starting from 0.


Table column hypothesis

From the hypothesis of the table element you can gain read-only access to the detected columns. To call a detected table, use the method Column( TableBlockColumn ). See the description of the hypothesis of the table element.

Logic HasLeftSeparator() | Shows whether the column has a black separator on the left
Logic HasRightSeparator() | Shows whether the column has a black separator on the right
Logic HasLeftSeparatorInHeader() | Shows whether the column name has a black separator on the left
Logic HasRightSeparatorInHeader() | Shows whether the column name has a black separator on the right
XCoordinate Left() | The left boundary of the column
XCoordinate Right() | The right boundary of the column
Distance Width() | The width of the column


Repeating Group hypothesis

Hypothesis LastFound() | The last detected instance. If used in the relations of an element not from the given repeating group, the last detected instance of this group is taken. If used in the relations of subelements of the repeating group itself, the previous complete instance of this group is taken.
Hypothesis CurrentInstance() | The current instance of the repeating group when searching for subelements of the repeating element. Used to create relations among subelements of an incomplete current instance of the repeating group.
Hypothesis Instance( Int instanceNumber ) | Instance number instanceNumber
HypothesisInstances AllInstances() | All the detected instances of the repeating group. If used in the relations among subelements of the repeating group itself, all the previous complete instances of the group are taken.
Logic HasInstances() | Checks if any instances have been detected.
Int InstancesCount() | The number of detected instances.


Labeled Field hypothesis

A Labeled Field element is a Group element with predefined subelements. The hypothesis for this element is generated in the same manner as for any Group element based on the hypotheses generated for its subelements. The hypothesis generated for a Labeled Field element has no specific properties. See the Hypotheses for all types of elements section for a description of the properties common to all elements.

The hypotheses generated for the subelements of this element may also be accessed. The properties of the hypothesis generated for the Label subelement are the same as the properties of a Static Text hypothesis. The hypothesis generated for the Field subelement may have the following specific properties depending on the type of content:

Field type | Property | Description
Any text | Text | The text of the hypothesis.
Fixed variants | Keyword | The words included in the hypothesis. For each word, the number of errors is indicated.
Number | Text | The text of the hypothesis.
Currency | Value | The detected numerical value.
 | Currency name | The detected currency name.
Date | Day | Day.
 | Month | Month.
 | Year | Year.
Phone | Number | The detected telephone number.
 | Prefix | The detected telephone prefix.
Regular expression | Text | The text of the hypothesis.


Region hypothesis

A hypothesis generated for a Region element has no specific methods or properties. The non-specific methods and properties are described in the Hypotheses for all types of elements section.


Hypotheses for all types of elements

A hypothesis for an element can be either found or not found. A found hypothesis, as a rule, is formulated on the basis of one or several image objects or their fragments (an exception is the White Gap element which may contain no image objects at all).

A found hypothesis for a simple element is always a continuous region. Hypotheses for White Gap, Separator, and Barcode elements are always single rectangles.

If a hypothesis is formulated on the basis of a set of detected image objects, e.g. a hypothesis for a Text Fragment element, the region of the hypothesis will be built on the basis of the array of rectangles of the detected objects. The region created in this way can be obtained by the Region method of the hypothesis. When displaying the region o f the hypothesis on the image, or when creating a block on the basis of the hypothesis, the boundaries of the region do not exactly follow the boundaries of each rectangle. Instead, the boundaries of the search area are smoothed out for better visualization. A region created in this way can be obtained using the SimplifiedRegion method of the hypothesis. The Region and SimplifiedRegion methods can be used either in the Advanced pre-search relations field on the Advanced tab (when describing the search area of the element), or in the Region expression field when describing the properties of the block and using the already found elements.

If a hypothesis was not found, it coincides with the fuzzy rectangle of its search area. When displaying a non-found hypothesis on the image, the program will draw the external rectangle of the fuzzy rectangle.

The Left, top, Right, and Bottom boundaries of any hypothesis are ranges. For each found hypothesis, the range degenerates to a point, i.e. Left.Start = Left.End, top.Start = top.End, etc. For a non-found hypothesis, the ranges of the boundaries coincide with the ranges of its search area.

Accessing generated hypotheses and their properties in the code of the corresponding dialog boxes of blocks and elements provides additional tools for setting up the FlexiLayout. Element hypotheses can be accessed by the names of the elements. To access a hypothesis for the current element in the Advanced post-search relations field, you can use only the name of the property.

Hypotheses and their properties are accessed in read-only mode. Hypotheses for elements can be accessed in the Advanced pre-search relations and Advanced post-search relations fields on the Advanced tab of the element's Properties dialog box as well as in the Region expression field in the block's Properties dialog box. In Advanced pre-search relations, you can access the generated hypotheses (and their properties) for all the elements located above the current element in the FlexiLayout tree. In Advanced post-search relations, you can access the generated hypotheses for the elements located above the current element in the FlexiLayout tree and the hypothesis for the current element itself. In Region expression, you can access the hypotheses (and their properties) for all the elements.

The table below lists the properties of hypotheses fro all types of element.

Logic IsNull() | Whether this is a null hypothesis.
Logic IsFound() | Whether the hypothesis is not null (the element has not been detected, IsNull property of the hypothesis is False). Equivalent to IsNull.
XInterval Left() | The left boundary of the hypothesis, horizontal range in global coordinates.
YInterval top() | The top boundary of the hypothesis, vertical range in global coordinates.
XInterval Right() | The right boundary of the hypothesis, horizontal range in global coordinates.
YInterval Bottom() | The bottom boundary of the hypothesis, vertical range in global coordinates.
XInterval XCenter() | The X-coordinate of the centre of the hypotheses, horizontal range in global coordinates.
YInterval YCenter() | The Y-coordinate of the centre of the hypotheses, vertical range in global coordinates.
DistInterval Width() | The width of the hypothesis in global coordinates, range of distances.
DistInterval Height() | The height of the hypothesis in global coordinates, range of distances.
FuzzyRect FuzzyRect() | Fuzzy rectangle of the hypothesis in global coordinates.
Rect Rect() | The rectangle circumscribing the hypothesis in global coordinates. Coincides with the external rectangle of the fuzzy rectangle.
Region Region() | The region of the hypothesis in global coordinates. The method is not supported for Group elements.
Region SimplifiedRegion() | The region of the hypothesis in global coordinates simplified for better visual representation. The method is not supported for Group elements.
ImageObjectSet Set() | The image objects which are part of the hypothesis.
ImageObjectSet ExcludeSet() | The image objects which are in the region excluded from the search area by methods of type Exclude.
RectArray Rects() | The array of the rectangles included in the hypothesis. For most elements, it coincides with the array of the rectangles enclosing detected objects. For White Gap and Region elements, no objects are available.
Int HypothesesCount() | The number of hypothesis which can be formulated for the element in the search area. Important! The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected document has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the corresponding method of the type Page.
PageInterval Pages() | The range of pages where the hypothesis is to be found.
PageArea PageAreaGlobal( Int PageNumber ) | Returns the part of the hypothesis located on the given page in global coordinates.
PageArea PageAreaLocal( Int PageNumber ) | Returns the part of the hypothesis located on the given page in the local coordinates of the page.
Example: accessing the properties of a hypothesis

Before you access the properties of a hypothesis for a simple or Group element, make sure that the hypothesis to be accessed is not a null hypothesis (call its IsNull property). Accessing a property of a null hypothesis (which corresponds to a non-detected element) will cause an error. Consider an example that uses the project from Sample 1 that can be found on the program CD-ROM.

Suppose there is an identifier on your document in the form of a barcode and you want your FlexiLayout to match only those documents on which the value of the barcode is 1556897142240. Do the following to achieve the desired result. In the Advanced post-search relations section of the element that describes the properties and search constraints of the barcode (element IdentityNumber in Sample 1), write the following code:
if value != "1556897142240" then Quality: 0;

Click Apply or Check. The compiler will not detect any syntax errors. It looks as if the code is OK. However, if you try matching the FlexiLayout with any page from Sample 1, the following error message will be displayed: "Error in element “MainGroup.IdentityNumber”, Advanced relations section: Attempt to access undefined hypothesis MainGroup.IdentityNumber."

The cause of error is as follows. The program finds a hypothesis for the barcode element. Then it compares the value of the barcode with the value specified in the code. If the values are different, the Quality: 0; code will reset the value of the hypothesis to 0. Then a null hypothesis is generated for this element, fro which the program also checks the condition value != "1556897142240." Since accessing the value of a null hypothesis is now allowed (it does not have this property), the program issues an error message "...undefined hypothesis..."
Therefore, you need to adjust the code as follows:

if not IsNull then {
if value != "1556897142240" then Quality: 0;
}

Note: The above code will work only for a required element. For an optional element, the code has to be adjusted as follows:

if not IsNull then {
if value != "1556897142240" then Quality: 0;
}
else {Quality: 0;}

Otherwise, only the quality of the real hypothesis will be reset to 0. This will cause the program to generate a null hypothesis, for which the "if not IsNull" will not be executed. Therefore the quality of the final (null) hypothesis will remain the same as was specified in the properties of the element (0.97 if the default value was kept) and the program will continue matching the FlexiLayout, even without the given element.

If you add else {Quality: 0;} to the code, the string will be executed for all hypotheses (including the null hypothesis) and the matching of the FlexiLayout will be stopped, because the complete chain of hypotheses will also be reset to 0 at this element.

Methods Region Region() and Region SimplifiedRegion() compared

The methods Region Region() and Region SimplifiedRegion() allow you to get the region of an element, but the method Region Region() gets the exact region:

while the method Region SimplifiedRegion() gets the rectangle created based on the boundary coordinates:


Conditional operators

In any section intended for entering code, you can use conditional if statements.

The if statement controls conditional branching. The body of an if statement is executed if the value of the expression is true. The syntax for the if statement has two forms.

Syntax

selection-statement :

if ( expression ) then statement
if ( expression ) then statement else statement

In both forms of the if statement, the expressions are evaluated.

In the first form of the syntax, if expression is true, statement is executed. If expression is false, statement is ignored. In the second form of syntax, which uses else, the second statement is executed if expression is false.


Printing to debug

In the Advanced pre-search relations and Advanced post-search relations sections, you can use the Print function, which prints information. This allows you to print information about certain properties of the formulated hypotheses.

The format of the Print function:

Void Print( String text )

The FlexiLayout language has global functions that are used to create string representations of various types and print debugging information (see the table below).

Function
String Str( Int )
String Str( Logic )
String Str( Real )
String Str( XInterval )
String Str( YInterval )
String Str( DistInterval )
String Str( Rect )
String Str( FuzzyRect )
String Str( Hypothesis )
String Str( RectArray )
String Str( Region )
String Str( Area )
String Str( PageInterval )

The global Chr( Int char ) function is used to format the printed lines using tab characters, carriage returns, etc. This function returns a string representation of a character by its Unicode code.

Examples of calling the Print function:

Print: Str( Group1.Item1.Width );
Print: "Is Item1 Null ? - " + Str( Group1.Item1.IsNull );
Print: "Calculate formula: ( 5 * 18 );" + Chr( 13 ) +Chr( 10 ) + "Result is: " + Str( 5 * 18 ) + Chr( 9 ) + "// example";
Print: Str( Group1.Item1.Rect );

Calling the Print function several times in a row in one of the Advanced… sections will print text consisting of several lines. The text will be printed in the Properties window of the active hypothesis in the Pre-search print and Post-search print properties.


Tips and tricks

This chapter describes several typical ways to create FlexiLayouts that would look for data fields on low-quality images. Such images are fairly common, with different scanning defects mostly caused by wrong scanning settings. For instance, an image may be too bright or too dark if brightness settings are not correct. As a result, some information on the image may be lost, or parts of the image may be noisy.

It is not always possible to rescan the documents, and the user often has to extract data from corrupted images. Moreover, some documents may have notes handwritten over useful information, which often causes recognition errors.

All the described instances of damage done to the text severely impair the quality of pre-recognition. The quality of pre-recognition may be improved by changing the recognition mode from Fast to Full. Unfortunately, this does not always help and greatly extends the pre-recognition time

When a FlexiLayout is created in FlexiLayout Studio, the following method is usually used. The user can specify in the FlexiLayout that pre-recognition results may be inaccurate, i.e. differ from the source text. This fact is reflected in the standard settings of an element, for example, in the maximum number of errors in an element of type Static Text, or the percentage of non-alphabetic characters in a Character String element. High pre-recognition quality is not actually required when searching for data fields. It is required, however, when the detected fields are recognized in FlexiCapture. These programs offer specialized data types for each field, significantly improving the quality of recognition. Pre-recognition in FlexiLayout Studio is full-page OCR, and practice has shown that this is usually enough to detect the data fields on a document.

In real life projects, it is usually enough to create just a few elements to get a FlexiLayout that can successfully process good-quality images. Any user can easily create a FlexiLayout that will detect the required data fields on about 70% of the images. Such a FlexiLayout can be used in FlexiCapture. A FlexiLayout can be updated and 'taught' to extract data from low-quality images. The degree of such modification depends on the task at hand and the time available to the user.

The modification of a FlexiLayout includes detection of previously undetected elements and the attempt to find them with the help of additional elements (maybe of a different type) with less strict search constraints.

There are also other situations which require modifications to the FlexiLayout, including creation of additional elements. The user often has to process similar forms received from different sources, for example, forms created in different regional branches of a government institution. Such forms, despite their apparent likeness, may differ in the layout of data fields. In such cases it advisable to create one FlexiLayout instead of several slightly different FlexiCapture templates.

Forms may differ by the types of separators used on them or they may be filled in not only by hand but also by means of a printer. When teaching the program to find such fields, use methods described in this chapter.

A FlexiLayout Studio project which contains test images and a tested FlexiLayout can be found in

<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

Detecting dates in the case of low quality pre-recognition

Setting multiple static text values. Search for static text with similar values

Using Exclude to exclude elements

Using Group elements to optimize FlexiLayout structure and search

Searching for single-line Static Text elements

Restricting search area with RestrictSearchArea

Search for single-line fields of known or unknown format on documents of different quality

Elements search with Nearest and FuzzyQuality

Optimizing Group element search

The property "Optional" of a Group element

Digit strings search

Simplifying the FlexiLayout with an auxiliary element with a null hypothesis

Description of text fields containing framed letters


Date search after high or low-quality recognition

Detecting dates in the case of low quality pre-recognition

This chapter describes several typical ways to create FlexiLayouts that would look for date fields on low-quality images. Such images are fairly common, with different scanning defects mostly caused by wrong scanning settings. For instance, the image may be too bright or too dark if brightness settings are not correct. As a result, some information from the image may be lost, or parts of the image may be noisy.

FlexiLayout Studio offers a special Date element that is used to detect dates. However, when creating a FlexiLayout you may find this element insufficient. This may happen when the date on the documents does not match any of the formats available in the Date element. For instance, FlexiLayout Studio allows only two languages (Russian and English) to be used in specifying the month in the date field. So, if the month is spelled out as a word in any language other than Russian or English, the date will not correspond to any of the available formats, and thus you will not be able to detect it by means of a Date element.

Date search errors can also occur if the image has form elements which cannot be removed. For example, the date may be underlined and there may be no visible gap between the date and the underline, crossed out or written in character cells with black separators (frames, combs). The inability to use the Date element for date search can also be caused by speckles in the search area, or by the fact that the date is not typed in but is filled in by hand.

The best way to organize a search for a date field is described in the sample project SearchOfDate.fsp

(see the folder <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Date\FCS project).

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

There are 5 pages in the project:

Page 1 - date format can be described by means of the Date element;

Page 2 - the month in the date is written in French;

Page 3 - the date is underlined;

Page 4 - the date field is noisy;

Page 5 - the date is filled in by hand.

Let us try and find the date on all the images including those where the date format is not supported by the element of type Date.

All the elements describing the date field are joined into a DateGroup element. First, this group has an element which looks for the name of the date field. In our project, this is an element of type Static Text named DateHeader with the only value 'Date:'.

Note: Setting up the search constraints for all the elements in the Relations section is not difficult and thus is not described here. You can look it up directly in the project.

Next we create an element of type Date named DateField. This element will search for date fields whose format is supported by the Date element.

As is seen in the project, the Date element can detect the date only on the first page.

To search for dates on the other pages, an element of type Character String is created. In our project this element is named DateAsString. All the characters that are likely to occur on the images are represented in this element by means of an alphabet.

Note: If the content in a data field can be structured and has a format which is not supported by the Date element, it is advisable, instead of specifying an alphabet, to describe this format with the help of a regular expression. However, you must be sure of the high quality of the processed images, as a regular expression presumes 100% match of the field and the described structure (alphabets, on the other hand, allow a certain percentage of errors. which is specified in the element's properties). Thus alphabets are a more flexible tool in the cases where accuracy of recognition can not be guaranteed. If you know that the month in the date will be written as a word in the same language as the pre-recognition language, then it may be advisable to divide the date field into three sections (day, month, year) and to search for the month field separately by using an element of type Static Text. Such a Static Text element should describe all possible variations of the month (e.g. full and abbreviated names of the month in the given language). Day and year fields will then be sought to the right and left of the month by means of elements of type Character String.

To optimize FlexiLayout matching, the following condition is provided in the Advanced pre-search relations field for the DateAsString element:

if (DateField.IsNull == FALSE) then Dontfind();

which is the same as:

if not DateField.IsNull then Dontind();

This condition means that a search for the date as a character string will only be initiated if the date cannot be detected by using a Date element .

As is seen in the project, the element DateAsString finds the date on the rest of the project pages, where it could not be detected by the element of type Date.

On Page 4, however, the detected string contains only part of the date field. If you look at the pre-recognition results for the date field (by clicking Show Raw Objects on the toolbar), the reason for the partial detection becomes clear: the search area contains not only text objects, but other types of objects as well: Picture and Punctuation mark. Such a situation is typical for low-quality images - text objects are not always recognized during pre-recognition.

To find all the objects associated with the date field, an element of type Object Collection is created and named DateAsObjectCollection. All object types detected in the date field during pre-recognition are specified in the properties of the element. To optimize FlexiLayout matching, the following condition is provided in the Advanced pre-search relations field for the DateAsObjectCollection and the DateAsString elements:

if (DateField.IsNull == FALSE) then Dontfind();

Note: The condition if (DateAsString.IsNull == FALSE) then Dontfind() can't be added to the Advanced properties of the DateAsObjectCollection element, because, as is clear from the example, there may be situations when the detected string contains only a part of the date.

At this stage the creation of elements describing the search constraints for the date fields may be considered complete. The Group element SearchElements.DateGroup.AlternativeDateGroup, which consists of the DateField, DateAsString, and DateAsObjectCollection elements, is specified in the project tree as a Source element for the Date block. Since the Dontfind() method was used to describe the properties of the DateAsString and DateAsObjectCollection elements, the actual region of the detected block will match either the region found by the hypothesis for the Date element or the combined regions of the DateAsObjectCollection and the DateAsString elements. In the latter case, we expect the region of the DateAsString element to be part of the region of the DateAsObjectCollection element, so the resulting region will be the region of the DateAsObjectCollection element.

Note: In this case we can specify the Group element SearchElements.DateGroup.AlternativeDateGroup as a Source element, because the situation is relatively simple. The region of the group is a combination of the regions of its detected subelements. The Dontfind() method allows skipping the search for some of the subelements. Thus the region of the Group element SearchElements.DateGroup.AlternativeDateGroup will match the region of the subelement. In the given example, the Dontfind() method not only helps to optimize FlexiLayout matching, but also makes the description of blocks simpler.

Alternatively, we could use the code specified in the Expression section.

Rect OutputRect;

let dateGroup = SearchElements.DateGroup.AlternativeDateGroup;
if (dateGroup.DateField.IsNull == FALSE) then
outputRect = dateGroup.DateField.Rect;
else
outputRect = dateGroup.DateAsObjectCollection.Rect;
OutputRegion = outputRect;

The use of a Expression provides for additional options. For example, we could check if the region of the DateAsString element is really a part of the region of DateAsObjectCollection.

Note: Using a Character String element to look for a date field, without defining the string format or using an element of type Object Collection, like in the given example, can lead to good results if the search area of the date field can be clearly defined. But if there are several character strings in the search area, then the string format should be described by means of a regular expression or a narrower alphabet. Otherwise, the final hypothesis can be unsatisfactory. By using the element of type Character String, the user can limit the number of characters in a string, the number of word ends and the length of spaces to filter out wrong hypotheses. If an element of type Object Collection is used, the hypothesis will include all the objects on the image that are located within the search area and meet the constraints on the object size.


Setting multiple static text values. Search for static text with similar values

To detect various titles of forms, tables, fields, or any text present on all or most of the images in a document, FlexiLayout Studio uses a special Static Text element. If different images which are to be processed by means of the same FlexiLayout have different variations of one and the same name (for example, the field 'Invoice number' has variations 'Invoice,' 'Invoice:,' 'Invoice No.,' etc.), you must specify all the possible static text values even if they only differ in punctuation marks.

This is necessary due to the following reasons:

  1. To generate a hypothesis corresponding to the specified value. For example, if we do not specify the variant 'Invoice:' but only specify the variant 'Invoice', the colon will not be included into the hypothesis for the field name. It may then be included into the search area of the invoice number which the program will search to the right of the name. If the search for the number allows non-digit or non-specified characters, then the column may get into the hypothesis of the element that describes the invoice number.
  2. To avoid penalizing a hypothesis for characters not specified in the Search text window. For example, if the value 'Invoice:' is specified in the Search text section and the name 'Invoice#' is also encountered on the processed images, then, provided that some errors are permitted for the element, a hypothesis will still be generated but its quality will be penalized (in this example the FlexiLayout allows at least 1 error).
  3. If there are variant hypotheses available, for example, 'Invoice|Invoice:', the program will assign the longer hypothesis a slightly higher quality, so that the hypothesis 'Invoice:' will be preferable. If a variant with ':' is specified, then the one without ':' will be penalized by 0.001, because the string 'Invoice' is a sub-string of 'Invoice:'. Penalizing the shorter name string, which is a sub-string of the other, makes the longer hypothesis the winner.

Let us use the sample project StaticText.fsp

(folder <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Variants of StaticText\FCS project)

to see how specifying the values of a Static Text element helps to detect the name of the 'Invoice number' field and the field itself.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

The project has 5 pages:

Page 1 - the field "Invoice number" has the name "INVOICE";

Page 2 – the field "Invoice number" has the name "Invoice:";

Page 3 – the field "Invoice number" has the name "Invoice #:";

Page 4 – the field "Invoice number" has the name "Invoice -";

Page 5 – the field "Invoice number" has the name "Invoice:", but the page also has
a field "Invoice date", where the word "Invoice" is present.

In the Properties dialog box of the Static Text element named InvoiceHeader, we have specified all the possible names for the field that may be found on the processed forms. In this case, these are the abovementioned values. Letter-case in the names is irrelevant for search purposes.

Invoice|Invoice:|Invoice#:|Invoice-.

Note: To speed up the search for the element, all the variants are written without spaces. Absence or presence of spaces does not influence the quality of a hypothesis.

For the sake of simplicity, let us assume that the invoice number is always located to the right of the name. To search for the invoice number, a Character String element named InvoiceNumber has been created. Its alphabet and search constraints are specified in the Relations field. These settings are very simple and are not described here. You can look them up directly in the project.

A text block Invoice has been created in the FlexiLayout tree. The element InvoiceNumber has been specified as the Source element for the block.

As you can see after running the analysis procedure, the field name and the invoice number can be successfully detected on all the pages.

Now try removing temporarily all the static text values but the first (Invoice) from the InvoiceHeader element, and then try matching the FlexiLayout with all the pages again. You will see that the name and the invoice number have been successfully detected only on Page 1, because the name there fully matches the specified value (Invoice). On Pages 2-4, a part of the name got into the invoice number. On Page 5, there was an error in locating the number field.

Let us now restore the removed values. Look at the analysis results on Page 5, where the word Invoice occurs twice. As can be seen, the program generated 5 hypotheses for the InvoiceHeader element. The highest quality (Chain quality = 1, which, in this case, is equal to the Pre-search quality) is assigned to the hypothesis for the name "Invoice:". Hypotheses were also generated for the values "Invoice" and "Invoice d", because these strings are derivatives of the values specified for the InvoiceHeader element, for which a certain percentage of errors is allowed. These hypotheses were penalized (Cf. the above arguments for listing all the possible Static Text values), so their final quality is lower.


Using Exclude to exclude elements

When creating a FlexiLayout, the search areas cannot always be defined in terms of "top-bottom-left of-right of". This is particularly true when the search area contains unwanted objects, e.g. objects that may have been introduced during scanning. These objects should not make it into the recognition block, so they have to be excluded when creating the corresponding element. The field of the address in the figures below is a good example. What is meant here is the mutual location of the field names "Address:", "(Address)" (which must be excluded from recognition) and the address itself (which should be recognized).

The Exclude function excludes a region from the search area of an element. The region to exclude is specified when calling the function. The excluded region may be either the region of a hypothesis (detected or not), a rectangle or an array of rectangles of the found elements, or a region built from the regions of objects which are part of a found hypothesis (see ExcludeSet method).

Let us study the Exclude.fsp project

(<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Exclude\FCS project folder)

to see how the Exclude function works.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

The project has 4 pages:

Page 1 - the address field is written in several lines. The name "Address:" is in the first line, so we cannot say that the sought data field is to the right of or below the field name. However, the name still has to be excluded from recognition;

Page 2 – the address field has no name;

Pages 3 and 4 – the line "(Address)" lies within the data field. However, it has to be excluded from recognition.

On all the pages the address field is below the field with the company name.

First we create an element of type Static Text, name it CompanyHeader and specify its value. This element will be used to detect the name of the <company name> field.

Next we create an element of type Static Text and name it AddressHeader. This element will be used to detect the name of the <address> field. We specify the following static text values: Address:|(Address), i.e. we list all the variants of this line that should be detected and then excluded from recognition in the address field. We describe the search constraints for these lines in the Relations field and specifying that these lines should be looked for below (Below) the CompanyHeader element.

Note: The element for the name must be created before the element for the address field, because the Exclude function only allows referring to elements that are higher up in the FlexiLayout tree than the current element.

Launch the FlexiLayout matching procedure (Match FlexiLayout) to make sure that the name of the address is found on all the pages where it occurs.

Since the address field in this example has multiple lines, we create an element of type Text Fragment to search for it. We name it Address and, as in the previous example, specify that it should be looked for below (Below) the CompanyHeader element.

Once you have run the FlexiLayout matching procedure, you will see that on pages 1,3 and 4 the line of the name has also been included into the address field.

Now let us go back to the Properties dialog box of the Address element and click the Search Constraints tab. Click Add… next to the Exclude elements section and choose the AddressHeader element from the list.

After saving the properties of the element, run again the FlexiLayout matching procedure. You will see that the region of the block which corresponds to the address field acquired a non-rectangular shape, because the region of the name has been cut from it.

Note 1: The Exclude elements section allows you to exclude from the search area of the current element the region of a found hypotheses for another element. To exclude a more geometrically complex area, or to detect a region first and then exclude it from the recognition process, then you should use the functions Exclude, ExcludeRect and ExcludeSet in the Advanced pre-search relations field.

Note 2: The region of a block by definition consists of rectangles placed one upon another, so any horizontal line can cross the region only once, i.e. there can be no vertical "teeth" jutting out. Therefore, if the line to be excluded and the required information are located as shown in the figure below (i.e. on the same or roughly on the same level), then the name cannot be excluded at the stage of FlexiLayout creation. In that case the name can be excluded after recognition in FlexiCapture by using the "Substitute from the list" rule.


Using Group elements to optimize FlexiLayout structure and search

Using Group elements to search for objects is most efficient, because grouping elements together reduces the number of hypotheses for an element and speeds up the search for the resulting hypothesis for the whole FlexiLayout. Moreover, if the grouping of the elements reflects the logic of the document, it helps to optimize the structure of the FlexiLayout and makes it more explicit.

Grouping several elements together into one Group element enables the program to treat this set of elements as a whole with its own hypothesis (composed of individual hypotheses for elements in the group). Analysis of hypotheses and their elements takes place within the Group element, and only the user-specified number (1 by default) of the best hypotheses are used in the subsequent search for other elements.

The entire tree of elements can be regarded one Group element, the best hypothesis for which is the result of matching the FlexiLayout .

Let us study the GroupSample.fsp project

(<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Group\FCS project1 folder)

to see how Group elements can be used. Here we have an image where we want to detect fields with the invoice number, the invoice date, and the invoice sum.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

As is seen on the image (the same is usually true for all financial documents), the number and the date of the document are neighboring fields. Even if the arrangement of the fields on another form is different, they still will be close to each other. Furthermore, they are connected by the logic of the document, as they describe certain bank details and form a logical block. To make the structure of the FlexiLayout more explicit, we will group them into a Group element named InvoiceRequisiteGroup.

Note: Prior to grouping the elements, we created a special identifying element. (Identifier elements are described in detail in the section "Identifying and Processing FlexiLayouts in ABBYY FlexiCapture".) This element was only created to illustrate the "branching out" of the tree of hypotheses caused by the presence or absence of Group elements in it. Let us assume that all the elements in the tree, except the identifier element, are optional, and their null hypotheses have the default quality of 0.97.

The first element in the Group is an element of type Static Text, named InvoiceNumHeader, which describes the search constraints for the name of the field "Invoice number". The string "Invoice" is specified as the value of this element.

Based on the analysis of the images at our disposal, we will search for the invoice number to the right of the name, with the help of an element named InvoiceNum.

Similarly, under the line with the invoice number we created an element for the date field and named it InvoiceDateHeader. To search for the date itself we created the group DateGroup with the following subelements: InvoiceDate and InvoiceDateAsString. See "Creating FlexiLayouts for poor quality images" for more details.

To detect the field with the invoice sum, we created two elements: an element of type Static Text named TotalSumHeader (its value "Totalsum(EUR):" is written without spaces), and an element of type Character String named TotalSum (the latter will be used to look directly for the sum).

Note: We do not describe here the settings of the elements. You can look them up directly in the project.

Please note that the string "Invoice", specified as the value of the element InvoiceNumHeader, can be encountered on the test images three times: as the name of the field "Invoice number", as a substring of the name of the field "Invoice date", and at the bottom of the invoice, as a substring in the invoice conditions: "Current invoice is…". It is also important to note that the name "INVOICE" (which we are going to detect by means of the InvoiceNumHeader element ) is very noisy, which caused an error in the name. In the other lines, the string "Invoice" is clear, and the quality of the corresponding hypotheses must be higher than that of the hypothesis for the name.

Now try matching the FlexiLayout with the test images in the batch.

Once you have started the FlexiLayout matching procedure by selecting the Match command, you will see that the tree of hypotheses consists of a single chain.

The tree of hypotheses consists of just one chain.
The quality of the Group coincides with the quality of the best chain in the Group.

Double-click InvoiceRequisiteGroup to open its Properties dialog box where we can see what hypotheses were generated for its subelements, which chain in the Group turned out to be the best and why.

We see that there are three hypotheses for the InvoiceNumHeader element, equal to the number of "invoice" strings detected. The quality of the hypothesis we are interested in is lower (approximately 0.99), because its area on the image is noisy and the program could only recognize "INVOIC" instead of "INVOICE". The quality of the other two hypotheses, however, is maximum (Chain quality = 1).

At the creation of the InvoiceNum element we specified that the invoice number can have any number of digits and should be sought to the right of the name. On our image these conditions are met in all the three cases, which enabled the program to continue creating a chain of hypotheses for each of the hypothesis for the name of the "Invoice number" field . It should be noted that, in spite of the fact that the Pre-search quality of each of the hypotheses of the InvoiceNum element is 1, the chain that we consider to be correct is still the worst. This happened because chain quality is assessed by the multiplying the qualities of all the hypothesis forming the chain. For the required name this quality is about 0.99. If the Group did not have any other elements, the final choice at this stage would be incorrect.

Note: We did not specify Post-search relations for any of the elements, so for each of the elements Post-search quality = 1, and we can judge the quality of any given hypothesis by its Pre-search quality.

The search for the best hypothesis is done within the Group. The quality of all the chains is analyzed and compared.
The quality of the Group will be determined by the quality of the best chain in the Group.

As we noted above, in the properties of the InvoiceDateHeader element we specified that it should be sought under the line with the invoice number. However, none of the chains with the best quality (Chain quality = 1) resulted in a hypothesis for the name of the date field. Consequently, null hypotheses were formed in these chains for the InvoiceDateHeader element. Since we did not change the default quality of a null hypothesis, the resulting Chain quality of the corresponding chains dropped to 0.97. At the same time, the element corresponding to the name of the date field was found for the chain that had the lowest quality. The quality of its hypothesis is approximately 0.993. It is less than 1 not because the image in the area of the name is noisy, which resulted in a recognition error and an incomplete match between the recognized text and the value specified in the properties of the InvoiceDateHeader element. As a result, the found hypothesis was penalized and its final quality is about 0.98 (the result of multiplying 0.99 by 0.993). Nevertheless, the final quality of this hypothesis is higher than that of the others (0.97), so at this stage this chain is the best.

To detect the date field, we created the Group element DateGroup, which specifies that at least one of the elements cannot be found if the other has been found (the Dontfind function was used). As a result of the form layout features and the properties specified for the InvoiceDateAsString element (its alphabet allows digits), the program managed to find the date field for all the chains, though only one hypothesis in the three is actually correct.

Since in each Group one of the elements has been found while the other has not, the final quality of the chain in each of the DateGroup groups is 0.97 (1 multiplied by 0.97, the default quality of the null hypothesis). In this example, the final quality of the DateGroup chains will not affect the "balance" among the hypotheses at the moment of detecting the InvoiceDateHeader element, i.e. the quality of each of the chains will be simply further multiplied by 0.97.

At the end the program generated a single hypothesis for the Group element InvoiceRequisiteGroup, which corresponds to the best chain in the Group. Its quality is approximately 0.953, i.e. the "group approach" helped the right hypothesis win, even though its initial quality was lower.

To illustrate how the tree of hypotheses would look like without Group elements in the FlexiLayout, we created the GroupSample.fsp project (Group\FCS project2 folder ). The tree can be seen in the figure below. As is clear from the figure, after detecting the FormID element, the tree of hypotheses branched out because several hypotheses are generated for the InvoiceNumHeader element. As a result, the program has to compare the qualities of each of the chains, starting every time from its very first element and moving down to the last. Moreover, for any document with a layout more complex than the one in this example, a FlexiLayout without Group elements will produce a tree of hypotheses with too many branches, which will make FlexiLayout matching more difficult.

Note: It is not recommended to place all the sought elements into one root group. This is only suitable for very simple FlexiLayouts with fewer than 10 elements, which is very rare in real-life tasks. An increase in the number of elements in the root Group causes massive growth of the number of hypothesis, until it reaches its limit of 10,000 or the memory allocated for the tree of hypotheses is all used up. In either case, matching the FlexiLayout may fail.

In real-life tasks there is usually no need to explore all the possible combinations of every hypothesis for one element with every hypothesis for every other element, as most of the elements might be detected independently from one another. That is why it is advisable to Group elements into the smallest possible Group elements, so as to reduce the number of combinations to analyze and speed up the search.

An ungrouped tree of hypotheses has too many branches and its visual analysis is difficult.
Moreover, since the quality of the final chain is calculated by multiplying the qualities of all the hypotheses in that chain, the volume of calculations may be much higher in a tree with too many branches, which will results in slower FlexiLayout matching.


Searching for single-line Static Text elements

If you need to detect a string of static text and you know that this field has only one line on all the images, it is advisable to enter the text value without spaces. It speeds up the search and does not affect the quality of the found hypothesis.

Note: This is only true if the static text of the name has been recognized without errors. This is because the maximum number of errors (set for Static Text elements by two parameters: Max number of errors and Max error percentage) means the number of errors in a word. Thus, if the Max number of errors is set to 1, the name consists of 3 words, and the value of the Static Text is entered without spaces, the program can make no more than 1 mistake during recognition. When entered without spaces, the name is perceived by the program as a single word, regardless of the actual number of words in it. But if you separate the words in the name with spaces, the allowed number or percentage of errors will apply to each of the words you typed in the Search text field. If any recognition errors are made in a Static Text, the hypothesis is penalized in accordance with a certain algorithm, and the quality of the hypotheses with and without spaces may be different.

Let us study the Spaces.fsp project

(<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Spaces in StaticText\FCS project 1 folder)

and learn some methods of working with Static Text elements.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

The project has 2 pages:

Page 1 – the quality of the image is good;

Page 2 – the name of the data field is noisy.

We are going to search for the data field "Father's name" related to the name "Please indicate your father’s name here:"

In the project, we created an element of type Static Text and named it NameOfFatherHeader. We specified its value as one word without spaces (i.e. Pleaseindicateyourfather'snamehere:). Letter-case in the name is irrelevant. We left the default values for all the other properties of the element. The maximum number of errors in the name is 10 characters (30% of the 35 characters which make up the text).

Once you have run the FlexiLayout matching procedure by selecting the Match command, you will see that the name has been successfully detected on both pages. However, on Page 2 the Chain quality of the element hypothesis is about 0.994, because it has been penalized for the recognition error caused by the noise on the document.

Note: To see the pre-recognition results for the sought name, click "L" ("Show Recognized Lines") on the toolbar and point at the text of the name. The pre-recognition result for the field name on Page 2will look like this: "PLEASEINDICATE|OURFATHER'SNAMEHERE:". Alternatively, you can display the detected Static Text by selecting the hypothesis of the NameOfFatherHeader element in the Tree of Hypotheses window and moving your mouse pointer to the line Keyword in the Properties-Hypothesis window. In this case the pre-recognition results and detected errors (if any) will be displayed in the bottom part of the Properties-Hypotheses window.

To detect the data field "Father's name" we created an element of type Character String, because the sought data field has only one line and its value, unlike Static Text, changes from document to document. We named the element FathersName and specified its properties in the Relations section. Then we created a block with the same name in the FlexiLayout and specified that its region coincides with the region of the FathersName element (we selected the name of the element FathersName in the Source element field).

Now let us try matching the FlexiLayout with the same images but enter the value of the NameOfFatherHeader element as words separated by spaces.

To do this we created the Spaces.fsp project (Spaces in StaticText\FCS project 2 folder). The value for the element NameOfFatherHeader looks like this: Please indicate your father's name here:. All the other settings are left unchanged (they are identical to those of the Spaces.fsp project located in the Spaces in StaticText\FCS project 1 folder).

Once you have run the FlexiLayout matching procedure by selecting the Match command, you will see that the field name has been successfully detected on both pages. However, the Chain quality for the hypothesis of the NameOfFatherHeader element on Page 2 is now about 0.987, because the hypothesis was penalized for one recognition error caused by the low quality of the initial image.

Note: Please note that if there are spaces in the Static Text value you type in the Search text field, each word will be analyzed individually and the maximum number or percentage of errors will apply to each of the words. The final quality of the Static Text hypothesis will then depend on the qualities of these separate words.


Restricting the search area by means of RestrictSearchArea

The function RestrictSearchArea allows you to specify the search area as a rectangle, an array of rectangles, or a region.

On different pages of the document the sought field is often located differently relative to its name. For example, on some pages the field can be to the right of the name, on the others it can be under the name. In such cases it is advisable to specify the search area as an array of rectangles. See "Using Nearest and FuzzyQuality to look for elements" about the use of the RestrictSearchArea function in such cases.

It may also be advisable to use the RestrictSearchArea function instead of doubling search constrains that are identical for several elements.

Use this function to describe the search area of the date field or any other field when, for some reason (e.g. low image quality or layout peculiarities), the use of an element of one type is not enough.

Let us see how the RestrictSearchArea function can be used to search for a date field. It is usually recommended to search for date fields with the help of at least two types of elements: Date and Character String. But if the image quality is very low, these two elements may not be enough. See "Detecting dates in the case of low quality pre-recognition" for more details on how to organize a search for date fields.

Let us see this function at work by taking by running the sample project SearchOfDate.fsp ((<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\RestrictSearchArea\FCS project folder ). This project is actually a copy of the project of the same name from the Date\FCS project folder . The search constraints for all the elements in it (DateField, DateAsString and DateAsObjectCollection) were identical and looked as shown in the figure below.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

But in the current project, instead of doubling the search constraints in the Relations tab for the elements DateAsString and DateAsObjectCollection, we use the function RestrictSearchArea by writing the following code in the Advanced pre-search relations field on the Advanced tab:

if (DateField.IsNull == FALSE) then Dontfind();

else RestrictSearchArea (DateField.Rect);

This code means that searching for the date field as a string or as an object collection will only be attempted if the program fails to detect it by menas of the Date element. And both elements will be looked for in the very area where the element DateField has not been detected. It so happens because the DateField.Rect method restores the rectangle enclosing the hypothesis of the DateField element. Since the hypothesis has not been found, the enclosing rectangle will coincide with the search area. Therefore, we specify a search area for the DateAsString and DateAsObjectCollection elements which coincides with the rectangle enclosing the search area of the undetected DateField element.


Searching for single-line fields of known or unknown format on documents of varying OCR quality

To detect single-line fields, FlexiLayout Studio has a special Character String element. If the sought field has a known format, then it can be described in the properties of the corresponding element on the Character String tab in the Regular expression field. But the use of a regular expression demands printed forms and a good image quality, because description with a regular expression does not permit any errors to be made in the field, otherwise the element simply will not be detected. Regular expressions also must not be used if the form is filled in by hand, even if its layout can be described. Nevertheless, such a field can be detected.

The search for a single-line field "Invoice number" with a similar format on all the pages is shown in sample the project StructuredStrings.fsp (<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Structured strings\FCS project folder).

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

The project has four pages:

Pages 1 and 2 - the field "Invoice number" is filled in by means of a printer, printing quality is good;

Page 3 – the field "Invoice number" is filled in by means of a printer, the image is noisy;

Page 4 – the image quality is good, but the field "Invoice number" is filled in by hand.

We are going to look for the field "Invoice number" relying on the field name. First we need to create an element describing the search constraints of the field name. The created element is of type Static Text, named InvoiceNumberHeader and has the value "InvoiceN:".

The field "Invoice number" is a single-line field. To detect it, we have created an element of type Character String, named NumAsRegularExpression. As can be seen on the pages of the project, the format of the field "Invoice number" can be described with the following regular expression:

NNNN"-"NN"-"[A-Z]"/"NN or (which is the same) [0-9]{4}"-"[0-9]{2}"-"[A-Z]"/" [0-9]{2}

It means that the number is a sequence:

"four digits - two digits - one Latin capital letter/two digits"

As is seen in the project, after running the FlexiLayout matching procedure by selecting the Match command, null hypotheses were generated for the element NumAsRegularExpression on pages 3 and 4, i.e. the element was not detected. On page 3, the noise caused a mismatch of the field and the regular expression. If you open Page 3 and click "L" ("Show Recognized Lines") on the toolbar, the pre-recognition of the invoice number on the page will look like "10&0-20-A/04". On Page 4, the invoice number is filled in by hand. You can see in the results of pre-recognition (Z.OOO-41-C/03) that it does not match the described format either.

The following solution to this problem is recommended. We create one more element of type Character String and named NumAsAlphabet. We specify for it the same search constraints as for the NumAsRegularExpression element. Then we group the two elements into one Group element InvoiceNumber. But we describe the element NumAsAlphabet not as a regular expression but as a list of all valid characters.

The following code should be written in the Advanced pre-search relations field:

if (NumAsRegularExpression.IsNull == FALSE) then Dontfind();

This means that the search for a string of an unknown format, described by the element NumAsAlphabet, will only be attempted if the program fails to detect it by means of the NumAsRegularExpression element, which describes a string of fixed format.

Note: When specifying search constraints for the NumAsAlphabet element, you can use the drag&drop method to copy the settings from the section Relations of the element NumAsRegularExpression into the same section of the current element. Alternatively, the following code can be written in the Advanced pre-search relations field:

if (NumAsRegularExpression.IsNull == FALSE) then Dontfind();

else RestrictSearchArea (NumAsRegularExpression.Rect);

This code means that a search for the element NumAsAlphabet will only be attempted if the structure of the invoice number doesn't match the specified format, i.e. the program failed to detect the element NumAsRegularExpression. And the element NumAsAlphabet will be looked for in the same area where the element NumAsRegularExpression wasn't found.

Now we start again the FlexiLayout matching procedure on all the pages. As is seen in the project, the invoice number field is now successfully found on each of the pages.

In the project tree we created a text block named InvoiceNum. The group SearchElements.InvoiceNumber is specified as its Source element. At this stage the creation of a FlexiLayout to detect "Invoice number" fields is complete.

Note: If, for some reason, the method described above is not sufficient for detecting the data field (whether its format is known or unknown), then one more element (of type Object Collection) can be created in the group. In this project, it is the element of type Object Collection, named NumAsObjectCollection. It is not actually needed given the good quality of the images in our project and is only shown as an example (the Disable command is specified for it). Introduction of an additional element of type Object Collection might be needed when it is difficult to predict pre-recognition results on different pages, but the search area can be accurately described, preventing unwanted information from getting into the hypotheses.

The following question may arise: why a regular expression is needed if the field can sometimes be detected without it? The answer is that the use of a regular expression makes the search more reliable. If this element is found, then you can be sure that you have found the very line that you need. This information can then be safely used to detect further elements and their relations. When the search constraints are lax, you cannot be absolutely sure that you have found exactly what you need.

This may happen if the image is very noisy. In such cases, the use of an element of type Character String with a specified alphabet can lead to the excessive percentage of errors (the Percentage of non-alphabet characters parameter). As a result, the element will be either not detected at all, or detected only partially. The example of such a situation is given in the picture below.


Using Nearest and FuzzyQuality to search for elements

Important! For the sake of simplicity, a one-page document is used in this sample.

In forms processing there are often situations when it is not enough to describe the location of elements relative to other elements in terms of the "above - below - to the right - to the left" kind. This may happen, for example, if in the search area there are several objects matching the search constraints. In such situations we need additional differentiating properties, specifically - the distance between the objects. For these purposes FlexiLayout Studio has the FuzzyQuality function, as well as the functions of the group Nearest (Nearest, NearestX, NearestY).

The applications of these functions are different.

The function Nearest can only be used in the Advanced pre-search relations field. It specifies that, among the several hypotheses of the element, the program must look for the nearest one to a certain element or point on the image set in the properties of the Nearest function. In the Advanced pre-search relations field of the element, only one function of the Nearest group can be used. After it is run, only one hypothesis is left, and it happens at the stage of hypotheses generation, i.e. before the code specified in the Advanced post-search relations field is run. There is no guarantee that the remaining hypothesis is the best (and corresponds to the required object of the image), because Advanced post-search relations are very important for assigning a quality value to a hypothesis. When using the function Nearest, the choice of hypothesis is made at the stage of hypotheses generation and is based on the proximity to some point, not on the quality of the hypothesis. It should always be taken into consideration that if the properties specified in the Advanced post-search relations section are important for the correct selection of the hypothesis you should use the FuzzyQuality function instead of the functions of the Nearest group.

The FuzzyQuality function can only be used in the Advanced post-search relations section. Unlike the functions of the Nearest group, it doesn't select a single hypothesis but instead influences the overall quality of all the generated hypotheses based on the properties of these hypotheses and the parameters of the function FuzzyQuality. Besides, the FuzzyQuality function can be used multiple times for a single element in the Advanced post-search relations field. This means that several different constraints with different quality values can be applied to a hypothesis. All the values will be multiplied to determine the Post-search quality of the hypothesis. The FuzzyQuality function looks as follows:

FuzzyQuality: x, {f1, f2, f3, f4};

Its algorithm is as follows: the function checks whether the value of the parameter x belongs to the interval defined by the parameters f1, f2, f3, f4. The meaning of this fuzzy interval is similar to the fuzzy intervals specified for some of the parameters of the Character String element.

Let us see how the Nearest and FuzzyQuality functions can be used on the following images.

As is seen from the pictures, the form of the invoice is semi-structured, as the arrangement of the fields is different on different images. We are going to detect the fields "Invoice number" and "Invoice date".

To do this, we created the NearestAndFuzzyQuality.fsp project (<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\FuzzyQuality and Nearest \FCS project 1\FuzzyQuality and Nearest \FCS project 1 folder).

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

To optimize the FlexiLayout structure and to follow the logic behind the arrangement of the sought fields in the form, we grouped all the sought elements into a compound element, InvoiceGroup. We can start FlexiLayout creation with the creation of an element describing the search constraints for the name of the field "Invoice number". But the analysis of the images shows that the word "Invoice", which makes up the name, is encountered on the form several times. Since the relative location of the fields changes each time, we cannot specify the constraints that would guarantee the correct detection of the word "Invoice". It may, for example, be found in the name "Invoice date". To avoid such confusion, we started the description of the name of the date field by using an element of the Static Text type, named DateHeader. In the Search text field we specified two values of the name: Invoicedate:|Invoicedate (listing the variants of the name as they occur on the images). The letter case of the name is irrelevant.

Note: See "Setting multiple static text values. Search for static text with similar values" for details on why you must specify both the variants.

We are going to look for the date field relying on the field name. In the project we have created a group DateAlternative, which consists of two elements: a Date element to search for the date field in one of the specified formats, and an element of type Character String, in case the format of the sought field is different.

Note: See "Detecting dates in the case of low quality pre-recognition" for a detailed description of creating a FlexiLayout for date search.

As is seen form the images, the date field can either be located to the right of the name "Invoice date" or below it. If we set standard search constraints in the Relations field (these are displayed in the project, but disabled), then the search area will be too large, and may enclose some fields that may be mistakenly taken for the date field (an example is shown in the picture). This may happen, for instance, if the date doesn't match the format specified for the element Date.

To prevent the program from analyzing the unwanted area, we used an alternative method. In the Advanced pre-search relations field we wrote the following code:

let Header = InvoiceGroup.DateHeader;

if not Header.IsNull then

{ let rect1 = Rect (Header.Rect.Right, Header.Rect.Top-20dt,

PageRect.Right, Header.Rect.Bottom+20dt);

let rect2 = Rect (Header.Rect.Left - 200dt, Header.Rect.Bottom,

Header.Rect.Right + 150dt, Header.Rect.Bottom+200dt);

RectArray ar;

ar = RectArray ( rect1 );

ar.Add ( rect2 );

RestrictSearchArea( ar );

}

else

{ Above: PageRect.Top + PageRect.Height/2;

}

The code checks whether the name of the date field has been found. If it has been found, we specify the search area as an array of rectangles (in the example - 2 rectangles). One rectangle searches for the date to the right of the name, the other - below the name. If the name is not found, the search will be run in the upper half of the image.

In the case of a page where the search constraints were specified in the Relations section, the form of the search area after running this code will be different from a rectangle. As is seen in the picture, all the unwanted objects were removed from it.

Note: The first line of the code (let Header = InvoiceGroup.DateHeader;) simplifies the code by defining the variable Header and assigning it the value of the element DateHeader.

We didn't duplicate the above code for the element DateAsString, but wrote the following search constraint in the Advanced pre-search relations section:

if not Date.IsNull then Dontfind();

else RestrictSearchArea (Date.Rect);

It means that if the element Date is not detected, the search will be run in the rectangle enclosing the search area of the element Date.

Note: To specify the search area of the element DateAsString as an array of rectangles, instead of calling RestrictSearchArea (Date.Rect), duplicate the corresponding code from the Advanced pre-search relations section of the element Date.

Then we created an element of type Static Text (named InvoiceHeader) to detect the name of the field "Invoice number", and specified the sought value: "Invoice". Since the form is not structured, we are unable to give any specific search constraints.

Once the FlexiLayout matching procedure is finished, we can see that the name has been accurately detected only on the first page. On pages 2 and 4, the word "Invoice" was mistakenly detected in the name of the date field. On page 3, it was found at the bottom of the page, and, according to the optimization algorithm, the other hypotheses of the name were not generated, even though the word "Invoice" occurs on the image three times.

Note: See the "Optimizing Group element search" for more information on optimal search for elements in the group.

To solve the problems, we used the following method. To exclude the region of the name of the date field from the search area of the field name "Invoice", we added the element DateHeader to the section Exclude elements (see the picture below).

Note: If we had started creating the FlexiLayout not with the name DateHeader but with the name InvoiceHeader, we wouldn't have been able to use the Exclude function, as this function can only exclude elements that are located higher than the current element in the project tree.

To exclude the unwanted detection of the word "Invoice" at the bottom of the page, we wrote the following code in the Advanced pre-search relations section.

NearestY: PageRect.Top;

This code tells the program to search for the element nearest to the top edge of the page.

Once the FlexiLayout has been matched, we see that our method failed on page 2, because the name of the date field here is very noisy and wasn't detected. On this page, the constraint specified in the Nearest function is true for both of the "Invoice" strings, because they are located on the same level. And since the recognition quality of the "Invoice" strings is good in both the cases, the optimization algorithm generated a single hypothesis instead of two separate ones. Unfortunately, this hypothesis is not correct.

To detect the "Invoice number" field, we created an element of type Character String, named InvoiceNumber. Similarly to the element for the date field, we specify the search constraints for the "Invoice number" field in the Advanced pre-search relations section. The search area for this element is an array of rectangles.

let Header = InvoiceGroup.InvoiceHeader;

if not Header.IsNull then

{ let rect1 = Rect (Header.Rect.Right, Header.Rect.Top-20dt,

PageRect.Right, Header.Rect.Bottom+20dt);

let rect2 = Rect (Header.Rect.Left - 200dt, Header.Rect.Bottom,

Header.Rect.Right + 150dt, Header.Rect.Bottom+200dt);

RectArray ar;

ar = RectArray( rect1 );

ar.Add( rect2 );

RestrictSearchArea( ar );

}

else

{ Above: PageRect.Top + PageRect.Height/2;

}

Nearest: Header;

Additionally, we added one more constraint to the code. We told the program that the element InvoiceNumber is the nearest to the element of the name.

After running the matching procedure, we see that the "Invoice number" field was detected wrongly on pages 2 and 4. It was wrongly detected on page 4 even though the name of the field was detected correctly.

Note: As an alternative (for the images of the current project) to Nearest: Header;, we could write NearestY: Header.Rect.YCenter;, to tell the program that the sought field is vertically nearest to the center of the name. This could solve the problem of the incorrect detection of the field "Invoice number" on page 4. But it doesn't help on page 5, because the sought field is detected within the date field after the incorrect detection of the name "Invoice number".

Now let's see how we can use the FuzzyQuality function in such a situation.

To demonstrate this, we created the project NearestAndFuzzyQuality.fsp (FuzzyQuality and Nearest\FCS project 2 folder).

The settings of this project are nearly identical to those of the project described above.

But there is one significant difference. We didn't use the Nearest function in the Advanced pre-search relations section. Instead, we wrote the following code in the Advanced post-search relations section:

if not IsNull then

{ FuzzyQuality: Rect.Top - PageRect.Top, {0,0,0,50000} * dt;

FuzzyQuality: 500dt-Width, {0,0,0,100000} * dt;

if not InvoiceHeader.IsNull then

{ FuzzyQuality: Rect.XCenter - InvoiceHeader.Rect.XCenter, {-10000,0,0,50000} *dt;

FuzzyQuality: Rect.YCenter - InvoiceHeader.Rect.YCenter, {-10000,0,0,10000} *dt;

}

}

With this method we can affect the quality of all the hypotheses, not excluding any of them. The choice of the best chain will be made for each chain individually by multiplying the quality values of all constituent hypotheses of the elements.

The line FuzzyQuality: Rect.Top - PageRect.Top, {0,0,0,50000} * dt; means, that if a non-null hypothesis is generated (if not IsNull check is run first), then the distance between the location of the element and the top edge of the page is determined. I.e. the difference (Rect.Top - PageRect.Top) is calculated, and the program checks whether this difference belongs to the interval {0, 0, 0, 50000}*dt. Such a description of the interval means that there is a direct dependency of the quality penalty and the distance between the element and the top edge of the page - the longer the distance, the greater the penalty. As is shown in the picture (a), with the specified parameters values, the maximum penalty (1) corresponds to the distance of 50000dt, while the distance of 1000 dots (1 dot is 1/300 of an inch) means the penalty of 0.02, the distance of 100dt - the penalty of 0.002.

Note: When you choose parameters setting the boundaries of the interval, you should choose such parameters (particularly, when there are multiple element checks with the FuzzyQuality function) that won't penalize the right hypothesis to a degree when its final quality will be lower than that of a null hypothesis. If the quality of all the hypotheses (including the correct one) is lower than the quality value of a null hypothesis, the null hypothesis may be selected, i.e. the element won't be detected.

(à)

The line FuzzyQuality: 500dt - Width, {0,0,0,100000}*dt; means that the programs considers the difference of width of the detected object, corresponding to the hypothesis of 500dt. I.e. the difference (500dt - Width) is calculated and the program checks whether this difference belongs to the interval {0, 0, 0, 100000}*dt. The narrower the object, the greater the penalty, so longer invoice numbers will be preferable. This constraint can be used if the image is noisy. If the noise is recognized as a character from the specified alphabet (as it can be seen, for instance, on page 2), its hypothesis should be penalized to exclude it from further analysis.

Note: The value of 500dt is chosen by visual examination, assuming that the string length in the field "Invoice number" is not greater than this value. The parameters specified here define that the maximum penalty (0.005) would correspond to the zero width of the field "Invoice number". For any other widths between 0 and 500dt, quality penalties would be lower.

The line FuzzyQuality: Rect.XCenter - InvoiceHeader.Rect.XCenter, {-10000,0,0,50000} *dt; means that if a non-null hypothesis of the element of the name of the "Invoice number" field is generated (if not InvoiceHeader.IsNull check is run first), then the distance between the center of the detected element InvoiceNumber and the center of the name InvoiceHeader is determined. The difference (Rect.XCenter - InvoiceHeader.Rect.XCenter) is calculated, and the program checks whether this difference belongs to the interval {-10000, 0, 0, 50000}*dt. This description also takes into account the possibility that the field "Invoice number" can be located below the name. In this case, the farther the elements are from each other, the greater is the penalty for the corresponding hypothesis. Hypotheses assuming that the number is located to the right of the name won't be penalized as much as those assuming that the number is below the name, as it is obvious that the "right" arrangement of the field "Invoice number" and its name is much more common.

As is shown in the picture (b), with the specified parameters of the left and the right boundaries of the interval, the maximum penalty (1) will correspond to the shift of the field "Invoice number" from the name field by 10000dt to the left or by 50000dt to the right. A shift of 1000 dot will be penalized by 0.1 if it's a "left" shift, or by 0.02 if it's a "right" shift. Similarly, a shift of 100 dot will be penalized by 0.01 if it's a "left" shift, or by 0.002 - if it's a "right" shift.

(b)

The line FuzzyQuality: Rect.YCenter - InvoiceHeader.Rect.YCenter, {-10000,0,0,10000} *dt; is identical to the previous one. But it is reserved for the cases when the field "Invoice number" is on the same horizontal level or even slightly higher than the field of the name. Penalties here are the same for any vertical shift. The boundaries of the interval are set, in accordance with to the same logic - to support the priority of hypotheses that find the data field to the right of its name. However, the project shows that these settings didn't prevent the correct detection of the invoice number even when it was located below the name (page 3).

After matching the FlexiLayout with all the pages, we see that the two sought fields have been successfully detected.

In conclusion we can say that the FuzzyQuality function is more efficient and flexible compared to the functions of the Nearest group, which is particularly important when processing of semi-structured forms.


Optimizing Group element search

If all the hypotheses of the chain of elements in the Group element (Group) have the quality value of 1, then the other hypotheses of these elements won't be analyzed.

Note: This is done to optimize the FlexiLayout, to quicken the matching procedure and to avoid the unwanted "branching" of the tree of hypotheses. But a hypothesis which is optimal for the program does not necessarily correspond to the sought object on the image. This might happen if the search constraints for the element are not strict enough. So, when such a situation arises, you should first of all analyze the parameters set for the elements search.

Let's consider the project GroupOptimization.fsp

(folder <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Group optimization\FCS project 1), where we are going to search for the field "Invoice number".

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

The project has 2 pages:

Page 1 – the image quality is good;

Page 2 – the name of the sought field is noisy.

We created the group InvoiceGroup, which contains the element used to search for the field name. This is an element of the Static Text type, named InvoiceHeader, with the value "INVOICE". To search for the field "Invoice number" itself we created an element of type Character String, named InvoiceNumber. We specified the search constraints of the date field search relative to the name in the Relations section of the element InvoiceNumber.

Note: The letter-case of the name in the section Search text is irrelevant.

Note that the string "Invoice" specified as the value for the element InvoiceHeader occurs on the images three times: as the name of the "Invoice number" field, as a substring in the name "Invoice date" and at the bottom of the invoice, as a substring in the payment conditions "Current invoice is…". So we can predict that there will be three hypotheses after the matching procedure.

After running the FlexiLayout matching procedure by selecting the Match command, we see that the tree of hypotheses in the group InvoiceGroup has only one complete chain instead of the expected three, and the complete chain of hypotheses left does not correspond to the name we are trying to detect.

If you look at the properties of each of the elements in the generated chain, you will see that the Chain quality of each hypothesis is 1, which triggered the optimization - when the program detects an ideal chain in terms of quality (i.e. having the quality 1) it ceases to generate hypotheses.

Note: To see the tree of hypotheses of the group, double-click the name of the Group element in the tree of hypotheses, or press Enter, or select the Show Details from the shortcut menu.

Why, at the stage of hypotheses generation, one object of the image is preferable over the others is determined the algorithm of the program.

Since the results of matching the FlexiLayout are unsatisfactory, we should analyze the reasons of the problem and decide how it can be solved.

First, we didn't limit the search area for the element InvoiceHeader. Second, when describing the element InvoiceNumber, we specified that the string of digits can be of any length (because we don't know the possible length of the invoice number). We also specified that it should be looked for to the right of the name, at approximately the same horizontal level. As you can see, all the three instances of the word "Invoice" match these conditions. That's why the incorrect detection of the name automatically caused the incorrect detection of the field "Invoice number." You must add some limiting constraints, so that the correct hypothesis is the best in the end, and the FlexiLayout is optimal not only in terms of matching speed.

If we assume that the arrangement of the fields is identical on all the pages of the project, then the easiest way is to "tell" the program that we need the string "Invoice" which is the nearest element to the top edge of the page. So we write the following code in the Advanced pre-search relations section of the element InvoiceHeader: Nearest: PageTop;. We can do so because the name of the sought field "Invoice number" is the only element nearest to the top edge of the page. If it weren't so or if the form weren't formalized, the Nearest function couldn't help us to solve the problem.

To show alternative ways to do this task, including the case with a semi-structured form, we created the project GroupOptimization.fsp (folder Group optimization\FCS project 2).

As you can see on the images, the distance between the digit string and the word "invoice" is the smallest in the sought field "Invoice number". This is true on all the pages, which gives us an opportunity to affect the quality values of generated hypotheses by entering the following code in the Advanced post-search relations section of the element InvoiceNumber:

if (not InvoiceHeader.IsNull) and (not IsNull) then

{ FuzzyQuality: Rect.Left - InvoiceHeader.Rect.Right, {0, 0, 0, 10000}*dt; }

It means that if both elements are detected, the distance between the elements is calculated for the hypothesis of the element InvoiceNumber, and the program checks whether it belongs to the interval {0, 0, 0, 10000}*dt. This description of the interval shows the linear dependency between the quality of the hypothesis and the distance between the elements - the longer the distance, the greater the penalty (the function FuzzyQuality restores the post-search quality of the hypothesis - it can be seen in the Properties window of the hypothesis). The value for the right boundary of the interval (10000dt) was determined experimentally. When choosing this value, you should take into account the distance between the corresponding objects on test images.

As is seen from the picture below, under the specified interval properties, the maximum penalty (1) will correspond to a distance of 10000dt. Accordingly, a distance of 1000dt will bring a penalty of 0.1, a distance of 100dt - a penalty of 0.01, etc.

So for real distances of about 100-300 dot, which we can see on our images, the penalty coefficient will be 0.99-0.97.

Note: See "Using Nearest and FuzzyQuality to look for elements" for more details about the use of these functions.

For the images in this batch, the hypothesis corresponding to the unwanted field "Invoice number" with the value "2005" got the maximum penalty, while the hypothesis corresponding to the sought field got the minimum penalty. Since penalizing made the Post-search quality of all the hypotheses different from 1, all the hypotheses of both elements of the Group element InvoiceGroup will now be analyzed.

Note that the field "Invoice number" was correctly detected even on page 2, where the name "Invoice" is very noisy, which caused a recognition error and, consequently, additional penalties for the hypothesis.


The "Optional" property of a Group element

At the creation of a Group element the Optional element box is clear by default, i.e. the element is obligatory. At FlexiLayout matching, a non-null hypothesis is generated for an obligatory Group element, even if null hypotheses are generated for all of its subelements. To check the properties of the subelements of such a hypothesis, call the code in their Advanced sections. If the Group element is optional, a null hypothesis can be generated for it (if there are no non-null hypotheses with the quality higher than the quality of a null hypothesis).

It is not recommended to select the Optional element box for Group elements. The reasons for this are that, if the Group element is Optional element and it is not detected (its quality is lower than the quality of a null hypothesis, of the function Dontfind() is called for it), then any call to any of its subelements will cause errors, because in a group with a null hypothesis, the hypotheses of subelements are not formulated. To avoid this error, you must first check the Group element. If the IsNull-check returns True, you mustn't address any of the subelements.

Then why do we need an optional Group element and its null hypothesis? It is needed when the entire group of fields is not present on the image. Then it is useless to search for them. And the search for the elements can be speeded up by calling the DontFind() method for the Group element.

Note: Under "call" we mean writing code in any of the sections on the Advanced tab or in the block properties in the Expression window. If the properties of a Group element are called when setting the search constraints in Relations, then the IsNull-check is automatic. You can see this if you click Code on the Advanced tab.

To illustrate this, we created the project GroupSample.fsp

(folder <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Optional Group\FCS project).

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

In the Properties dialog box of the Group element InvoiceRequisiteGroup, we selected the Optional element box. On the Advanced tab in the section Advanced pre-search relations we wrote the following code:

if FormID.IsNull then Dontfind();

Next we check for the availability of the element which identifies the form type. By using the element FormID, created prior to the Group element InvoiceRequisiteGroup, we search for the static text with a known value ("ID2015"). If the value of the identifier on the form matches the value specified in the Search text section, then a non-null hypothesis is generated for the element FormID. Otherwise, the static text FormID is not detected and we tell the program not to look for the Group element InvoiceRequisiteGroup, i.e. we created a null hypothesis for the optional Group element InvoiceRequisiteGroup.

In the project there is an element TotalSumHeader that is used to look for the name of the sum field. The following code is entered for the element in the Advanced pre-search relations section:

Below: SearchElements.InvoiceRequisiteGroup.InvoiceDateHeader, 0 * dot;

This code means that the search for the name will be run below the date field described by the element InvoiceDateHeader, which, in its turn, is a subelement of the Group element InvoiceRequisiteGroup.

Let's run the FlexiLayout matching procedure on both pages in the batch. For page 1 the procedure was successful, but at the attempt to apply the FlexiLayout to page 2, the program displays the following error notice: "Page 2: Error in element "SearchElements.TotalSumHeader", Advanced generator parameters section: Attempt to access undefined hypothesis: SearchElements.InvoiceRequisiteGroup".

This happens because on page 2 the value of the identifier of the form is ID 2589. Since this value is different from the one specified in the properties of the element FormID, the function Dontfind() for the Group element InvoiceRequisiteGroup generated a null hypothesis. So in the code we called for a non-existent hypothesis.

The correct code must look like this.

if not( SearchElements.InvoiceRequisiteGroup.IsNull ) then

{ Below: SearchElements.InvoiceRequisiteGroup.InvoiceDateHeader, 0 * dot;}

Note: If you comment the code in the Advanced pre-search relations section and activate the flag near the similar search constraint of the element TotalSumHeader in the Relations section, then clicking Code in the Advanced tab will show that the compiled code already contains the IsNull-check.


Searching for strings of digits

An element of type Character String is used to search for digit strings. If the image quality is very good, then even a regular expression can be specified as an alphabet. But if the quality of images in the batch differs, we must specify the list of characters that can be recognized in the corresponding field. If the quality of images or print is non-satisfactory, digits can be mistakenly recognized as other characters. For example - "8" can be recognized as "B", "7" - as "?", "5" - as "S", "4" - as "H" or the letter combination "LI", etc. This can happen if the digits are "glued", which is common if forms are filled in by using a typewriter.

The degree of correspondence between the results of recognition and the actual characters depends on the image quality. If there is a tendency to misinterpret characters on all or most of the processed images, then you should add these recognition variants to the alphabet in the Edit Alphabet window of the corresponding element Character String. By specifying these characters, you tell the program not to penalize the hypothesis if these characters are encountered in the search area.

Note: Certainly, there is no need to specify all the possible recognition variants. If the quality of the images is bad, it may be an extremely time-consuming task to find all such variants. If, because of low image quality, the results of the recognition are unpredictable, then you should run the search by using some other element properties, such as string length, length of spaces in the string, etc.

Specify the characters whose outlines are similar to those of digits. The chances of incorrect recognition for such characters are higher than for the rest. If required, you can specify other characters as well, if they are commonly mistaken for digits.

Let's consider the project DigitalString.fsp (folder Digital strings\FCS project1).

The project has 3 pages.

Page 1 – the digit 4 is recognized as the combination of letters "LI";

Page 2 – the substring 13 is recognized as the letter "å";

Page 3 – the digit 0 is recognized as "a", 2 and 5 are recognized as "S", 6 and 8 – as "B".

To detect the digit string, we created an element of type Character String, named it DigitalString and specified only digits as its alphabet. We set the maximum percentage of non-digit characters at 20.

After running the FlexiLayout matching procedure on all the pages, the digit field on page 3 wasn't fully detected. The quality value of the hypothesis is about 0.98. On pages 1 and 2, the string has been detected. But since it contains non-alphabetic characters, the corresponding hypotheses were penalized and their quality made 0.978 and 0.982 respectively.

Now let's see the results of the FlexiLayout matching if we add to the alphabet the characters that were mistakenly recognized instead of digits: L, I, e, a, B, S.

The result of the FlexiLayout matching can be seen in the project DigitalString.fsp

(folder <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Digital strings\FCS project2).

The other settings in the projects are identical.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

As you can see, the string on page 3 has been fully detected, and the quality of all the generated hypotheses is 1.


Simplifying the FlexiLayout by using an auxiliary element and a null hypothesis

This method can be used when you need to check the same bulky search constraints for several elements. The idea behind is that constraints are checked and the calculations are performed only once in some auxiliary element. As a result of checking the constraints, the given element is either searched for or not, so the found or unfound hypothesis is a marker signaling whether the constraints are met or not. This auxiliary element is created so that it can always detect something on the images, provided the DontFind() function (i.e. "stop the search") is not activated. The number of hypotheses shouldn't be too large, to avoid overextension of the tree of hypotheses and the time of the FlexiLayout matching. To achieve this, you can use, for instance, elements of the Object Collection or Text Fragment types. These elements always generate a single hypothesis that includes all the objects of the specified type from the search area. In the Advanced pre-search relations section of the dummy element we write the set of conditions that we want to check for some of the elements located below the dummy element in the project tree. If all the conditions are met, we call the DontFind() function for the dummy element. In this case a null hypothesis will be generated for the dummy element, and it will serve as a marker that all the conditions have been met when the program starts searching for other elements. By doing so, we tell the program to run only the IsNull-check of the dummy element instead of checking the same bulky constraints for several elements.

Note 1: This method helps to make the code more descriptive. Additionally, if you need to edit the constraints, you can do this only in the description of the dummy element. It lowers the chances of logical and syntactical errors when duplicating the code.

Note 2: In the future versions of the product we plan to support creation of variables in the area of subelements of groups. The results of checking the constraints will then be stored in the values of different variables. The current method is a temporary solution (workaround) that helps to simplify the code in the Advanced sections in the present version of FlexiLayout Studio.

Let's see how this method works in the project AuxiliaryElement.fsp

(folder <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks\Auxiliary element\FCS project).

On these images, we will search for the following fields: "Invoice number", "Invoice date", "Company name", and "Company address".

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

Let's assume that we have to process invoices of two different types:

The fields "Company name" and "Company address" are above the field "Invoice number";

The fields "Company name" and "Company address" are below the field "Invoice number".

As you can see from the images, the fields "Company name" and "Company address" don't have names, which prevents us from using the standard procedure of looking for the date field by relying on its name. However, we can notice a certain pattern: when the date field is located to the right of the invoice number, the company name and address are located below the field "Invoice number" (pages 1 and 3); while if the date field is below the invoice number field, then the company details are above the field "Invoice number" (pages 2 and 4).

taking into account the detected pattern, it is would be best to search for the location of the fields "Invoice number" and "Invoice date" first. And then we are going to detect the other fields by relying on these two, specifying their mutual locations.

We have create a Group element InvoiceGroup that contains elements InvoiceHeader, InvoiceNum, DateHeader and a Group element DateGroup. These subelements are required to detect field names and the fields "Invoice Number" and "Invoice date".

Note: See "Detecting dates in the case of low quality pre-recognition" for more details on the methods of date search. Here we only describe the constraints for the date search in the current project.

As you can see, the date fields on the images do not always have names. So, when searching for a date field, you need to specify two sets of constraints: for cases when the name has been detected and for cases when the name has not been detected (a special case would be if the name is present on the page but has not been detected, for example, because of noise).

if not DateHeader.IsNull then

{ RightOf: DateHeader.Rect.Right;

Below: DateHeader.Rect.Top - 30dt;

Above: DateHeader.Rect.Bottom + 30dt;

}

else

{ RectArray ar;

Let ar1 = Rect (InvoiceNum.Rect.Right, InvoiceNum.Rect.Top-30dt, PageRect.Right, InvoiceNum.Rect.Bottom + 30dt);

Let ar2 = Rect (InvoiceHeader.Rect.Left, InvoiceHeader.Rect.Bottom, InvoiceHeader.Rect.Right + 300dt, InvoiceHeader.Rect.Bottom + 150dt);

ar = RectArray (ar1);

ar.Add (ar2);

RestrictSearchArea (ar);

}

If the name of the date field is detected (the constraint if not DateHeader.IsNull is checked), then the search will be carried out relative to the name of the date field: to the right of the name, on one horizontal level, with some margin of error for vertical displacement:

{ RightOf: DateHeader.Rect.Right;

Below: DateHeader.Rect.Top - 30dt;

Above: DateHeader.Rect.Bottom + 30dt;

}

Otherwise the search area is divided into two rectangles: to the right of the invoice number and on the same level as the invoice number and below the invoice field.

Note: For the sake of simplicity we assume that we have images of good quality where the field "Invoice number" and its name are always detected. In a real-life situation, before calling the properties of these elements we must run their IsNull-check, because if the elements are not detected, further search will be carried out relative to the search areas of the corresponding elements.

In the Advanced post-search relations section of the element Date we wrote the following code:

if (DateHeader.IsNull) and (not IsNull) then

{if (not InvoiceHeader.IsNull) then

{ FuzzyQuality: Rect.Left - InvoiceHeader.Rect.Right, {0, 0, 0, 50000}*dt;

FuzzyQuality: Rect.Top - InvoiceHeader.Rect.Bottom, {-50000, 0, 0, 50000}*dt;

}

if (not InvoiceNum.IsNull) then

{ FuzzyQuality: Rect.Left - InvoiceNum.Rect.Right, {0, 0, 0, 50000}*dt;

FuzzyQuality: Rect.Top - InvoiceNum.Rect.Bottom, {-50000, 0, 0, 50000}*dt;

}

}

It allows influencing the quality of the date hypothesis depending on its distance from the name of the invoice field and the field "Invoice number" itself if the name of the date field is not detected. The longer the distance to the specified fields, the greater the penalty will be for the corresponding hypotheses, i.e. we search for the date field nearest to the field "Invoice number".

Note: See "Using Nearest and FuzzyQuality to look for elements" for more details on the use of these functions.

We specify identical search constraints for the element DateAsString, but in the Advanced post-search relations section we add one more line to the above-mentioned code:

FuzzyQuality: 600dt - Width, {0, 0, 0, 50000}*dt;

This line is needed during date search, so that a hypothesis with a longer string of alphabet characters is preferable to a shorter one.

Additionally, on the Search Constraints tab of the element DateAsString we specified that, when searching for the date as a string of characters, the region of the element InvoiceNum must be excluded. This is because we decided, for the sake of simplicity, not to duplicate for the element DateAsString the same search constraints as we specified in the Advanced pre-search relations section of the element Date. We specified the search area as RestrictSearchArea (Date.Rect);. We thus told the program to search for the object of the element DateAsString in the area of the fuzzy rectangle of the element Date. The search area of the element Date can be represented as an array of rectangles. When a null hypothesis is generated for the element Date, the rectangle enclosing the search area is taken as a rectangle (Rect) of the current element. As you can see on the image below, it also encloses the field "Invoice number" described by the element InvoiceNum. Under some conditions (for instance, when the date field is very noisy), a situation may occur when, instead of the date field, the element DateAsString will detect the field of the invoice number, as characters (including digits) specified for this element do not have any format restrictions.

After the elements required to search for the fields "Invoice number" and "Invoice date" have been described, we can go on to the search for the fields "Company name" and "Company address".

We create an element of type Text Fragment and name it ShamElement. This element serves as an auxiliary element and is used exclusively to check the mutual location of the fields "Invoice number" and "Invoice date".

In the Advanced pre-search relations section of the auxiliary element, we wrote the following code:

Let Date1 = InvoiceGroup.DateGroup.Date;

Let Date2 = InvoiceGroup.DateGroup.DateAsString;

Let DateGroup = InvoiceGroup.DateGroup;

Let InvoiceHeader = InvoiceGroup.InvoiceHeader;

Let InvoiceNumber = InvoiceGroup.InvoiceNum;

if ((not InvoiceHeader.IsNull) or (not InvoiceNumber.IsNull)) and

(

((Date1.IsNull == FALSE) and ((max (InvoiceHeader.Rect.YCenter - Date1.Rect.YCenter, Date1.Rect.YCenter - InvoiceHeader.Rect.YCenter ) < 30dt) or (max (InvoiceNumber.Rect.YCenter - Date1.Rect.YCenter, Date1.Rect.YCenter - InvoiceNumber.Rect.YCenter ) < 30dt)) and ((Date1.Rect.Left - InvoiceHeader.Rect.Right > 100dt) or (Date1.Rect.Left - InvoiceNumber.Rect.Right > 50dt)))

or

((Date2.IsNull == FALSE) and ((max (InvoiceHeader.Rect.YCenter - Date2.Rect.YCenter, Date2.Rect.YCenter - InvoiceHeader.Rect.YCenter ) < 30dt) or (max (InvoiceNumber.Rect.YCenter - Date2.Rect.YCenter, Date2.Rect.YCenter - InvoiceNumber.Rect.YCenter ) < 30dt)) and ((Date2.Rect.Left - InvoiceHeader.Rect.Right > 100dt) or (Date2.Rect.Left - InvoiceNumber.Rect.Right > 50dt)))

)

then

{ Dontfind(); }

else

{ Below: PageRect.Top; }

Despite the simplicity of constraints checked by this code, the code itself turned rather bulky. Its idea is that, if the date field detected by means of one of the elements Date or DateAsString is located to the right of the invoice number field but on the same level (with a vertical tolerance of 30 dt), then we tell the program that a null hypothesis must be generated for the auxiliary element. In the other cases the element ShamElement will be looked for below the top edge of the page. Since we created an auxiliary element of type Text Fragment without any additional search constraints, it will enclose all text objects on the page and a single hypothesis will be generated.

Nearly all the constraints to be checked are intuitively clear. So we are only going to describe the most complicated of them.

max (InvoiceHeader.Rect.YCenter - Date1.Rect.YCenter, Date1.Rect.YCenter - InvoiceHeader.Rect.YCenter ) < 30dt

This part of the code checks that the date field (in this case, if it is detected by the element Date) is located on one horizontal level with the element of the name of the field "Invoice number". The date may be slightly higher or lower than the name (because of the possible errors during scanning or form filling). We specified that the maximum difference is 30 dt. We check the mutual vertical location of the field "Invoice date" and "Invoice number" by the same method.

Date1.Rect.Left - InvoiceHeader.Rect.Right > 100dt

This line checks that the date field is located to the right of the name of the field "Invoice number" (the coordinate of the left boundary of the date is greater than that of the right boundary of the name). We specified a tolerance of 100dt because between the name and the date there must be the invoice number itself. The location of the date field is to the right of the field "Invoice number".

All the conditions of the check are then duplicated for the element DateAsString.

To check that our code is correct, let's run the FlexiLayout matching procedure on all the pages. We see that on pages 1 and 3, where the date field is located to the right of the invoice number, a null hypothesis was generated for the element ShamElement. On the other two pages, text fragments were detected.

To detect the company details, we create a Group element CompanyGroup. It groups the elements CompanyName of type Character String (the company name on test images is written in a single line) and Address of type Text Fragment. The element will be used to search for the block containing the company address.

The use of the auxiliary element helps to simplify the code which describe the search constraints of the element in the Advanced pre-search relations section. So, if the auxiliary element is not detected (i.e. a null hypothesis is generated for it), this will mean that the date field is located to the right of the invoice field. In such a case, the field "Company name" will be looked for below the field "Invoice number". If the auxiliary element is detected, the field "Company name" will be looked for above the field "Invoice number".

if ShamElement.IsNull then

{ Below: InvoiceGroup.InvoiceHeader;

Below: InvoiceGroup.InvoiceNum;

NearestY: PageRect.Top;

}

else

{ Above: InvoiceGroup.InvoiceHeader;

Above: InvoiceGroup.InvoiceNum;

}

Note: In this case we can use the function Nearest, as it helps to detect the field containing the company name unambiguously and accurately (there are no objects matching the same search constraints).

In the Advanced post-search relations section of the element CompanyName we write the following code.

if not IsNull then

{ FuzzyQuality: Rect.Left - PageRect.Left, {0, 0, 0, 50000}*dt;

FuzzyQuality: Rect.Top - PageRect.Top, {0, 0, 0, 50000}*dt;

FuzzyQuality: 100dt - Height, {0, 0, 0, 10000}*dt;

}

This code works when the single-line field "Company name" is looked for above the field of the invoice number. The sought fields don't have names. At the same time, the mutual loaction of the fields "Company Name" and "Company address" is different on pages 2 and 4. The constraint Above: InvoiceGroup.InvoiceHeader; and Above: InvoiceGroup.InvoiceNum; is met not only be the string with the company name, but also by the strings in the address field.

To select the only correct hypothesis among all the generated hypotheses, the following code in the Advanced post-search relations section is used.

By typing the code FuzzyQuality: Rect.Left - PageRect.Left, {0, 0, 0, 50000}*dt; and FuzzyQuality: Rect.Top -PageRect.Top, {0, 0, 0, 50000}*dt; we tell the program to stronger penalize hypotheses with objects close to the bottom and right boundaries of the image. However, on page 2 the field "Company name" is located to the left of the address field but lower then its upper line. So the described constraints are not sufficient to detect the sought field "Company name", and we have to add one more constraint.

FuzzyQuality: 100dt - Height, {0, 0, 0, 10000}*dt;

This line tells the program to check the height of all the lines for the generated hypotheses. The taller the characters in the line are, the higher the quality of the corresponding hypothesis.

After we have matched the FlexiLayout we see that the field "Company name" has been successfully detected on all the pages.

To detect the address field we wrote the following code in the Advanced pre-search relations section of the element Address:

if ShamElement.IsNull then

{ Below: CompanyName;

Above: TotalSumHeader.Rect.Top;

}

else

{

Above: InvoiceGroup.InvoiceHeader;

Above: InvoiceGroup.InvoiceNum;

RightOf: CompanyName.Rect.Left;

Exclude: CompanyName;

}

Here again we use the auxiliary element ShamElement, which helps to simplify the code.

The creation of a FlexiLayout is now complete. Once we have run the FlexiLayout matching procedure we will see that all the fields have been successfully detected.


Describing text fields containing framed letters

Sometimes you may need to create a FlexiLayout to look for fields which typically occur on traditional forms with a fixed layout. For example, you may need to describe a field in which letters must be entered into small frames. A typical example would be a company collecting forms from its regional offices. Even if the forms are expected to look the same, there may be subtle differences in layouts from one regional office to another, which means that they cannot be processed using a single "hard" template. In this case one FlexiLayout may be preferable to several slightly different "hard" templates.

If data fields sought on the form are of "framed letters" or "separate framed letters" type, a separator-based search for the boundaries of such fields can be very complicated, and the description of elements can turn bulky, particularly if the names for such fields are not available or uncertainly recognized. Moreover, it is very important that the block contain not only these fields but the entire frame as well. If separator lines are thin, they may sometimes be misprinted or lost during scanning. In such cases it is recommended to search for the boundaries using White Gap elements. Such field boundaries are described in the special FlexiLayout language in the Expression field of the block's Properties dialog box. You can describe the top boundary of the field as the bottom of the top white gap, the bottom boundary as the top of the bottom white gap, the right boundary of the field as the left boundary of the right white gap, and the left boundary of the field as the right boundary of the left white gap.

A FlexiLayout Studio project which contains test images and a tested FlexiLayout can be found in

<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Tips and Tricks.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

Example

Let us assume that all the 4 gaps (LeftGapName, RightGapName, TopGapName, BottomGapName) which are required to formally describe the location of the data field in the picture have been found.

The code in the Expression field will then look as follows:

Rect outputRect;
Let FieldLeft = LeftGapName.Rect.Right;
Let
FieldRight = RightGapName.Rect.Left;
Let FieldTop = TopGapName.Rect.Bottom;
Let FieldBottom = BottomGapName.Rect.Top;
outputRect = Rect(FieldLeft,
FieldTop, FieldRight, FieldBottom);
OutputRegion = outputRect;

Note: Instead of "LeftGapName", "RightGapName", "TopGapName" and "BottomGapName" you should put the names of the corresponding White gap elements. If required, you can extend the field's width and height by using the Inflate option.

If data fields sought on the form are multiple-line fields which have the marking of "framed letters" or "separate framed letters" type, and the lines are not separated from each other by gaps, then you should look for top, bottom, right and left boundaries by using White Gap elements. Search for individual lines should then be specified by a special algorithm in the Expression field. In the given example, the height of each individual line can be calculated by dividing the height of the entire field by 2.


Shortcut keys

  • File menu
  • Edit menu
  • View menu
  • Batch menu
  • Image menu
  • FlexiLayout / Classifier menu
  • Tools menu
  • Image window
  • Hypotheses window
  • Batch window
  • FlexiLayout window

File menu

Command | Keys
New Project>FlexiLayout Project… | Ctrl+N
Open Project… | Ctrl+O
Save | Ctrl+S
Exit | Alt+X

Back to top

Edit menu

Command | Keys
Cut | Ctrl+X
Copy | Ctrl+C
Paste | Ctrl+V
Delete | Del
Select All | Ctrl+A

Back to top

View menu

Command | Keys
Batch | Alt+1
FlexiLayout / Classifier | Alt+2
Properties | Alt+3
Image | Alt+4
Hypotheses | Alt+5
Classifier Log | Alt+6

Back to top

Batch menu

Command | Keys
Match | Ctrl+Shift+E
Next Page | Ctrl+NUM +
Previous Page | Ctrl+NUM -
Go to Page… | Ctrl+G
Delete Page Data… | Alt+Del

Back to top

Image menu

Command | Keys
Pre-Recognize | Shift+E
Match | Ctrl+E
Hide Active Blocks or Elements | Ctrl+H
Image Window Scale>Zoom In | Ctrl+NUM*
Image Window Scale>Zoom Out | Ctrl+NUM/

Back to top

FlexiLayout / Classifier menu

Command | Keys
Disable / Ena&ble | Ctrl+D
Test Element | Ctrl+T
Build | Ctrl+B

Back to top

Tools menu

Command | Keys
Find in Advanced Code… | Alt+F3

Back to top

Image window

Command | Keys
Match | Ctrl+E
Go to Page… | Ctrl+G
Pre-Recognize | Shift+E
Hide Active Blocks or Elements | Ctrl+D
Scale>Zoom In | Ctrl+NUM*
Scale>Zoom Out | Ctrl+NUM/
Test Element | Ctrl+T
Properties… | Alt+Enter

Back to top

Batch window

Command | Keys
Go to Page… | Ctrl+G
Match | Alt+Shift+E
Delete Page Data… | Alt+Del
Test Element | Ctrl+T
Properties… | Alt+Enter

Back to top

Hypotheses window

Command | Keys
Show Details | Enter
Go One Level Up | Backspace
Expand Active | NUM +
Collapse Active | NUM -
Expand All | NUM *
Collapse All | Shift+NUM *
Show Search Area | Shift+A

Back to top

FlexiLayout window

Command | Keys
Cut | Ctrl+X
Copy | Ctrl+C
Paste | Ctrl+V
Delete | Del
Disable / Ena&ble | Ctrl+D
Find in Code | Alt+F3
Build FlexiLayout | Ctrl+B
Properties… | Alt+Enter

Back to top


Properties of image objects detected during pre-recognition

  • Recognized Word
  • Recognized Line
  • Separator
  • Raw Objects
  • Barcode

Recognized Word

Property | Description
Object type | The type of the object - Text.
Surrounding rect | The coordinates of the surrounding rectangle.
Width | The width of the object.
Height | The height of the object.
Recognized text | The words recognized during pre-recognition.

Back to top

Recognized Line

Property | Description
Object type | The type of the object - Recognized line.
Surrounding rect | The coordinates of the surrounding rectangle.
Width | The width of the object.
Height | The height of the object.
Recognized text | The lines recognized during pre-recognition.

Back to top

Separator

Property | Description
Object type | The type of the object - Separator.
Surrounding rect | The coordinates of the surrounding rectangle.
Width | The width of the object.
Height | The height of the object.
Orientation | The orientation of the separator - Vertical or Horizontal.

Back to top

Raw Objects

Property | Description
Object type | The type of the object - Image (elementary object).
Surrounding rect | The coordinates of the surrounding rectangle.
Width | The width of the object.
Height | The height of the object.
Data type The type of the elementary object:
  • Raw Text,
  • Picture,
  • Punctuation Mark,
  • Inverted,
  • Checkmark.

Back to top

Barcode

Property | Description
Object type | The type of the object - Barcode.
Surrounding rect | The coordinates of the surrounding rectangle.
Width | The width of the object.
Height | The height of the object.
Text | The recognized value of the barcode.
Type | The type of the barcode.
Orientation The orientation of the barcode:
  • Left to right,
  • Bottom to top,
  • Right to left,
  • Top to bottom.

Back to top


Supported image formats

Format | Color
BMP | black-and-white, grayscale, color
PCX, DCX | black-and-white, grayscale
PNG | black-and-white, grayscale, color
JPEG, JPEG2000 | grayscale, color
TIFF black-and-white uncompressed, CCITT3, CCITT3FAX, CCITT4, Packbits;
grayscale – uncompressed, Packbits, JPEG;
color – uncompressed, JPEG
PDF | regardless of their type, PDF files are opened only as images (a separate license is required)
XPS | color; requires Microsoft .Net Framework 3.0
WIC-compatible | color; requires Windows Imaging Component (part of Microsoft .Net Framework 3.0)
DjVu | black-and-white, grayscale, color


Barcodes supported in ABBYY FlexiLayout™ Studio

ABBYY FlexiLayout Studio supports the following types of barcode:

  • Check Code 39
  • Check Interleaved 25
  • Codabar
  • Code 128
  • Code 39
  • Code 39 without asterisk
  • Code 93
  • EAN 13
  • EAN 8
  • IATA-25
  • Industrial 25
  • Interleaved 25
  • Matrix 25
  • Patch Code
  • PDF 417
  • UCC-128
  • UPC A
  • UPC E


OCR languages supported in ABBYY FlexiLayout™ Studio

  • Abkhaz
  • Adyghe
  • Afrikaans
  • Agul
  • Albanian
  • Altai
  • Armenian (Eastern)
  • Armenian (Grabar)
  • Armenian (Western)
  • Avar
  • Aymara
  • Azeri (Cyrillic alphabet)
  • Azeri (Roman alphabet)
  • Bashkir
  • Basque
  • Belarusian
  • Bemba
  • Blackfoot
  • Breton
  • Bugotu
  • Bulgarian
  • Buryat
  • Catalan
  • Cebuano
  • Chamorro
  • Chechen
  • Chinese (simplified)
  • Chinese (traditional)
  • Chukchee
  • Chuvash
  • Corsican
  • Crimeam Tatar
  • Croatian
  • Crow
  • Czech
  • Dakota
  • Danish
  • Dargwa
  • Dungan
  • Dutch
  • Dutch (Belgian)
  • English
  • English Legal Terminology
  • English Medical Terminology
  • Eskimo (Cyrillic alphabet)
  • Eskimo (Roman alphabet)
  • Esperanto
  • Estonian
  • Even
  • Evenki
  • Faroese
  • Fijian
  • Finnish
  • French
  • Frisian
  • Friulian
  • Gagauz
  • Galician
  • Ganda
  • German
  • German (Luxembourg)
  • German (new spelling)
  • German Legal Terminology
  • German Legal Terminology (new spelling)
  • German Medical Terminology
  • German Medical Terminology (new spelling)
  • Greek
  • Guarani
  • Hani
  • Hausa
  • Hawaiian
  • Hebrew
  • Hungarian
  • Icelandic
  • Ido
  • Indonesian
  • Ingush
  • Interlingua
  • Irish
  • Italian
  • Japanese
  • Jingpo
  • Kabardian
  • Kalmyk
  • Karachay-Balkar
  • Karakalpak
  • Kazub
  • Kawa
  • Kazakh
  • Khakass
  • Khanty
  • Kikuyu
  • Kirghiz
  • Kongo
  • Korean
  • Korean (Hangul)
  • Koryak
  • Kpelle
  • Kumyk
  • Kurdish
  • Lak
  • Latin
  • Latvian
  • Lezgi
  • Lithuanian
  • Luba
  • Macedonian
  • Malagasy
  • Malay (Malaysian)
  • Malinke
  • Maltese
  • Mansi
  • Maori
  • Mari
  • Maya
  • Miao
  • Minangkabau
  • Mohawk
  • Moldavian
  • Mongol
  • Mordvin
  • Nahuatl
  • Nenets
  • Nivkh
  • Nogay
  • Norwegian
  • Norwegian (bokmal)
  • Norwegian (nynorsk)
  • Nyanja
  • Occidental
  • Ojibway
  • Old English
  • Old French
  • Old German
  • Old Italian
  • Old Spanish
  • Ossetian
  • Papiamento
  • Polish
  • Portuguese
  • Portuguese (Brazilian)
  • Provencal
  • Quechua
  • Rhaeto-Romanic
  • Romanian
  • Romany
  • Rundi
  • Russian
  • Russian (old spelling)
  • Russian-English
  • Rwanda
  • Sami (Lappish)
  • Samoan
  • Scotish Gaelic
  • Selkup
  • Serbian (Cyrillic alphabet)
  • Serbian (Roman alphabet)
  • Shona
  • Slovak
  • Slovenian
  • Somali
  • Sorbian
  • Sotho
  • Spanish
  • Sunda
  • Swahili
  • Swazi
  • Swedish
  • Tabasaran
  • Tagalog
  • Tahitian
  • Tajik
  • Tatar
  • Thai
  • Tok Pisin
  • Tongan
  • Tswana
  • Tun
  • Turkish
  • Turkmen
  • Tuvinian
  • Udmurt
  • Uighur (Cyrillic alphabet)
  • Uighur (Roman alphabet)
  • Ukrainian
  • Uzbek (Cyrillic alphabet)
  • Uzbek (Roman alphabet)
  • Vietnamese
  • Welsh
  • Wolof
  • Xhosa
  • Yakut
  • Yiddish
  • Zapotec
  • Zulu


Add Global Constant dialog box

Property | Description
Name | Enter a name for the global constant in this field. Note: A constant name must be a valid identifier, i.e. it must consist of the characters "_ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" and digits. The first character in the name must not be a digit. Constant names must not contain blank spaces or special symbols.
Value | Enter a value for the global constant in this field.


Add New Alphabet dialog box

Field | Description
Code page | Selects a code page.
Unicode subrange | Selects a Unicode subrange.
Character map Selects characters for the alphabet. Selecting a character automatically places it in the entry field. When you place the mouse pointer over a character, the following information is displayed at the top of the dialog box:
  • A large image of the character
  • Unicode
  • Character code

Important!
The selected characters are highlighted in blue. To deselect a character, click it again. The deselected character will be automatically removed from the entry field.
Entry field | Here you can type in characters for the alphabet.
Selected on screen/selected in all | Shows the number of characters selected on the screen/in total.
Clear All | Clears the entry field and deselects all the characters on the character map.
Percentage of alphabet characters | The percentage of alphabet characters calculated as [the number of alphabet characters in the hypothesis]/[the total number of characters in the hypothesis].


Assemble to Reference Documents dialog box

In this dialog box, you can create a reference document assembly.

Property | Description
One document | Specifies that the selected pages belong to one document.
Group by page count | Groups the selected pages into document based on the number of pages in a document. Enter the number of pages in the field to the right.
First page of document matches Header | Specifies that the first page of the document must match the Header element. The option is selected by default. Clear the box if no Header element can be detected for the given document.
Last page of document matches Footer | Specifies that the last page of the document must match the Footer element. The option is selected by default. Clear the box if no Footer element can be detected for the given document.


Block Properties dialog box

Property | Description
Name Enter a name for the block in this field.

Important!
The name of the block must be unique for a given FlexiLayout.
Comment | Enter additional information about the block in this field.
Has repeating instances | Specifies that the block has repeating instances.
Instance sort order | Specifies the order in which group instances must be joined into a block. The option is available only if Has repeating instances is selected. Possible values: Top to bottom, Left to right, Right to left, In order of finding..
For layout | Specifies the layout alternative where the element or the position of the block is specified.
Source element | Specifies the location of the block as coinciding with the location of the object described by the source element.
"..." button | Opens the Select Element, dialog box where you can select a source element in the tree of elements.
Expression | In this field you can write a region expression in the FlexiLayout language, which formally describes the location of the block.

More

Blocks


Block Properties dialog box, Columns tab

Item | Description
Table columns | Lists the columns of the table block. You may find it convenient to use in the FlexiLayout the actual names of the columns on the document.
Add… | Opens the Add Table Column dialog box, where you enter a name for the column. Note: A column name must not contain blank spaces or start with a digit.
Edit… | Opens the Edit Table Column dialog box, where you can edit the name of a column.
Delete | Deletes the selected column from the list.
 | Moves the selected column one level down.
 | Moves the selected column one level up.


Change Header/Footer dialog box

Field | Description
First page of document matches Header | Specifies that the first page of the document must match the Header element. The option is selected by default. Clear the box if no Header element can be detected for the given document.
Last page of document matches Footer | Specifies that the last page of the document must match the Footer element. The option is selected by default. Clear the box if no Footer element can be detected for the given document.


Create Block dialog box

Property | Description
Select block name | Selects a block from the FlexiLayout tree.


Password dialog box

Field | Description
Enter password | Enter a valid password for a password-protected PDF document.


Go to Page dialog box

Field | Description
Page number | The number of the page to be opened.


Find dialog box

Field | Description
Find what | The string to find.
Replace with | The string with which to replace the found string.
Match case | Enables case-sensitive search.
Direction (Up, Down) | Selects the direction of the search.
Find | Starts the search.
Replace | Replaces the found string.
Replace All | Replaces the string in the entire document.


Find in Advanced Code dialog box

In this dialog box, you can find and replace code strings on the Advanced tabs of element properties.

Field | Description
Find what | The string to find.
Replace with | The string with which to replace the found string.
Match case | Enables case-sensitive search.
Find All | Starts the search.
Replace All | Replaces the string in the entire document.
Results | Displays the search results.


FlexiLayout Properties dialog box, Constants tab

Property/Button | Description
Table of constants | Lists the global constants. Each constant has a name and value.
"Add…" button | Opens the Add Global Constant dialog box where you can enter a name and value for the new constant.
"Delete" button | Deletes the constant selected in the table of constants.
"Edit…" button | Opens the Edit Constant dialog box where you can change the name and value of a global constant.


FlexiLayout Properties dialog box, FlexiLayout tab

Property | Description
Name | The name of the FlexiLayout. The default name is FlexiLayout1.
Version | The version of the FlexiLayout. The version number will be saved in the exported file making it possible to distinguish between different versions of the same FlexiLayout.
Pre-recognition parameters | Text languages | Lists the installed OCR languages. Select the required language from the list.
Text type Lists the available text types. Select the text type which corresponds to the text to be pre-recognized:
  • Typographic,
  • Matrix printer,
  • Typewriter
Mode Selects one of the two pre-recognition modes:
  1. Fast
  2. Full (use for poor quality images)
Multi-page parameters | Minimum number of pages | The minimum number of pages in the document.
Maximum number of pages | The maximum number of pages in the document.


Measure Tool dialog box

this dialog box allows you to measure objects and distances on the image. To measure an object, draw a rectangle around the object using the mouse.

The measurement is made in the user-defined units of measurement.

Field | Description
Rectangle | The coordinates of the measured rectangle.
Width | The width of the measured rectangle.
Height | The height of the measured rectangle.
Automatically copy results to Clipboard | Automatically copies the obtained coordinates to the Clipboard.


Number of Repeats dialog box

This dialog box sets the number of repeats for a regular expression element.

Field | Description
Min value | Sets the minimum number of repeats.
Max value | Sets the maximum number of repeats.


Open Images dialog box

Field | Description
Look in | Selects a folder with images.
File name | Selects an image file name.
Files of type | Selects an image file type.
Assemble to Reference Documents | Group of fields which define how pages must be assembled into the document in the reference assembly.
One document per file | Reference assembly method: one image file corresponds to one document.
Group by page count | Reference assembly method: the specified number of pages corresponds to one document.


Options dialog box

Field | Description
Units | Selects the units of measurement to be used in the program: dots, centimeter, millimeter, points, inches. All the measurements (element sizes, distances) will be in the units selected in this dialog box.
Layout colors | Selects the colors of objects in the program (the colors of elements, hypotheses, search area, etc.). Select the desired object, click the color button, and select the desired color on the palette. Clicking Reset selects the default color for the object. Clicking Reset All selects the default colors for all objects.
Text colors | Selects the color of lexemes in code (the colors of key words, variables, comments, etc.). Select the desired object, click the color button, and select the desired color on the palette. Clicking Reset selects the default color for the object. Clicking Reset All selects the default colors for all objects.
Possible page orientation | Selects the possible orientation of pages in the batch. Select Image>Correct Orientation to select page orientation automatically based on the selected pre-recognition language. If none of the options is selected, orientation will not be corrected automatically.
Rotated 180° | Select this option if the batch may contain pages rotated by 180°.
Rotated 90° clockwise | Select this option if the batch may contain pages rotated by 90° clockwise.
Rotated 90° counter-clockwise | Select this option if the batch may contain pages rotated by 90° counterclockwise.
Show image in black and white | Select this option to display color images in black and white. Clear this option to display color images.
Max number of advanced code symbols | The maximum number of characters in each of the fields on the Advanced tab.


Page Properties dialog box, Page tab

Property | Description
Page
Path to batch | The path to the batch folder where the images are stored.
Source image file | The path to the folder where the added image was originally stored.
Number | The number of the page.
Comment | Comment to the page.
Error | Errors that occurred when processing the image.
Reference FlexiLayout name | The name of the reference FlexiLayout for the page.


Project Properties dialog box

Property | Description
Name | The name of the project.
Path | The path to the project file.
Path to batch | The path to the batch.
Comment | A user comment to the project.


Class Properties dialog box, Class tab

Property | Description
Class name | The name of the class. The default name is Node[N].
ID Element identifies document type

Specifies how unique the class is.

  • Uniquely in project - the class is unique within the classifier
  • Uniquely on its tree level - the class is unique within the parent class
  • Non-uniquely - the class is not unique or non-identifying
Use this FlexiLayout for identified document type | The name of the FlexiLayout or layout alternative to be matched with the page (text string).


Classifier Properties dialog box

Property | Description
Name | The name of the classifier. The default name is ClassificationTree.
Version | The version of the classifier. The version number is saved in the exported file and can be used to distinguish the FlexiLayout versions.
Comment | A comment or a description for the FlexiLayout.
Pre-recognition parameters Text type Selects the type of the text to be recognized:
  • Typographic
  • Matrix printer
  • Typewriter
Mode Selects between one of the tow pre-recognition modes:
  • Fast (recommended),
  • Full (for poor-quality images)
Text languages | Selects pre-recognition languages from the list of available OCR languages.


Select Data to Delete dialog box

Property | Description
Extracted image objects | Deletes information about objects detected during pre-recognition.
Matched layout | Deletes information about detected blocks and elements obtained when matching the FlexiLayout.
Reference layout | Deletes information about the reference layout.


Select Element dialog box

Field | Description
Tree of elements | Selects an element in the tree of elements whose region will correspond to the location of the block.
Repeating instance | Selects an instance for a Repeating Group element. For details, see Using instances of a Repeating Group as reference, excluded or source elements.


Select Element to Exclude dialog box

Property | Description
Tree of elements | Selects an element in the tree of elements whose region will be excluded from the search area.
Repeating instance | Selects an instance for a Repeating Group element. For details, see Using instances of a Repeating Group as reference, excluded or source elements.


Fuzzy interval visual editor

ABBYY FlexiLayout Studio 9.0 offers a visual editor to make specifying fuzzy intervals easier. You can open the fuzzy interval editor from the Properties dialog box of a Character String element (Character String tab, [image] button) or from the main menu by selecting Tools>Fuzzy Interval Editor….

Show me...

This dialog box displays a graph representation of the fuzzy interval. The vertical axis measures the quality of the hypothesis and the horizontal axis measures the linear dimensions or the number of characters.

The "zoom in" and "zoom out" buttons change the horizontal scale (the vertical scale is always from 0 to 1). The left and right arrows move the image to the left or to the right respectively.

The fields below the graph contain the numerical values of the interval. You can specify the interval either by editing the graph with your mouse or by entering the desired numerical values in the corresponding fields.

The visual fuzzy interval editor operates in two modes:

  1. Fuzzy intervals for units of measurement, which may be fractional. In this case, select Distance under Interval type.

    Note: If dot is selected as the unit of measurement, the distance must be specified using integers.

  2. Fuzzy intervals for positive integers, such as string length in characters. In this case, select Integer under Interval type.

    Note: If you open the fuzzy interval editor from the Properties dialog box of a Character String element, one of the two modes is automatically selected depending on the field from which you called the editor.

Editing the graph. You can change the interval by moving the green markers to the right or to the left with your mouse. You can also change the angle of the slopes. Certain restrictions apply: you cannot move the left marker to the right of the right marker, etc. The corresponding numerical values will be displayed in the fields below the graph.

Changing the numerical values directly. The Left, Left non-penalized, Right, and Right non-penalized fields correspond to the representation of the fuzzy interval in the program. Left and Right are the extreme points, Left non-penalized and Right non-penalized are the non-penalized points. The Left slope and Right slope groups set the slope of the sides of the graph, which represent the penalty coefficient for deviating by a Distance from the non-penalized point. Changing a slope moves the corresponding extreme point without changing the non-penalized point. Changing an extreme and non-penalized point results in changes in the corresponding slope. When you edit fields, the depiction and the values of the dependent fields are changed accordingly.

Saving the results

If the fuzzy interval editor was called from the Properties dialog box of a Character String element, clicking OK will automatically insert the fuzzy interval into the corresponding field of the dialog box.

If the fuzzy interval editor was called from the Tools menu, you can copy the fuzzy interval from the Result field or from the Code field. The purpose of the Code field is to allow you to paste the code into the code on the Advanced tab, for example, when using a fuzzy interval as an argument of the FuzzyQuality function. See Using Nearest and FuzzyQuality to search for elements.


Element Properties dialog box, General tab

Property | Description
Name | The name of the element. By default, the element will be given the name [the type of the element][the sequence number of the element of this type]
Full name | The full name of the element generated by the program on the basis of the elements position in the tree of elements. This name is used in expressions written in the FlexiLayout language.
Search Control

Specifies whether the element is required, optional, or prohibited (see the Required, optional, and prohibited elements section. The following options are available:

  • Optional element
  • Required element
  • Prohibited element
Null hypothesis quality | Specifies the probability of the null hypothesis. The probability estimate is a number between 0 and 1. The default value is 0.97. This property is available only if Optional element is selected in the Search Control section.
Number of surviving hypotheses The maximum number of hypotheses which may be formulated for the element. The default number for simple elements is 5, the default number for Group elements is 1.

Important!
We do not recommend increasing the default numbers too much.
Min number of found subelements | The minimum number of detected subelements to consider the compound element detected. Available only for Group, Header, and Footer elements.

More

An overview of element properties


Element Properties dialog box, Static Text tab

Property | Description
Static Text
Search text The text to find on the image. If you need to find a phrase consisting of several words written in one line, you can enter this phrase without spaces. Variants are separated by a vertical line ("|"). Phrase variants are enclosed in braces and are separated by a vertical line: { }|{ }.
You can enter search text in a separate window. Click [image] to open a separate window.
Search text from database | Searches for text from a database.
Connection string | The database connection string. Click [image] to set up database connection.
Query text | The text to find in the database. Click [image] to enter your query in a separate window.
Search text from file | Searches for text from a file.
Browse… | Specifies the file that contains the text to be found.
Max number of errors | The maximum number of errors in the word. By default the number of errors is unlimited. This setting is similar to the next setting, but is measured in absolute numbers.
Max error percentage | The maximum percentage of errors in the word (calculated as a ratio of the number of errors in the hypothesis to the total number of characters in the hypothesis). The default setting is 30%.
Max space length | Specified the maximum absolute length of the space inside the detected object.
Whole words only | Finds whole words only.
Match case | Enables case-sensitive search (the program distinguishes between small and capital letters).
Take spaces into account | Specifies that spaces will be taken into account when searching for the text. If the option is not selected, the spaces will be removed from the search text. ignoring spaces speeds up the search. If your search phrase may stretch over several lines or you must allow for missing words, enter the search phrase with spaces and disable this option.
Permit multiple lines Specifies that the phrase can be written in several lines.

Important!
This property is only available if Take spaces into account is selected.
Line break penalty The coefficient (a number from 0 to 1) by which the quality of the hypothesis is multiplied each time the phrase is carried to a new line. The hypothesis is penalized for each line break.

Important!
This property is only available if you have selected Permit multiple lines.
Permit missing words Specifies whether the text must contain all the words of the given phrase in the specified order.

Important!
This property is only available if Take spaces into account is selected.
Missing word penalty The coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied if a word from the specified phrase is not found in the hypothesis. The hypothesis is penalized for each missing word.

Important!
This property is only available if you have selected Permit missing words.

More

Static Text


Element Properties dialog box, Separator tab

Property | Description
Orientation The orientation of the separator:
  • Vertical

or

  • Horizontal
Min length | The minimum length of the separator. The objects shorter than the specified length will not be considered as valid hypotheses.
Max length | The maximum length of the separator. The objects longer than the specified length will not be considered as valid hypotheses.
Min relative length (%) | The minimum relative length of the separator (a number from 0 to 100). The relative length of the separator is calculated as [the length of the separator]/[the length of the element’s search area]. The objects shorter than the specified length will not be considered as valid hypotheses.
Penalty limit for length | The minimum coefficient by which the quality of the hypothesis may be multiplied as a penalty for its length. When its quality is assessed, a hypothesis may be penalized for the length of the separator: the longer the separator object, the higher the quality of the hypothesis. he highest quality of 1 is assigned to a separator whose length is the same as the search area. When the relative length of the separator decreases from 1 to 0, the quality of the hypothesis decreases in direct proportion from 1 to Penalty limit for length.
Fits entirely within search area | If this option is selected, the separator must fit entirely within the search area. Otherwise, parts of the separator may lie outside the search area.
Space
Max length | The maximum length of space between neighboring segments of the separator which allows merging them into one separator object. This parameter is used to formulate hypotheses for Separator elements on the basis of the detected separator objects on the image.
Max relative length (%) | The maximum relative length of space between neighboring segments of the separator which allows merging them into one separator object. This parameter is calculated as [space length]/[separator length].
Orthogonal shift | The maximum distance between two separators which allows merging two parallel separators into one object. (Measured orthogonally to the orientation of the separators.)

More

Separator


Element Properties dialog box, White Gap tab

Property | Description
White Gap
Orientation The orientation of the White Gap:
  • Vertical
  • Horizontal.
Min width/height | The minimum width/height of the White Gap (the parameter is called width for vertical gaps and height for horizontal gaps).
Search among object of type | Searches for a white gap among objects of a certain type: Text, Punctuation mark, Picture, Inverted text, Checkmark, Separator, Barcode. More than one type of object may be selected.
Lower threshold limit | The lower limit of the White Gap threshold on the histogram. The threshold must be greater than the value you enter in this field.
Upper threshold limit | The upper limit of the White Gap threshold on the histogram. The threshold must be less than the value you enter in this field.
Threshold coefficient (%) | Coefficient used to calculate the White Gap threshold. The program determines the histogram maximum in the search area and multiplies it by the threshold coefficient.

More

White Gap


Element Properties dialog box, Barcode tab

Property Description
Barcode
Barcode type The type of the barcode.

Note: You can select several barcode types.
Orientation The orientation of the barcode:

  • Left-to-Right,

  • Bottom-to-Top,

  • Right-to-Left,

  • Top-to-Bottom.

Note: You can select several orientations.

More

Barcode element


Element Properties dialog box, Character String tab

Property | Description
Character String
Regular expression A regular expression which describes the character string. This is an alternative to the alphabets.

Tip: You can click [image] and select elements for your regular expression from a drop-down list.

Important!
If you use a regular expression, the following parameters will become unavailable: Alphabets, Percentage of non-alphabet characters and Allow embedded hypotheses.
Alphabets List of alphabets Lists the sets of characters (alphabets) specified for the element. For each alphabet, the program displays:
  • Character Set
  • Percentage of alphabet characters
Add… | Opens the Add New Alphabet dialog box where you can specify an alphabet and its parameters.
Delete | Removes an alphabet from the list.
Edit… | Opens the Edit Alphabet dialog box where you can edit the alphabet and its parameters.
Allow embedded hypotheses | Allows/forbids the program to formulate hypotheses which are embedded in other hypotheses. If you forbid embedded hypotheses, the program will attempt to find the longest possible hypothesis.
Percentage of non-alphabet characters | The maximum percentage of non-alphabet characters allowed in the object. This is a number from 0 to 100.
Whole words only | Finds whole words only.
Word count The number of words in the line (specified by means of a fuzzy interval).

Tip: Use the [image] button to specify fuzzy intervals in a separate window that visualizes fuzzy intervals for your convenience.

Detect words by interword space Specify how lines should be divided into words. Disable this option to detect words automatically. Enabling this option will divide a line into words whenever the space between neighboring characters is greater than or equal to the value entered in Min interword space

Note: In the case of automatic word detection, word ends are detected based on spaces or other symbols that separate words (e.g. ",", ";", "/", "?" - the exact set of symbols depends on the selected pre-recognition language), or based on other attributes. To make sure that the program correctly divides lines into words, review the text objects on the test images (Image>Show Image Objects> Recognized Words.
Min interword space | The minimum distance between characters. If the distance is greater than the specified minimum, the line is divided into words at this point. The value is specified in the selected units of measurement.
Max space length | The maximum length of space within the object. When the program formulates a hypothesis, it will add characters to the hypothesis until the space between the neighboring characters does not exceed Max space length.
Character count The length of the character string (i.e. the number of characters in the string). This parameter is a fuzzy interval (a set of 4 increasing integers). The parameter evaluates the quality of the hypothesis on the basis of its length.

Let us assume we have the fuzzy interval {f1,f2,f3,f4}, and the length of the character string equals L. If L is in the range from f2 to f3 (i.e. L>=f2 and L<=f3), then the quality of the hypothesis will equal 1. If L is in the range from f1 to f2, then the quality of the hypothesis will vary from 0 to 1 (Quality(f1) = 0, Quality(f2) = 1). Similarly, if L is in the range from f3 to f4, the quality of the hypothesis will vary from 1 to 0 (Quality(f3) = 1, Quality(f4) = 0). If L does not belong to the range from f1 to f4 (i.e. L<f1 or L>f4), then the quality of the hypothesis equals 0 (Quality(L) = 0).

Tip: You can use a visual editor to specify a fuzzy interval. Click [image] to open the fuzzy interval visual editor.

More

Character String


Element Properties dialog box, Text Fragment ta

Element Properties dialog box, Text Fragment

Property | Description
Line count | The number of lines in the paragraph (specified by means of a fuzzy interval).
Fragment width | The width of the paragraph in characters (specified by means of a fuzzy interval).
Min font height | The minimum height of characters (font size). Specified in the selected units of measurement.
Max font height | The maximum height of characters. Specified in the selected units of measurement.
Max line length variation (%) | The maximum variation in line length. Calculated as the difference in length between the longest and the shortest line divided by the length of the longest line.
Max line height variation (%) | Maximum variation in line height. Calculated as the difference in height between the tallest and the smallest line divided by the height of the tallest line.
Min horizontal line overlap (%) | Minimum horizontal overlap of neighboring lines. Calculated by dividing the length of the common segment of the lines by the length of the shortest line.
Max space length in line | Maximum length of the space inside the detected object. Specified in the selected units of measurement. When the program searches for text, it adds characters to the string until the distance between the neighboring characters becomes greater than this value.
Max interline space | Maximum distance between lines. Specified in the selected units of measurement..
Max relative interline space | Maximum distance between two lines divided by the height of the top line. If the distance between the lines is greater than this value, the second line is excluded from the hypothesis.
Whole words only | Specifies whether word parts should be included into the hypothesis if words are only partially contained within the search area. Disable this option to exclude word parts from consideration.
Ignore separators | Ignores separators when searching for the paragraph. Disable this option if the paragraphs are marked off by separators.
Remove stamp | Specifies whether the program should look for and remove a stamp, which may be placed over a text fragment. If this option is selected, the program will look for text fragments with a superimposed stamp in the bottom right corner and remove them from the search area.

More

Text Fragment


Element Properties dialog box, Date tab

Property | Description
Date
Format Date The format of the date, i.e. the order in which the day, month and year are written.

Note: You can select several variants.
Day The format in which the day may be written:

  • Allow single digit

  • Two digits only

Note: You can select both variants.
Month The format in which the month may be written:

  • Allow single digit

  • Two digits only

  • Word

Note: You can select several variants.
Year The format in which the year may be written:

  • Two digits

  • Four digits

Note: You can select both variants.
Date interval | from | The earliest possible date.
to | The latest possible date.
Language The language in which the month may be written:
  • Russian
  • English
Note: This property becomes available if you select Word for the month format.
Separators | The separators which may be used to separate the parts of the date. Possible separators must be separated by spaces.
Max space length | Specifies the maximum absolute length of the space inside the detected object.

More

Date element


Element Properties dialog box, Object Collection tab

Property | Description
Object Collection
Type Selects the type of the objects.

Note: You can select several variants.
Object size | Min height | The minimum height of the object.
Max height | The maximum height of the object.
Min width | The minimum width of the object.
Max width | The maximum width of the object.

More

Object Collection


Element Properties dialog box, Phone tab

Property | Description
Prefixes for phone numbers | Lists the possible phone prefixes. A prefix is a word or phrase such as 'tel.', 'Phone', etc..
Add… | Opens the Add Phone Prefix dialog box where you can enter a prefix.
Edit… | Opens the Edit Phone Prefix dialog box where you can change a prefix.
Delete | Deletes the selected prefix from the list.
Missing prefix penalty | Sets the penalty (a number from 0 to 1) by which the quality of the Phone hypothesis must be multiplied if the prefix is not found.
Possible digit separators | Lists the symbols that may separate digits in the phone number. Each separator must be a single symbol. By default, the list includes a space, i.e. digits may be divided by spaces. When entering several alternative symbols, you need not separate them by commas or spaces.
Max space length | Specifies the maximum absolute length of the space inside the detected object.
Minimum number of digits | Sets the minimum number of digits in the phone number.
Maximum number of digits | Sets the maximum number of digits in the phone number.
Area code/city code brackets | Specifies whether the city/area code is enclosed in brackets.
Brackets used for the city/area code | Displays the brackets which may be used to enclose the city/area code.
Add… | Opens the Add Phone Code Brackets dialog box where you can list the types of closing and opening brackets.
Edit… | Opens the Edit Phone Code Brackets dialog box where you can change he types of opening and closing brackets.
Delete | Deletes the selected symbols from the lest.

More

Phone element


Element Properties dialog box, Currency tab

Property | Description
Currency names | Lists the allowed currency names.
Add… | Opens the Add Currency Name dialog box where you can enter the names of currencies.
Edit… | Opens the Edit Currency Name dialog box where you can change the names of currencies.
Delete | Deletes the selected currency from the list.
Missing name penalty | A coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied, if the name of the currency is not found.
Minimum value | The minimum sum.
Maximum value | The maximum sum.
Possible fractional part separators | Lists the symbols which may separate the integer part from the fractional part. The separator must be a single symbol. When entering several alternative separators, you need not separate them by commas or spaces.
Max space length in line | Specifies the maximum absolute length of the space inside the detected object.
Currency name position | Sets the location of the currency name relative to the numerical value. Select either: Left of value or Right of value.
Allow missing fractional part | Specifies whether the fractional part is optional or not.
Allow missing separator | Specifies whether a separator is required or not.

More

Currency element


Element Properties dialog box, Repeating Group tab

Field | Description
Document mode | Enables the Document search mode for group instances.
Min repetitions | Minimum number of group instances in the document.
Max repetitions | Maximum number of group instances in the document.
Page mode | Enables the Paginal search mode for group instances.
Min repetitions on page | Minimum number of group instances on the page.
Max repetitions on page | Maximum number of group instances on the page.

See also

Repeating Group


Table Properties dialog box, Columns tab

Property | Description
Table block | Displays the name of the Table block which corresponds to the Table element.
Select | Opens the Select Table Block dialog box where you can select the Table block corresponding to the Table element.
Columns of selected table block | Lists the names of columns in the selected Table block.
Properties… | Opens the Column Properties dialog box. To set the search constraints for a column, select the column in the list and click the Properties…button.

More

Selecting a Table block and specifying search constraints for columns


Column Properties dialog box

Property | Description
Detect by keyword in name | Select this option to detect columns by keywords in column names.
Keywords | The keywords to look for on the images.
Whole words only | Select this option to search for whole words only.
Multi-line name | Specifies that the name may stretch over several lines.
Missing keyword penalty | The coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied if the keyword is not found in the hypothesis.
Use found element as column name | Select this option to use the region of the found element to detect a column. Note: The element whose region will be used to detect the column must located above the Table element in the FlexiLayout tree.
Check content type | Checks the content of the column to make sure that the columns has been detected correctly. If the data type in the column is the same as the data type specified by the user, the column is considered detected successfully. Otherwise, a null hypothesis will be generated.
Type of column content Select the data type of the column from the drop down list:

  • Text;

  • Currency;

  • Date;

  • Regular expression;

  • Number.
Regular expression This field becomes available if you select the Regular expression option to check the content of the column.
Enter the regular expression which describes the data type.
See Character String for details.
Missing content penalty | Sets the penalty for the hypotheses. The coefficient (a number from 0 to 1) by which the quality of the hypothesis will be multiplied if the actual data type in the column does not coincide with the data type specified by the user.
Absolute area constraints | This option sets the exact coordinates of the column search area.
Left boundary | Enter the coordinates of the left column boundary in this field.
Right boundary | Enter the coordinates of the right column boundary in this field.

More

Selecting a Table block and specifying search constraints for columns


Table Properties dialog box, Order tab

Property | Description
Fixed column order | Sets a fixed order of columns in the table.
List of possible column orders | Lists all the possible orders of columns in the table. Each order has a name. The columns are listed in the order in which they will appear on the images.
Add… | Opens the Add Fixed Column Order dialog box where you can define a column order and give it a name.
Edit… | Opens the Edit Fixed Column Order dialog box where you can change a column order and rename it.
Delete | Deletes a column order from the list.
Rules for column order | Select this option if you wish to use a rule to describe the possible column orders.
List of order rules | Displays a list of rules for column orders.
Add… | Opens the Add Column Order Rule dialog box where you can create a column order rule and give it a name.
Edit… | Opens the Edit Column Order Rule dialog box where you can change a column order rule and rename it.
Delete | Deletes a column order rule.

More

Order of table columns


Table Properties dialog box, Header tab

Property | Description
Look for header | Specifies whether the program should look for a header.
Search options | Sets the search constraints for the header.
Header is optional | Specifies whether the header is optional or not.
Null hypothesis quality | Sets the quality of the null hypotheses for the header if the header is not found.
Number of hypotheses | Sets the maximum number of hypotheses which the program may generate when looking for the header.
Header is on each page | Specifies that the table header occurs on every page (for multi-page tables).
Absolute area constraints | Select this option if you wish to enter the coordinates of the header.
Coordinates field | Sets the coordinates of the rectangle enclosing the footer, e.g. [left1, top1, right1, bottom1]; [left2, top2, right2, bottom2].

More

Table header


Table Properties dialog box, Footer tab

Property | Description
Look for footer | Specifies whether the program should look for a footer.
Search options | Sets the search constraints for the footer.
Footer is optional | Specifies whether the footer is optional or not.
Null hypothesis quality | Sets the quality of the null hypotheses for the footer if the footer is not found.
Search by keyword | Searches the footer by keywords or phrases.
Keywords | Lists the keywords to look for. After typing each word, press Enter.
Whole words only | Uses the region of an already found element to look for the footer. Note: The element whose region is used to look for the footer must be located above the Table element in the FlexiLayout tree.
Use found element as footer | If this option is selected, the specified keywords or phrases must be found in whole when searching for the footer of the table with the help of keywords.
The field of the reference element | Displays the name of the reference element.
 | Opens the Select Element dialog box where you can select the element whose region will be used as the region of the footer.
Absolute area constraints | Specifies that the table footer occurs on every page (for multi-page tables).
Footer is on each page | Select this option if you wish to enter the coordinates of the footer.
Coordinates field | Sets the coordinates of the rectangle enclosing the footer, e.g. [left1, top1, right1, bottom1]; [left2, top2, right2, bottom2].

More

Table footer


Table Properties dialog box, Rows tab

Property | Description
Detect rows automatically | Detects rows automatically.
One line of text corresponds to one row | Tells the program that each line of text in the table must correspond to one row.
Use master columns to detect rows | Uses a master column to divide the table into rows.
Master columns | The list of master columns that will be used to divide the table into rows
 | Opens the Select Master Columns dialog box where you can select the columns whose cells will be used to divide the tables into rows.
Master column text alignment | Specifies how the text should be aligned in the cells of the master columns. Top aligns the text by the top border, Bottom aligns the text by the bottom border.
One line of text corresponds to one row | When this option is selected, each line of text in the master column forms one table row.
Words not to be treated as a separate line of text | Lists the words or phrases which occupy a separate line but which must be ignored when dividing the table into rows. Press Enter after typing each word or phrase.

More

Table rows


Element Properties dialog box, Label tab

Property | Description
Label | The name of the field. If the name includes more than one word and all of them are known to be positioned on one line, the text may be entered without spaces. Word variants are separated with "|" (vertical line). Phrase variants are specified in braces and a separated with vertical lines: { }|{ }.
Max number of errors | The maximum number of errors in a word. Not limited by default.
Max error percentage | Specifies the maximum percentage of errors in a word (i.e. the number of errors in the text of the hypotheses divided by the number of letters in the text of the hypothesis). The default value is 30%.
Max space length | Specifies the maximum length of the space inside the detected object.
Whole words only | Searches for whole words only.
Take spaces into account | Specifies whether spaces should be ignored in the search. If this option is not selected, the spaces will be removed from the text. To speed up the search, the spaces are best ignored. However, if a phrase may be positioned on several lines or if some of the words may be missing, specify the search phrase with spaces and select Take spaces into account.
Permit multiple lines | Allows phrases carried over to the next line. Note: This property is available if Take spaces into account is selected.
Line break penalty | Specifies the coefficient (a number between 0 and 1) by which the quality of the hypothesis is multiplied whenever it is carried over to the next line. Note: This property is available if Permit multiple lines.
Permit missing words | Specifies whether the text must contain all the words of the phrase (in the order specified). Note: This property is available if Take spaces into account is selected.
Missing word penalty | Specifies the coefficient (a number between 0 and 1) by which the quality of the hypothesis is multiplied whenever a word from the specified phrase is not detected. Note: This property is available if Permit missing words.

More

Labeled Field


Element Properties dialog box, Field Position tab

Element Properties dialog box, Field Position

Property | Description
Field position | The position of the field relative to its name (to the right, to the left, above, or below).
Field alignment The alignment of the field's search area relative to the rectangle of the name. The available options depend on the value in the Field position field:

  • if the field is located to the right or to the left of its name, it may be aligned by the top or bottom boundary or be centered

  • if the field is located above or below its name, it may be aligned by the left or right boundary or be centered

Minimum space | The minimum size of the gap between the field and its name.
Detect indent size | Specifies whether a White Gap element should be sued to detect the distance between the field and its name.
Search area width | The width of the search area.
Search area height | The height of the search area.

More

Labeled Field


Element Properties dialog box, Field tab

Element Properties dialog box, Field

Property | Description
Content type | The type of the field. Depending on the type of the field, the Field Position tab will display different parameters.
Fixed variants |
Variants | The text to find. If you need to find a phrase consisting of several words written in one line, you can enter this phrase without spaces. Variants are separated by a vertical line ("|"). Phrase variants are enclosed in braces and are separated by a vertical line: { }|{ }.
Max number of errors | The maximum number of errors in a word. Not limited by default.
Max error percentage | Specifies the maximum percentage of errors in a word (i.e. the number of errors in the text of the hypotheses divided by the number of letters in the text of the hypothesis). The default value is 30%.
Max space length | Specifies the maximum length of the space inside the detected object.
Whole words only | Searches for whole words only.
Take spaces into account | Specifies whether spaces should be ignored in the search. If this option is not selected, the spaces will be removed from the text. To speed up the search, the spaces are best ignored. However, if a phrase may be positioned on several lines or if some of the words may be missing, specify the search phrase with spaces and select Take spaces into account.
Permit multiple lines | Allows phrases carried over to the next line. Note: This property is available if Take spaces into account is selected.
Line break penalty | Specifies the coefficient (a number between 0 and 1) by which the quality of the hypothesis is multiplied whenever it is carried over to the next line. Note: This property is available if Permit multiple lines.
Permit missing words | Specifies whether the text must contain all the words of the phrase (in the order specified). Note: This property is available if Take spaces into account is selected.
Missing word penalty | Specifies the coefficient (a number between 0 and 1) by which the quality of the hypothesis is multiplied whenever a word from the specified phrase is not detected. Note: This property is available if Permit missing words.
Number |
Minimum number of digits | The minimum number of digits in the number.
Maximum number of digits | The maximum number of digits in the number.
Max error percentage | The maximum percentage of errors.
Allow separators | specifies whether separators are allowed in numbers. The set of digits used in the search is supplemented with a set of separators with an allowed share of 30%
Currency |
Currency names | List of currency names.
Phone |
Min number of digits | Minimum number of digits in the phone number.
Max number of digits | Minimum number of digits in the phone number.
Regular expression |
Regular expression | The regular expression that specifies the search pattern to be used.
Min length | The minimum length of the string.
Max length | The maximum length of the string.

More

Labeled Field


Element Properties dialog box, Search Constraints tab

Property |  | Description
Absolute search area constraints |  | Specifies an absolute search area.
Pages |  | Specifies the pages on which to search.
Range |  | Specifies the range or enumerates the pages on which to search. For example: 3,5, 8-12. This option is available if Range is selected in Pages.
Region |  | Specifies an absolute search area on the page by providing the coordinates of one or more rectangles. For example: [left1, top1, right1, bottom1]; [left2, top2, right2, bottom2].
Search areas |  | Lists the absolute search areas specified.
 | Add | Adds a new search area.
 | Delete | Delete the element selected in the list of elements to be deleted.
Exclude elements |  | Displays the list of elements whose regions are excluded from the search area.
 | Add… | Opens the Select Element to Exclude dialog box where you can select an element whose region will be excluded from the search area.
 | Delete | Deletes the element selected in the list of elements to exclude.

More

Specifying a search area


Element Properties dialog box, Relations tab

Property | Description
Relation | Sets a relation type: Left of, Right of, Above, or Below.
Reference element | Sets the element relative to which the location of another element will be specified. Click [image] and select the desired reference element in the dialog box.
Element boundary | Sets the boundary of the element's region relative to which the search area will be specified.
Offset | Sets an offset value for the search area boundary.
Add | Adds a new relation
Relations Displays the specified relations. For each relation the following information is shown:

  • enabled/disabled

  • type

  • element relative to which the relation is specified

  • offset
button | Moves the selected relation up in the Relations tab.
button | Moves the selected relation down in the Relations tab.
Nearest | Specifies the Nearest property, which tells the program to select the hypothesis that is closest to a certain element or point on the image.
To | Specifies the object closest to the element to be detected. Select the desired object from the drop-down list: Element, X coordinate, Y coordinate, Point, Page top edge, Page bottom edge, Page left edge, Page right edge.
X | Specifies the X-coordinate of the axis or point selected in the To field.
Y | Specifies the Y-coordinate of the axis or point selected in the To field.
Reference element | Specifies the element closest to the element to be detected. The element must be specified if you selected Element in the To field. Click [image] and select the desired reference element in the dialog box.

More

Relative search area


Element Properties dialog box, Advanced tab

Field or button | Description
Advanced pre-search relations | Allows you to specify the properties of an element in the FlexiLayout language. Here you can specify the same properties as in the GUI dialog boxes, as well as some additional properties. Note: The code entered in this field is executed immediately before the program starts looking for the corresponding object.
Check | Checks the code in the Advanced pre-search relations field.
Advanced post-search relations | Allows you to specify additional constraints on the objects corresponding to the elements in the FlexiLayout language. The purpose of the code in this field is to adjust the quality of the formulated hypothesis. Note: The code entered in this field is executed after the hypothesis has been generated. The code is always executed for one hypothesis.
Check | Checks the code in the Advanced post-search relations field.
User-defined properties | Specifies element fields (see the Element fields section for details).
Check | Verifies the code in the User-defined properties field.
>> | Opens a separate code editor window.
Code | Translates the settings you have made in the dialog boxes into code. You can review the code on the Code tab of the Properties dialog box.

More

Additional search constraints


Repeating Group Properties dialog box, Advanced for All Instances tab

The Properties dialog box for a Repeating Group element provides two tabs where you can specify addition al constraints: Advanced and Advanced for All Instances. On the Advanced tab, you can specify additional search constraints for individual instances of the group. On the Advanced for All Instances tab, you can specify additional search constraints for all the instances. See also Additional search constraints for a Repeating Group element.

Field | Description
Advanced pre-search relations for all instances | Allows you to specify the properties of all the instances of a repeating group and define the search constraints in the FlexiLayout language. In this field, you can describe the same properties that can be specified via the Properties dialog box and some additional properties. Note: The code entered in this field is executed immediately before the program starts looking for the corresponding object.
Check | Checks the code in the Advanced pre-search relations for all instances field.
Advanced post-search relations for all instances | Allows you to specify additional constraints on the objects corresponding to the given Repeating Group element in the FlexiLayout language. The purpose of the code in this field is to adjust the quality of the formulated hypothesis. Note: The code entered in this field is executed after the hypothesis has been generated. The code is always executed for one hypothesis.
Check | Checks the code in the Advanced post-search relations for all instancesfield.
>> | Opens a separate code editor window.


Element Properties dialog box, Code tab

Field | Description
Code | Displays the code of all the search constraints and properties specified for the element.


Element Properties dialog box, Errors tab

Field | Description
Errors | Displays errors detected when building the FlexiLayout.


Patents

U.S. Patent Nos. 5,258,855, 5,369,508, 5,625,465, 5,768,416, and 6,094,505.


Tutorial

In this Tutorial you will find two sample FlexiLayouts and detailed step-by-step instructions on how to create them.

For the sake of simplicity, the samples in this Tutorial use one-page documents. For sample FlexiLayouts designed to process more complex documents, see the folders Contract, Invoice, Letter, Prices, etc. located in

<disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\.

  • The Halloween Registration Form section describes the creation of a FlexiLayout for a simple registration form. You will learn how to create blocks and elements, set simple search constraints and describe field locations. The FlexiLayout Studio project with the test images and a ready-made FlexiLayout can be found in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\RegistrationForm.
  • The Easiest Recipes section describes the creation of a FlexiLayout for a more complex form with various types of fields. Here you will learn some tricks and non-standard approaches that may be helpful when describing field locations. The FlexiLayout Studio project with the test images and a ready-made FlexiLayout can be found in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Recipe.
  • The Invoices section describes a creation of a flexible template (FlexiLayout) for a simple invoice. You will create blocks and elements of type Table and also learn some approaches which may be used in case of realistic images. The tutorial has links to various sections of the help file, particularly Help/Tutorial/Sample1 and Help/Tutorial/Sample2, which describe in detail how to create a FlexiLayout with blocks and elements of different types (except Table) and how to do most basic actions. You can find a third sample FlexiLayout in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Invoice One-Page. The test images in the project are typical of invoices and contain standard data fields and a table.

Note: Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.


Sample 1. Introduction

Important! For the sake of simplicity, a one-page document is used in this sample.

This sample document is a typical example of a registration form for which a FlexiLayout must be created. You will go through all the steps required to create a FlexiLayout that will detect the following elements: Static Text, Character String, Barcode, Text Fragment, Date, Separator, and Object Collection.

The ultimate goal is to create a FlexiLayout which will enable ABBYY FlexiCapture to locate the following fields on all the test pages:

  • NAME
  • YOUR PLANET NAME
  • YOUR SPACESHIP NUMBER
  • DATE YOU ARRIVED AT THE EARTH
  • YOUR IDENTITY NUMBER ON THE PARTY
  • YOUR PHOTO IN FANCY DRESS

Additionally, the FlexiLayout must enable FlexiCapture to find a text field in which the guest has entered the information he or she managed to find about Halloween. Unlike all the above fields, the exact name of this field is not known in advance.

Show me...


Sample 1. Step 1: Creating a new project

Note: A project is a set of files created by ABBYY FlexiLayout™ Studio which contains all the data pertaining to a FlexiLayout.

  1. Create a new folder and name it Sample1.
  2. Run ABBYY FlexiLayout Studio.
  3. Create a new project by selecting File>New Project>FlexiLayout Project…).
    Show me...

  4. Type the name for the project: Sample1.

After you create the project, the Halloween Form folder will contain:

  • Sample1.fsp – the file of your project,
  • Sample1Batch – the default folder where all images added to the batch are stored,
  • Sample1Templates – the default folder where the FlexiLayout is stored.


Sample 1. Step 2: Adding images to the batch

Note: A batch is a set of test images (pages) to be used for debugging a FlexiLayout.

Once the new project has been created, you must add the test images to the batch. The images will be used to debug the FlexiLayout.

  1. Click the Batch tab in the main program window.
  2. Select the Open & Add Images… command in the File menu or in the shortcut menu.
Show me...

  3. In the Open Images dialog box, select the One document per file option and specify the test image files.

    Note: Sample 1 images can be found in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Halloween Form\Halloween FormBatch.

The test images you add to the batch will be displayed in the Batch window.

Show me...

Note: When adding images, you can specify how reference assembly must be performed. By selecting One document per file, you tell the program that each image is a separate document.
For more information about reference assembly, see the Reference document assembly section of the help file.


Sample 1. Step 3: Setting the FlexiLayout properties

By default, the program has named the new FlexiLayout FlexiLayout1 (see the FlexiLayout tab in the FlexiLayout Properties dialog box).

Show me...

We recommend renaming the FlexiLayout and giving it a meaningful name for the sake of convenience. The name you give to your FlexiLayout will also be displayed in ABBYY FlexiCapture after you have created a FlexiCapture FlexiLayout on the basis of the FlexiLayout.

To set the FlexiLayout properties (these also include the name of the FlexiLayout):

  1. Double-click the name of the FlexiLayout (i.e. FlexiLayout1) or right-click the FlexiLayout and select Properties… in the shortcut menu.

  2. In the Name field, type a new name for the FlexiLayout, e.g. RegistrationForm.

  3. Specify the pre-recognition parameters:

  • From the Text languages list, select English as the pre-recognition language (the documents contain text in English).

  • Select Typographic in the Text type group (this is the default setting), assuming that in this particular case neither a dot-matrix printer nor a typewriter will be used to fill in the form.

  • Mode. You can select either Fast or Full pre-recognition mode, depending on the quality of the images to be processed. Since the sample images are of good quality, contain no noise and almost no small print, select the default Fast mode. This will speed up pre-recognition, both when creating the FlexiLayout in FlexiLayout Studio and when processing it in FlexiCapture.

Multi-page parameters – Our document contains one page. Therefore, specify 1 for Minimum number of pages and 1 for Maximum number of pages.

Show me...

There is no need to specify the beginning and end of documents, so you can delete the predefined Header and Footer elements form the list of elements of your FlexiLayout.

Note: You can add Header and Footer elements to a FlexiLayout to help the program detect the beginning and end of documents. If the program fails to find both the Header and Footer elements when matching the FlexiLayout, it will use the maximum number of pages specified in the FlexiLayout for document separation. For the document in this example, we specified 1 as the maximum number of pages.


Sample 1. Step 4: Pre-recognition

Before you start creating form elements, you need to know which objects on the form can be used as "signposts" when looking for fields (blocks). These are usually pictures and/or text fragments that are consistently detected during pre-recognition.

To start pre-recognition:

  1. Select all the images in the batch.

  2. Select the Pre-Recognize command in the Batch menu or in the shortcut menu of each image.

    Show me...

Note: If you change images in the batch or add new images, you will need to restart the pre-recognition procedure. If an image has not been pre-recognized, it will be pre-recognized when matching it with its FlexiLayout.


Sample 1. Step 5: Viewing images and pre-recognition results

Open the first page in the batch:

  • Double-click the corresponding line in the Batch window.

or

  • Select the Open Page command in the Batch menu or in the shortcut menu of the batch.

    Show me...

The image will be displayed in the Image window in Matched Layout mode.

By default, the pre-recognition results are not displayed on the image.

To view the pre-recognition results:

  • Select the Show Image Objects command in the Image menu and then select the type of image object you wish to see.

    Show me...

or

  • Click the corresponding icon on the Extracted Objects toolbar.

Note: You can also view all the objects by selecting the Show All Objects command.


Sample 1. Step 6: Analyzing pre-recognition results and selecting reference elements

When analyzing the pre-recognition results, you might wish to view different types of objects and images separately.

First, find the objects which have been consistently detected during pre-recognition on each of the test images and which the program may use as reference elements when looking for fields.

Once you have viewed the pre-recognition results for all the test images, you will notice that:

  1. The program has consistently detected all the Text objects corresponding to the names of the fields, and all the Barcode objects and Separator objects around the photograph. These objects can be used as reference elements when looking for the blocks.

  2. On images 3, 5 and 6 the program has detected separators that are missing on the other images. These objects cannot be used as reference elements when looking for the blocks.

  3. On images 1 and 6, the program has failed to recognize all parts of the photograph as image objects of type Picture. This means that looking just for a Picture object the program will not find the entire photograph, and you will need to use additional methods. (They will be described in Step 20: Describing the Photograph field.)

Now you can create and set up the reference elements and specify the search constraints for blocks corresponding for fields to be search.


Sample 1. Step 7: Creating a form identifier

When processing semi-structured forms in ABBYY FlexiCapture, one would normally wish to exclude forms not belonging to the current type. One way to identify a form is to mark at least one element as required. A required element must be consistently detected on all the forms of a given type (otherwise, the program will not be able to match the form and its FlexiLayout).

In this particular case, the form heading (HALLOWEEN REGISTRATION FORM) will make a good identifier element, since it contains distinct text that can be easily read by the OCR engine.

Note: You can specify an identifier element or set of elements in a predefined compound Header element (not described in this tutorial).

The form heading will be used solely to identify the form as belonging to the given type. In the FlexiLayout, specify the form heading as an element of type Static Text.

To create an ID element:

  1. Click the FlexiLayout tab in the program main window.

  2. Select SearchElements in the FlexiLayout tree.

  3. Select the Static Text command in FlexiLayout>Add element or in the shortcut menu of the element (New>Static Text).

  4. In the Name field, type a name for the element, e.g. IDHeader.

  5. Clear the Optional element box on the General tab to make the form heading a required element.

    Show me...

  6. Click the Static Text tab.
    Show me...

  7. In the Search text field, type the text to find: HALLOWEEN REGISTRATION FORM.
    Judging by the first image in the batch, one can assume that the form heading is written in one line. Therefore, you can type the heading without spaces to speed up looking for single-line static text.

  8. Set the maximum number of errors that may occur in the found text (either in percentage points or as a number). In this particular case we recommend setting the Max error percentage at 20, allowing 5 errors for 25 characters of the form heading.

Note: The optimal percentage of allowed errors can only be found by trial and error.


Sample 1. Step 8: Testing the identifier element

To check that the program can reliably detect the image object corresponding to identifier element IDHeader, try matching the FlexiLayout with each image in the batch:

  1. Open each image one by one.

  2. Select the Match command in the Image menu or in the shortcut menu of each image.

If the image and its FlexiLayout have been matched successfully, the program draws a blue frame around the detected element and the hypothesis which the program formulates about the IDHeader element will be marked with [image] in the Tree of Hypothesis. If you click the hypothesis, you will see the properties of the hypothesis in the Properties window.

Show me...

Once you have examined the FlexiLayout matching results for all the images, you will see that the program has failed to formulate a hypothesis for the IDHeader element on image 2 (it is marked with [image]). This is because the form heading is written in two lines on this image, whereas you described the IDHeader as single-line text.


Sample 1. Step 9: Adjusting the properties of the identifier element

For the identifier element to be detected consistently on all the forms, you need to adjust its properties:

  1. Open the element's Properties dialog box.
  2. Click the Static Text tab.
    Show me...

  3. In the Search text field, type the text to find, preserving the spaces: HALLOWEEN REGISTRATION FORM. This means that the program will look for a phrase which may not be written in one line.

  4. Select Take spaces into account and Permit multiple lines to specify that the search phrase may be written on more than one line.

  5. Set the Line break penalty to 1. This will preserve the quality of the hypothesis when it goes to the next line. If you set a smaller value, the hypothesis will be penalized.

Now if you try matching the FlexiLayout and the images, the program will detect the identifier element on all the test images.


Sample 1. Step 10: Describing the YOUR PLANET NAME field

The field names are detected reliably on all the test images and do not repeat on each given form. The order of the fields is the same on all the forms, even though their exact locations may vary from form to form. This means that for all the fields you can:

  1. Create Static Text elements to look for the name of the field.

  2. Use the field name to locate Character String, Text Fragment, Barcode etc. elements, which will then be used to look for the corresponding fields.

  3. Create blocks (which correspond to fields) and specify their location as coinciding with that of the corresponding reference elements.

To describe the location of the block corresponding to the YOUR PLANET NAME field:

  1. Create an element of type Static Text and name it PlanetNameHeader. This element will correspond to the name of the field YOUR PLANET NAME.

  2. Create an element of type Character String and name it PlanetName. This element will correspond to the field YOUR PLANET NAME proper.

  3. Create a block of type Text and name it PlanetName. This block will correspond to the field YOUR PLANET NAME.


Sample 1. Step 11: Describing the YOUR PLANET NAME field with a PlanetNameHeader element

Even though the YOUR PLANET NAME field is preceded by the NAME field, the FlexiLayout must first search for the field YOUR PLANET NAME. This will exclude the ambiguity which may arise if the FlexiLayout looks for the NAME field first. As the word NAME can be found in both field names, the program will formulate several hypotheses if you instruct it to look just for the word NAME without any additional constraints. To avoid this ambiguity, the program must first look for the YOUR PLANET NAME field and only then for the NAME field. In Step 15 you will impose additional constraints on the NAME field.

To create a PlanetNameHeader element:

  1. Create an element of type Static Text and name it PlanetNameHeader.
    Do not clear the Optional element box which is selected by default. Unlike the form heading, which is used as a form identifier and for this reason was specified as a required element, all the other form elements are assumed to be optional. This will allow the program to formulate null hypotheses even for those elements for which it fails to find the corresponding objects on the images.

    Show me...

  2. Click the Static Text tab.

  3. In the Search text field, type the text to search. Since the field name is written in one line on all the test images, you can type it without spaces: YOURPLANETNAME.

  4. Set the Max error percentage to 20, since the field name has more than one word and is fairly long.

Try matching the FlexiLayout with the test images and make sure that the program successfully finds the YOUR PLANET NAME field on all the images.

Show me...


Sample 1. Step 12: Describing the YOUR PLANET NAME field with a PlanetName element

We assume that the YOUR PLANET NAME field always contains only one line. Since, unlike the field name, the data in this field are not fixed, you must define it as a Character String element.

To create the PlanetName element:

  1. Create an element of type Character String and name it PlanetName.

    Show me...

  2. Click the Character String tab.

    Show me...

  3. Set the alphabet, i.e. all the characters that may be encountered in the names of planets and their satellites. Judging by the test images, the alphabet consists of English letters and parentheses. To set the alphabet, click the Add… button and select the required characters in the Add New Alphabet dialog box.

Note: The selected characters will be displayed in the Character Set column, (Character String tab, Alphabets field).

  4. Set the Percentage of alphabet characters to 100. This means that the program will take into account only the characters of the current element when looking for the object corresponding to PlanetName element.

    Show me...

Note: Generally, you can specify several alphabets for one element. In the Percentage of alphabet characters field, specify the maximum percentage of the characters of each alphabet in the element.

  5. Clear the Allow embedded hypotheses box. This will allow the program to formulate hypotheses which have the maximum length and meet all the search criteria. Otherwise the program may formulate several embedded hypotheses, each consisting of portions of one of the selected alphabets (taking into account the allowed percentage of non-alphabet characters).

  6. In the Percentage of non-alphabet characters field set the maximum percentage of non-alphabet characters to 10%.

Note: This value can only be selected by trial and error and can be changed when adjusting the FlexiLayout.

  7. In the Character count field, specify this fuzzy range: {0, 3, 35, 100}. This is an estimation of the length of the string of characters. We assume that the possible names of planets may have from 3 to 35 characters. Any hypotheses outside this range will be penalized.

Note: This value can only be selected by method of trial and error and can be changed when adjusting the FlexiLayout.

  8. Click the Relations tab.

    Show me...

    Use the PlanetNameHeader element as the reference element for the PlanetName element. The name of the planet will always be to the right of the field name and will be located on the same level with the name. Therefore, you must specify the location of the element relative to the name and to the name's top and bottom boundaries. Otherwise, the program will formulate a valid hypotheses for any text fragment that consists of characters of the set alphabet, even if it is located higher or lower than the name.
    to sum up: the program must look for the name of the planet described by the PlanetName element to the right of the field name specified as the PlanetNameHeader element and located on the same level with the PlanetNameHeader element.

  10. Specify that the PlanetName element is located to the right of the PlanetNameHeader element.
    Select PlanetNameHeader in the Select Element window. From the Relation drop-down list, select Right of and leave the default value of the Offset field equal to 0. Click the Add button.

    Show me...

  11. Specify that the PlanetName element is located not lower than the PlanetNameHeader element.

    Select PlanetNameHeader in the Select Element window. In the Relation drop-down list, select Above and set Offset to -100 (this value can only be selected by trial and error). This will give the program some leeway when detecting the position of the element relative to the name. The negative Offset value means that the element is located above the bottom boundary of the name. Click the Add button.

  12. Specify that the PlanetName element is located not higher than the PlanetNameHeader element.

    Select PlanetNameHeader in the Select Element window. In the Relation drop-down list, select Below and set Offset to -100 (this value can only be selected by trial and error). This will give the program some leeway when detecting the position of the element relative to the name. The negative Offset value means that the element is located below the top boundary of the name. Click the Add button.

Note: If you select <whole> in the Element boundary field, positive Offset values allow you to specify only the following locations: to the right of the right-hand boundary of the element, to the left of the left-hand boundary of the element, higher than the top boundary of the element, or lower than the bottom boundary of the element. If you select top and bottom in the Element boundary field, positive Offset values will limit the search area by the top and bottom boundaries of the element and exclude hypotheses which go beyond the top and bottom boundaries of the name of the field.


Sample 1. Step 13: Testing the YOUR PLANET NAME field

To check that the program can correctly find the field described by the PlanetName element, activate the Batch tab in the FlexiLayout Studio main window and try matching the FlexiLayout with each image in the batch:

  1. Open an image.

  2. Select the Match command in the Image menu or in the shortcut menu of each image.

Note: to carry out a fast check, select all the required images in the batch and then select the Match command in the shortcut menu of the batch. The results can be viewed in the Image window in Matched Layout mode. To carry out a more thorough check, which takes more time but allows you to view the formulated hypotheses, select the Match command for each open image separately.

Once you have matched the FlexiLayout with the images, you will see that the YOUR PLANET NAME field corresponding to the PlanetName element has been found successfully on all the images.

Show me...


Sample 1. Step 14: Describing the YOUR PLANET NAME field with a PlanetName block

To create a block corresponding to the YOUR PLANET NAME field:

  1. Click the FlexiLayout tab in the program main window.

  2. Select Blocks in the FlexiLayout tree.

  3. Select Add Blocks>Text in the FlexiLayout menu or New>Text in the shortcut menu.

    Show me...

  4. In the Properties dialog box, type a name for the block in the Name field, e.g. PlanetName

Note: The name of the block need not coincide with the name of the element corresponding to the YOUR PLANET NAME field, but this is convenient when working with the FlexiLayout.

  5. To describe the location of the block, select Source element. Click "…" and specify the PlanetName element as the source element.

    Show me...


Sample 1. Step 15: Describing the NAME field

To describe the location of the block corresponding to the NAME field:

  1. Create an element of type Static Text and name it NameHeader. This element will correspond to the name of the NAME field.

  2. Create an element of type Character String and name it GuestName. This element will correspond to the NAME field proper.

  3. Create a GuestName block corresponding to the NAME field.

The elements and the block for this field are created as described in Steps 10 to 14 with the following exceptions:

  • When specifying the search area for NameHeader, specify that it is located above the PlanetName Header element. This will prevent the program from formulating an erroneous hypothesis that contains the word NAME from the name YOUR PLANET NAME.

    Show me...

  • Unlike the alphabet of the PlanetName element, the alphabet of the GuestName element must include only English letters and the "-" symbol. In the Character count field, specify the fuzzy interval {0, 0, 50, INF}.

  • When specifying the search area for the GuestName element, specify the NameHeader element as the reference element.

  • When creating the GuestName block, specify the GuestName element as the source element.


Sample 1. Step 16: Describing the YOUR SPACESHIP NUMBER field

To describe the location of the block corresponding to the YOUR SPACESHIP NUMBER field:

  1. Create an element of type Static Text and name it SpaceShipHeader. This element will correspond to the name of the YOUR SPACESHIP NUMBER field.

  2. Create an element of type Character String and name it SpaceShip. This element will correspond to the YOUR SPACESHIP NUMBER field proper.

  3. Create a block and name it SpaceShip. This block will corresponding to the YOUR SPACESHIP NUMBER field.

The elements and the block for this field are created as described in Steps 10 to 14 with the following exceptions:

  • Unlike for the PlanetName element, specify a regular expression for the SpaceShip element rather than an alphabet. This is necessary because the format of data in the YOUR SPACESHIP NUMBER field is the same on all the test images.
    The format of spaceship numbers can be defined using the following regular expression:

    [N]{5}[A-Z][A-Z][N]{2} (for more on regular expressions see the help file for ABBYY FlexiCapture)

    Show me...

  • When defining the search area for the SpaceShip element, specify the SpaceShipHeader element as the reference element.

  • When creating the SpaceShip block, specify the SpaceShip element as the source element.


Sample 1. Step 17: Describing the DATE YOU ARRIVED AT THE EARTH field

To describe the location of the block corresponding to the DATE YOU ARRIVED AT THE EARTH field:

  1. Create an element of type Static Text and name it DateHeader. This element will correspond to the name of the DATE YOU ARRIVED AT THE EARTH field.

  2. Create an element of type Date and name it ArrivalDate. This element will correspond to the DATE YOU ARRIVED AT THE EARTH field proper.

  3. Create a block and name it ArrivalDate. This block will correspond to the DATE YOU ARRIVED AT THE EARTH field.

The elements and the block for this field are created as described in Steps 10 to 14 with the following exceptions:

  • Unlike for the PlanetNameHeader element, enter the text in the Search text field with spaces: DATE YOU ARRIVED AT THE EARTH. Select the Take spaces into account and Permit multiple lines options and set Line break penalty to 1.

    Show me...

  • For the DATE YOU ARRIVED AT THE EARTH field, create an element of type Date and name it ArrivalDate. For the ArrivalDate element, specify all the possible date formats on the Date tab. We assume that months will always be written in digits, and the year will always be a 4-digit number. Clear the Word box in the Month group and the Two digits box in the Year group. Other options may be left unchanged.

    Show me...

  • When defining the search area for the ArrivalDate element, specify the DateHeader element as the reference element.

  • When creating the ArrivalDate block, specify the ArrivalDate element as the source element.


Sample 1. Step 18: Describing the YOUR IDENTITY NUMBER ON THE PARTY field

To describe the location of the block corresponding to the YOUR IDENTITY NUMBER ON THE PARTY field:

  1. Create an element of type Static Text and name it BarcodeHeader. This element will correspond to the name of the YOUR IDENTITY NUMBER ON THE PARTY field.

  2. Create an element of type Barcode and name it IdentityNumber. This element will correspond to the YOUR IDENTITY NUMBER ON THE PARTY field proper.

  3. Create a block and name it IdentityNumber. This block will correspond to the YOUR IDENTITY NUMBER ON THE PARTY field.

The elements and block for this field are created as described in Steps 10 to 14 with the following exceptions:

  • For the YOUR IDENTITY NUMBER ON THE PARTY field, create an element of type Barcode and name it IdentityNumber. For the IdentityNumber element, specify the type of barcode (EAN13) and its orientation (Left-to-Right) on the Barcode tab.

    Show me...

  • When creating an IdentityNumber block, specify the IdentityNumber element as the source element.


Sample 1. Step 19: Describing the ANY TEXT field

The field located at the bottom of the form has no fixed name. Therefore, objects other than names must be used to locate this field. We will assume that each ANY TEXT field has its own unique name.

First, try using the already created IdentityNumber element to look for the ANY TEXT field, because on all the test images the ANY TEXT field is located below this element.

Note: Do not use separators that are present on some images, as those are not regular and reliable elements. See Step 6.

To use the IdentityNumber element to find the object corresponding to the ANY TEXT field:

  1. Create an element of type Text Fragment and name it TextField. This element will correspond to the ANY TEXT field.

  2. On the Relations tab, describe the location of the TextField element as Below the IdentityNumber element.

Try finding the ANY TEXT field using the IdentityNumber element. You will see that on some images the hypothesis will also include barcode digits. Therefore, you need to describe the location of the ANY TEXT field more precisely.

Create a White Gap element with horizontal orientation. This element will correspond to the gap between the text and the barcode. This element will be used as a reference element when looking for the ANY TEXT field.

Be sure to place the White Gap element above the TextField element in the tree of elements.

  1. Create an element of type White Gap and name it BetweenGap.

  2. On the White Gap tab, select Horizontal as the orientation of the BetweenGap.

    Show me...

  3. On the Relations tab, specify the search area for the BetweenGap element as an area below the IdentityNumber element but no further than 200 dots from the bottom boundary of the BarcodeHeader element.

    Show me...

  4. Create an element of type Text Fragment and name it TextField.

  5. On the Relations tab, describe the location of the TextField element as Below the BetweenGap element, Offset=0.

Try matching the FlexiLayout with all the test images. You will see that the formulated hypothesis about the TextField element does not contain any unwanted data. This means that the BetweenGap element can be used to detect the TextField element.

To describe the location of the block corresponding to the ANY TEXT field, create a block of type Text, name it TextField and specify the TextField element as the source element.


Sample 1. Step 20: Describing the YOUR PHOTO IN FANCY DRESS field

As has been noted in Step 6, not all the parts of the photo on images 1 and 6 were recognized as image objects of type Picture.

to get a full photo, the program needs to find all the types of Image Object located in the photo area.

For the sake of convenience, group all the photo elements in one compound Photo element. This will also limit the number of formulated hypotheses.

Show me...

The Group element "Photo" will include:

  • a PhotoPicture element of type Object Collection corresponding to the photo;

  • a PhotoHeader element of type Static Text corresponding to the name YOUR PHOTO IN FANCY DRESS;

  • four separators around the photo which are required for finding the PhotoPicture element.

As the text of the name (namely, YOUR PHOTO IN FANCY DRESS) occurs nowhere else in this document, we added the corresponding element first and will search for the separators relative to this element.

Since the name YOUR PHOTO IN FANCY DRESS is unique on the form, add it to the Group element and use it to look for the separators.

To create an element corresponding to the field name:

  1. Create an element of type Static Text and name it PhotoHeader.

  2. The properties of the element are set similarly to the other field names as described above.

Try matching the FlexiLayout with the images. You will see that the program reliably detects the name on all the images.

Create Separator elements for the four separators around the photo and give them the following names:

  • USeparator - upper separator

  • BSeparator - lower separator

  • LSeparator - left separator

  • RSeparator - right separator

On the Separator tab in the Properties dialog box, specify the orientation of each of the 4 separators (Vertical or Horizontal). Do not change the other properties.

Show me...

Now use the test images to specify the search area for each of the separators.

Upper separator (USeparator element):

  • below the photo caption but not farther than 100 dots from its top boundary (Below the PhotoHeader element and Above the PhotoHeader, Offset = -100).

  • within the area which is not longer than the length of the caption by more than 80 dots on each side (Left of the right boundary of the PhotoHeader element, Offset = -80, Element boundary = right and Right of the left boundary of the PhotoHeader element, Offset = -80, Element boundary = left).

Lower separator (BSeparator element):

  • below the name of the NAME field (Below the NameHeader element),

  • above bottom of IdentityNumber (Above the IdentityNumberelement, Element boundary = bottom).

  • within the area which is not longer than the length of the name by more than 80 dots on each side (Left of the right boundary of the PhotoHeader element, Offset = -80, Element boundary = right and Right of the left boundary of the PhotoHeader element, Offset = -80, Element boundary = left).

Left separator (LSeparator element):

  • within the area which is not wider than the distance between the upper and lower separators by more than 50 dots on each side (Below the USeparator element, Offset = -50, and Above the BSeparator element, Offset = -50).

  • the separator is located not far from the left boundary of the upper separator, the distance cannot exceed 40 dots (Right of the left boundary of the USeparator element, Offset = -20, Element boundary = left, and Left of the left boundary of the USeparator element, Offset = -20, Element boundary = left).

Right separator (RSeparator element):

  • within the area which is not wider than the distance between the upper and lower separators by more than 50 dots on each side (Below the USeparator element, Offset = -50, and Above the BSeparator element, Offset = -50).

  • the separator is located not far from the right boundary of the upper separator, the distance cannot exceed 40 dots (Right of the right boundary of the USeparator element, Offset = -20, Element boundary = right, and Left of the right boundary of the USeparator element, Offset = -20, Element boundary = right).

Now if you try matching the FlexiLayout with the images you will see that the program can detect these areas. In the Tree of Hypotheses, right-click a hypothesis and select Show Search Area in the shortcut menu. If the search criteria are wrong and the program failed to locate the search area properly, you will immediately notice this. You may also see that even the search area of a correct hypothesis needs some adjustment, e.g. it may be too small.

The maximum size of all the separators was detected by trial and error while studying the properties of Separator objects during pre-recognition.

To describe the YOUR PHOTO IN FANCY DRESS field:

  1. Create an element of type Object Collection and name it PhotoPicture.

  2. On the Relations tab, specify the search area for the PhotoPicture element:

  • below the upper separator (Below the USeparator element)

  • above the lower separator (Above the BSeparator element)

  • to the right of the left separator (Right of the LSeparator element)

  • to the left of the right separator (Left of the RSeparator element)

Then create the PhotoPicture block and specify the Photo Picture element as the source element.


Sample 1. Step 21: Exporting the FlexiLayout

Before you can use your FlexiLayout in ABBYY FlexiCapture, you must export it into AFL format:

  1. Select the Export… command in the File menu.
  2. In the Export FlexiLayout dialog box, enter a name for the file and select the folder in which to save the file.

The resulting *.afl file can then be used in ABBYY FlexiCapture.


Sample 1. Step 22: Opening the FlexiLayout in ABBYY FormReader

Sample 1. Step 22: Opening the FlexiLayout in ABBYY FlexiCapture

The FlexiLayout saved in *.afl format can be opened in ABBYY FlexiCapture:

  1. Launch ABBYY FlexiCapture.
  2. Create a new project or open an existing project.
  3. Create a new document template or open an existing template in the Template Editor.

Note: To open an existing template, go to Project>Document Templates..., select the required template from the list of available templates and click Edit...

Show me...

  3. In the Template Editor, open the Section Properties dialog box (View>Properties...).
  4. Click the Flexible Description tab.
  5. Click the Load... button.
    Show me...

  6. In the Open dialog box, select the required *.afl file.

Note: The required template blocks will be created automatically based on the FlexiLayout. To view the blocks, select the Match Section command in the Tools menu.


Easiest Recipes

Important! For the sake of simplicity, a one-page document is used in this sample.

This sample illustrates the creation of a FlexiLayout for a document which has more different types of fields compared with the Halloween Registration Form. This sample will not only help you to go through all the steps of FlexiLayout creation, but will also teach you some tricks that can be used to describe the position of objects on the document image.

The FlexiLayout Studio project with the test images and a ready–made FlexiLayout can be found in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayoutStudio\Recipe.

The FlexiLayout must reliably detect the following fields on all the test pages:

  • Recipe Name
  • Recipe #
  • Ingredients
  • Cooking Time
  • Cooking Description
Show me the example...


Sample 2. Step 1: Creating a new project

  1. Create a new folder and name it Recipes.
  2. Run ABBYY FlexiLayout Studio.
  3. Create a new project (<File>New Project>FlexiLayout Project…).
    Show me...

  4. Type the name for the project: Sample2.

Once the project is created, the Recipes folder will contain:

  • Sample2.fsp - the project file
  • Sample2Batch – the default folder where the images added to the batch are stored
  • Sample2Templates - the default folder where the FlexiLayout is stored


Sample 2. Step 2: Adding images to the batch

Once the new project has been created, you must add all the test images to the batch. The test images will be used to debug the FlexiLayout.

  1. Click the Batch tab in the main program window.
  2. Select the Open & Add Images… command in the File menu or in the shortcut menu.
Show me...

  3. Select One document per file and specify the test image files.

    Note:

    (The test images for this sample can be found in
    <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\ FlexiLayoutStudio\Recipe.)

The test images you add to the batch will be displayed in the Batch window.

Show me...

Note: When adding images, you can immediately specify how the reference document assembly should be performed. Selecting One document per file, tells the program that each image is a separate document. For more about reference document assembly, see Help\Debugging the FlexiLayout\Reference document assembly.


Sample 2. Step 3: Setting the FlexiLayout properties

By default, the program has named the new FlexiLayout FlexiLayout1 (see the FlexiLayout tab in the FlexiLayout Properties dialog box).

We recommend renaming the FlexiLayout and giving it a meaningful name for the sake of convenience.

To set the FlexiLayout properties (these also include the name of the FlexiLayout):

  1. Double-click the name of the FlexiLayout (i.e. FlexiLayout1) or right-click the FlexiLayout and select Properties… in the shortcut menu.

  2. In the Name field, type a new name for the FlexiLayout, e.g. Recipe.

  3. Specify the pre-recognition parameters:

  • From the Text languages list, select English as the pre-recognition language (the documents contain text in English).

  • Select Typographic in the Text type group (this is the default setting).

  • Select the Fast pre-recognition mode (this is the default setting).

Multi-page parameters – Our document consists of one page. Therefore set Minimum number of pages and Maximum number of pages to 1.

Show me...

Note: For more about selecting the right parameters, see Sample 1, Step 3.
For one-page documents, you do not need to use predefined compound Header and Footer elements to indicate the beginning and end of the documents. Therefore, you can remove them from the list of FlexiLayout elements.

Note: You can add Header and Footer elements to your FlexiLayout to indicate the beginning and end of the documents. If neither the Header nor the Footer element is found when matching the FlexiLayout, the program will use the maximum number of pages specified in the FlexiLayout as the number of pages in the document. For this particular document we specified 1 as the maximum number of pages.


Sample 2. Step 4: Pre-recognition

Before you start creating document elements, you need to know which objects on the form can be used as "signposts" when looking for fields (blocks). These are usually pictures and/or text fragments that are consistently detected on all the images during pre-recognition.

To start pre-recognition:

  1. Select all the images in the batch.

  2. Select the Pre-Recognize command in the Batch menu or in the shortcut menu of each image.

    Show me...

Note: If you replace images in the batch or add new images, you will need to restart the pre-recognition procedure. If an image has not been pre-recognized, it will be pre-recognized when matching it with its FlexiLayout.


Sample 2. Step 5: Viewing images and pre-recognition results

Pre-recognition shows that all the text objects corresponding to the names of the fields, the inverted text, and the horizontal separators can be reliably detected. The program can use these objects as "signposts" or reference elements when looking for other objects.

Now you can create reference elements. Click the FlexiLayout tab in the main program window.

Note: For more about viewing images and pre-recognition results, see Sample 1, Step 5 and Step 6.

Note: For each image in the batch, you can create a reference layout which reflects the desired positions of the blocks on the image. A reference layout can be created manually or based on the FlexiLayout matching results. Reference layouts are used when debugging FlexiLayouts, allowing you to compare the matching results with the expected positions of the blocks on each of the images. See Reference layout for details.


Sample 2. Step 6: Creating a form identifier

When processing semi-structured documents in ABBYY FlexiCapture, one would normally wish to exclude forms not belonging to the current type. One way to identify a document is to mark at least one element as required.

In this particular case, the document heading will make a good identifier element, since it contains distinct text that can be easily read by the OCR engine.

Note: An identifier element or set of elements can be described in a predefined Header element (not used in this sample).

The document heading will be used solely to identify the document as belonging to the given type and will not be recognized in ABBYY FlexiCapture. In the FlexiLayout, describe the document heading as an element of type Static Text:

  1. Click the FlexiLayout tab in the program main window.

  2. Select SearchElements in the FlexiLayout tree.

  3. Select the Static Text command in FlexiLayout>Add Elements>Static Text or in the shortcut menu of the element.

  4. In the Name field, type a name for the element, e.g. FormHeader.

  5. Clear the Optional element box on the General tab, because the form heading is a required element.

    Show me...

  6. Click the Static Text tab.

    Show me...

  7. In the Search text field, type the text to find.
    The batch contains test forms that have different headings: Easiest Recipes or Easy to Cook Recipes. Enter both headings.
    The headings are written in one line on all the test images. Therefore, you can type the headings without spaces to speed up looking for single-line static text. Separate the two alternative headings by "|".

  8. Set the maximum number of errors that the detected text may contain (either in percentage points or as a number). In this particular case we recommend setting the Max error percentage to 20, allowing 5 errors among the 25 characters of the form heading.

Note: The maximum number of errors is selected by method of trial and error.


Sample 2. Step 7: Testing the identifier element

To check that the program can reliably detect the identifier element FormHeader, try matching the FlexiLayout with each image in the batch:

  1. Open each image.

  2. Select the Match command in the Image menu or in the shortcut menu of each image.

If the image and its FlexiLayout have been matched successfully, the hypothesis which the program formulates about the FormHeader element will be marked with [image] in the Tree of Hypotheses. If you click the hypothesis, the program will draw a blue frame around the detected element. You will see the properties of the hypothesis in the Properties window.

Show me...

When you try matching the FlexiLayout with the images you will see that on some of the images the program has found a part of the phrase above the form heading instead of the heading itself. The phrase "Enjoy our collection of easiest recipes from over 50 countries of the world" occurs on almost all the images in the batch. To prevent the program from mistaking this phrase for the form heading, you need to adjust the properties if the identifier element. Since the phrase "Enjoy our collection…" is always located above the form heading, the program must look for an object that has all the properties specified by the element and is located closest to the bottom edge of the image.

To specify additional search constraints:

  1. Open the Properties dialog box for the FormHeader element.

  2. Click the Advanced tab.

  3. In the Advanced pre-search relations field, specify an additional search constraint: Look for an object that is closest to the bottom edge of the image. In the FlexiLayout language: NearestY: PageRect.Bottom;

Note: The same constraint can also be specified via the program’s graphical user interface. Click the Relations tab, select Nearest, and in the To: drop-down list select Page bottom edge.

Note: The Nearest function tells the program that out of the several hypotheses for the element it should look for the one nearest to a particular other element or point on the image (the distance between element centers is measured). Once the function is executed, only one hypotheses remains. This function does not take into account the quality of the hypotheses, as the choice is made at the stage when hypotheses are still being generated.

Once have matched the FlexiLayout with the images again, you will see that the program has reliably detected the form headings, which are described by the FormHeader element, on all the test images.


Sample 2. Step 8: Specifying the order in which the field Recipe # and the name for the recipe must be detected

Usually fields are detected via their names, but not all the fields on our documents have names. For example, the field containing the name of the recipe has no name. Therefore, a different approach must be used to detect this field.

The most obvious solution which first comes to mind is to tell the program that the recipe name is the object that is closest to the form’s heading. But if you look at test image 6, you will see that on this image the closest field is Recipe #:. Sometimes it is possible to specify additional search constraints which help the program to distinguish between the two fields, but in this particular case it is very difficult to differentiate between the two fields — the recipe name and the Recipe #: field are located very close to each other and have similar structures:

  1. The name Recipe #: and the field itself are located on the same level. The field may contain the same characters that may be used in the recipe name.

  2. One cannot be sure that the text in the recipe name will always be longer than the name Recipe #: and its field.

Note, however, that pre-recognition consistently detects the name Recipe #: on all the test images. This means that you can tell the program to look for Recipe #: first. Then the program will look for the recipe name: the program must look for an object that is closest to the form heading, but which is NOT Recipe #: (which will have been detected by then).


Sample 2. Step 9: Describing the Recipe #: field

The Recipe #: name is detected reliably on all the test images and does not repeat on each given form. This means that for Recipe #: you require:

  1. a Recipe element of type Static Text, which will correspond to the name Recipe #:.

  2. a RecipeNumber element of type Character String, which will correspond to the data in the field.

  3. a RecipeNumber block, which will correspond to the Recipe #: field.


Sample 2. Step 10: Creating the Recipe element

To create the Recipe element:

  1. Create an element of type Static Text and name it Recipe.
    Do not clear the Optional element box which is selected by default. Unlike the form heading, which is used as a form identifier and for this reason was specified as a required element, all the other form elements are assumed to be optional. This will allow the program to formulate hypotheses even for those elements for which it fails to find corresponding objects on the images.

    Show me...

  2. Click the Static Text tab.

  3. In the Search text field, type the text to search. Since the field name has only one line on all the test images, you can type it without spaces: Recipe#:.

  4. Set the Max error percentage to 20 (since the name of the field consists of only one word, it is unlikely to contain a very large number of errors).

Try matching the FlexiLayout with the test images and make sure that the program successfully finds the field name on all the images.


Sample 2. Step 11: Creating a RecipeNumber element

We assume that the Recipe # field always contains only one line. Since, unlike the field name, the data in this field are not fixed, you must describe it as an element of type Character String.

To create the RecipeNumber element:

  1. Create an element of type Character String and name it RecipeNumber.

    Show me...

  2. Click the Character String tab.

    Show me...

  3. Set the alphabet, i.e. all the characters that may be encountered in the recipe numbers. Judging by the test images, the alphabet includes digits and capital letters of the English alphabet. The order of letters and digits is not know beforehand. To set the alphabet, click the Add… button and select the required characters in the Add New Alphabet dialog box.

Note: The selected characters will be displayed in the Character Set column (Character String tab, Alphabets field).

  4. Set the Percentage of alphabet characters to 1. This means that the program will take into account only the characters of this alphabet when looking for the RecipeNumber element.

    Show me...

Note: You can specify several alphabets for one element. In this case, set the Percentage of alphabet characters for each alphabet used in the element.

  5. Clear the Allow embedded hypotheses box. This will allow the program to formulate hypotheses which have the maximum length and meet all the search criteria. Otherwise the program may formulate several embedded hypotheses, each consisting of portions of one of the selected alphabets (taking into account the allowed percentage of non-alphabet characters).

  6. Set the Percentage of non-alphabet characters to 20%.

Note: This value can only be selected by trial and error and can be changed when adjusting the FlexiLayout.

  7. In the Character count field, specify this fuzzy range: { 0, 8, 10, 16 }. This is an estimation of the length of the string of characters. We assume that the number is always 8 digits long. To be on the safe side, tell the program that the number may have from 8 to 10 digits. Any hypotheses outside this range will be penalized.

Note: This value can only be selected by trial and error and can be changed when adjusting the FlexiLayout.

  8. Click the Relations tab.

    Show me...

    Use the Recipe element as the reference element for the RecipeNumber element. The number of the recipe will always be located to the right of the field name and will be located on the same level with the name. Therefore, you must specify the location of the element relative to the name and to the name’s top and bottom boundaries. Otherwise, the program will formulate a valid hypothesis for any text fragment that consists of characters of the set alphabet, even if it is located higher or lower than the field name.
    to sum up: The program must look for the recipe number described by the RecipeNumber element to the right of the field name described by the Recipe element and located on the same level with the Recipe heading.

  10. Specify that the RecipeNumber element is located to the right of the right boundary of the Recipe element.
    Select Recipe in the Select Element window. From the Relation drop-down list, select Right of in the Element boundary drop-down list select right and leave the value of the Offset field unchanged (the default value is 0). Click the Add button.

    Show me...

  11. Specify that the RecipeNumber element is located not lower than the Recipe element.

    Select Recipe in the Select Element window. In the Relation drop-down list, select Above and set Offset to -50 (this value can only be selected by trial and error). This will give the program some leeway when detecting the position of the element relative to the top boundary of the field name. Negative Offset values allow you to specify that the bottom element boundary is located below the bottom boundary of the name. Click the Add button.

  12. Specify that the RecipeNumber element is located not higher than the Recipe element.

    Select Recipe in the Select Element window. In the Relation drop-down list, select Below and set Offset to -50 (this value can only be selected by trial and error). This will give the program some leeway when detecting the position of the element relative to the top boundary of the field name. Negative Offset values allow you to specify that the top element boundary is located above the top boundary of the name Click the Add button.

Note: If you select <whole> in the Element boundary field, positive Offset values allow you to specify only the following locations: to the right of the right-hand boundary of the element, to the left of the left-hand boundary of the element, higher than the top boundary of the element, or lower than the bottom boundary of the element. If you select top and bottom in the Element boundary field, positive Offset values will limit the search zone by the top and bottom boundaries of the element and exclude hypotheses which go beyond the left and right boundaries of the name of the field.

Try matching the FlexiLayout with the test images and make sure that the program successfully finds the field containing the number of the recipe on all the images.


Sample 2. Step 12: Creating the RecipeNumber block

To enable ABBYY FlexiCapture to recognize the number of the recipe, you must create a block corresponding to the Recipe # field and specify its location.

To create a block corresponding to the Recipe # field:

  1. Click the FlexiLayout tab in the program main window.

  2. Select Blocks in the FlexiLayout tree.

  3. Select Add Block>Text in the FlexiLayout menu or in the shortcut menu.

    Show me...

  4. In the Properties dialog box, type a name for the block in the Name field, e.g. RecipeNumber.

Note: The name of the block need not coincide with the name of the element corresponding to the Recipe # field. We recommend giving the block the same name as the field for the sake of convenience.

  5. To describe the location of the block, select Source element. Click "…" and specify the RecipeNumber element as the source element.

    Show me...


Sample 2. Step 13: Describing the field which contains the name of the recipe

Describe the recipe name field as the object closest to the bottom boundary of the form’s heading, but exclude those regions which contain the elements Recipe and RecipeNumber (see Step 8).

  1. Create an element of type Character String and name it RecipeName. This element will correspond to the name of the recipe.
  2. Create a RecipeName block corresponding to the field which contains the name of the recipe.

To create the RecipeName element:

  1. Create an element of Create Character String and name it RecipeName.
  2. Click the Character String tab.
  3. Set the required alphabet. Judging by the test images, the alphabet includes all the letters of the English alphabet, digits and the characters "#", "-", "&", and ".". The order and number of characters are not known in advance.
  4. Set the Percentage of alphabet characters to 1.
  5. Clear the Allow embedded hypotheses box.
  6. Set the Percentage of non-alphabet characters to 0.2 (i.e. 20%).
  7. In the Character count field, specify the fuzzy range that estimates the total length of all the character strings. Do not change the default range of {–1, –1, INF, INF}. This means that there are no constraints on the length of the character string.
  8. Click the Relations tab.
    Tell the program that the name of the recipe is located at least 100 dots lower than the bottom boundary of the form’s heading, i.e. there must be a gap at least 100 dots wide between the heading and the recipe name. If you look at the test images you will see that every line located below the heading meets this criterion. The search area must be narrowed.

  9. Click the Advanced tab.
    In the Advanced pre-search relations field, specify an additional search constraint: Look for the line closest to the top boundary of the form. In the FlexiLayout language this must be written as follows: NearestY: 0*dot;
    together with the search constraint on the Relations tab this narrows the search area to one line located closest to the form heading.

    Note: The same constraint can also be specified via the program’s graphical user interface. Click the Relations tab, select Nearest, and in the To drop-down list select Page top edge.

    Show me...

  10. Click the Search Constraints tab.

  11. As stated in Step 8, the regions of the elements Recipe and RecipeNumber must be excluded from the search area for RecipeName. Click the Add… button next to the Exclude elements field and in the Select Element to Exclude dialog box, select the Recipe and RecipeNumber elements.

    Show me...

Try matching the FlexiLayout with the test images and make sure that the program successfully finds the field which contains the name of the recipe on all the images.

Finally, create the RecipeName block. The RecipeName block is created similarly to the RecipeNumber block. The only exception is that you must specify the RecipeName element as the source element for the RecipeName block.


Sample 2. Step 14: Describing the Ingredients field

Judging by the test images, the list of ingredients is a text fragment which is always located below the name of the Ingredients field but above the separator located over the name of the Cooking field.

To make the description of the above elements easier and to restrict the number of possible hypotheses, group them into a Group element:

  1. Create a Group element and name it RecipeContents.

  2. Within the RecipeContents element, create an element of type Static Text and name it IngredientsHeader. This element will correspond to the name Ingredients. Specify the properties of the element as in Step 10 for the Recipe element.

  3. Within the RecipeContents element, create an element of type Separator which will correspond to the separator above the name Cooking. On the Separator tab, specify the orientation of the separator: Horizontal. In the element's Properties dialog box, click the Relations tab and specify the search constraints: below the name Ingredients: (i.e. Below the IngredientsHeader element).
    If you try matching the FlexiLayout, you will see that sometimes the program treats the lower boundary of an image as a separator.

    Note: The same constraint can also be specified via the program’s graphical user interface. Click the Relations, select Nearest, and in the To drop-down list select Element and specify IngredientsHeader as the Reference element.

    The problem can be solved by adding another search constraint. In the Advanced pre-search relations field (Properties dialog box, Advanced tab), add this search constraint: Look for the separator closest to the name Ingredients:. In the FlexiLayout language this must be written as follows: Nearest: SearchElements.RecipeContents.IngredientsHeader;

  4. Match the adjusted FlexiLayout once again.

  5. Matching the FlexiLayout with image 2 has generated two hypotheses for the IngredientsHeader element and two hypotheses for the Separator element. Note that the program has selected the best path which mistakenly recognized the word "ingredients" in the recipe as the name of the field and the bottom edge of the image as the separator.

    Show me...

    There is nothing unusual in this, because the found text fragment is so similar to the text described by the properties of the IngredientsHeader element (Static Text tab, Search text field), that it cannot be cut off by the error threshold set in the Max error percentage field (20). The sole difference between the two text fragments is the colon character ":".

    Note: We cannot set Max error percentage = 0 (or Max number of errors = 0) because recognition errors are may occur due to varying image quality. And if the Ingredients: name is not detected, the list of ingredients will not be detected either.

    The problem can be solved by adding another search constraint for the IngredientsHeader element. In the Advanced pre-search relations field (Properties dialog box, Advanced tab), add this search constraint: Look for the field name in the upper part of the image. In the FlexiLayout language this must be written as follows: Above: PageRect.top + PageRect.Height/2;

  6. Within the RecipeContents element, create an element of type Text Fragment and name it Ingredients. This element will correspond to the Ingredients field.
    Set the search constraints (element's Properties dialog box, Relations tab: below the Ingredients: heading (Below the IngredientsHeader), but above the separator (Above the Separator element).
    Try matching the FlexiLayout with the test images and make sure that the program successfully finds the Ingredients field on all the images.

Finally, create the Ingredients block. The Ingredients block is created similarly to the RecipeNumber block. The only exception is that you must specify the Ingredients element as the source element for the Ingredients block.


Sample 2. Step 15: Describing the field which contains the cooking instructions and the field which contains the cooking time

Create a Group element for the cooking time and cooking instructions:

  1. Create a Group element and name it Cooking.

  2. The Cooking element must contain the following elements

  • CookingTimeHeader element (of type Static Text) which corresponds to the time units specified in the Cooking Time field (see Step 16 for details).

  • CookingTime element (of type Character String), which corresponds to the Cooking Time field (see Step 17 for details).

  • InvertedHeader element (of type Object Collection), which corresponds to the name of the Cooking Instructions field (see Step 19 for details).

  • compound Instructions element (of type Group), which corresponds to the Cooking Instructions field (see Step 20 for details).


Sample 2. Step 16: Creating a CookingTimeHeader element

To create the CookingTimeHeader element:

  1. Create an element of type Static Text and name it CookingTimeHeader.

  2. Click the Static Text tab.
  3. In the Search text field, type the text to search: minutes|hour|hours.
  4. Set Max error percentage to 10.
  5. Click the Advanced tab.

  6. The field which contains the cooking time is located below all the other objects on the image. This means that you can set an additional search constraint in the Advanced pre-search relations field: Search for the object closest to the bottom of the page. In the FlexiLayout language this must be written as follows: NearestY: PageRect.Bottom;

    Note: The same constraint can also be specified via the program’s graphical user interface. Click the Relations tab, select Nearest, and in the To drop-down list select Page bottom edge.


Sample 2. Step 17: Creating a CookingTime element

To create the CookingTime element:

  1. Create an element of type Character String and name it CookingTime.
  2. Click the Character String tab.
  3. Set the required alphabet. Judging by the test images, the alphabet includes only digits.
  4. Set the Percentage of alphabet characters to 1.
  5. Clear the Allow embedded hypotheses box.
  6. Set the Percentage of non-alphabet characters to 10%.

  7. In the Character count field, specify this fuzzy range {0, 1, 3, 4}. This interval is an estimation of the length of the string of characters. We assume that the string may be 1 to 3 characters long. Any hypotheses outside this range will be penalized.

  8. Click the Relations tab.
  9. On the Relations tab, specify that the number indicating the cooking time is always located to the left of the units of time, and that the distance between the digits and the time units cannot exceed 100 dots (i.e. Left of the CookingTimeHeader element, Offset = 0 and Right of the left boundary of the CookingTimeHeader element, Offset = –100, Element boundary = left).
  10. Since the cooking time is always written on the same level as the units of time, add the following search constraints:
    - Above the CookingTimeHeader element, Offset = -20, Element boundary = bottom
    - Below the CookingTimeHeader element, Offset = -20, Element boundary = top


Sample 2. Step 18: Creating a CookingTime block

To create the CookingTime block:

  1. Activate the FlexiLayout window in the program main window.
  2. Select the Blocks object in the FlexiLayout tree.
  3. Select Add Block>Text in the FlexiLayout menu or New>Text in the shortcut menu.
  4. In the Properties dialog box, type a name for the block in the Name field, e.g. CookingTime.
  5. to describe the location of the block, select Expression.
  6. Describe the block as a rectangle created by merging the rectangles around the CookingTimeHeader and CookingTime elements. To give the program some leeway, enlarge the height and width of the resulting rectangle by 3mm.
    In the FlexiLayout language this must be written as follows:

Rect outputRect;
outputRect = SearchElements.Cooking.CookingTime.Rect Or
SearchElements.Cooking.CookingTimeHeader.Rect;
OutputRegion = outputRect;
OutputRegion.Inflate (3*mm, 3*mm);

Show me...


Sample 2. Step 19: Creating an InvertedHeader element

The name Cooking is inverted text (i.e. light text against a dark background).

To create the InvertedHeader element:

  1. Create an element of type Object Collection and name it InvertedHeader.
  2. Click the Object Collection tab.
  3. Select the Inverted text option in the Type group.
Show me...

Try matching the FlexiLayout with the test images and make sure that the program successfully finds the inverted text on all the images.


Sample 2. Step 20: Describing the Cooking field

In this step you will tell the program how to look for the field under the name Cooking, which contains cooking instructions and information about the number of servings.

Note that information about the number of servings is given after the word Serves on all the test images. However, on images 2, 3 and 4 the word "serves" is preceded by other words. Describe the field in such a way as to exclude this unwanted text from the block to be recognized.

For easier navigation in the FlexiLayout tree and to reduce the number of hypotheses for the Cooking element, create a Group element and name it Instructions:

  1. Within the Cooking element, create a Group element and name it Instructions.

  2. Within the Instructions element, create an element of type Static Text and name it Serves. This element will be used to locate the word "Serves" (see Step 21 for details).

  3. Within the Instructions element, create an element of type Character String and name it Servings. This element will be used to locate the number of servings (see Step 22 for details).

  4. Within the Instructions element, create an element of type Text Fragment and name it CookingInstructions. This element will correspond to the Cooking field (see Step 23 for details).

  5. Create a block corresponding to the Cooking field and name it CookingInstructions (see Step 24 for details).


Sample 2. Step 21: Creating a Serves element

To create the Serves element:

  1. Create an element of type Static Text and name it Serves.
  2. Click the Static Text tab.
  3. In the Search text field, type the text to search: Serves.
  4. Set Max error percentage to 20.
  5. Click the Advanced tab.
  6. In the Advanced pre-search relations field, specify an additional search constraint: Look for the object closest to the cooking time. In the FlexiLayout language this must be written as follows: Nearest: SearchElements.Cooking.CookingTimeHeader;

    Note: The same constraint can also be specified via the program’s graphical user interface. Click the Relations, select Nearest, and in the To drop-down list select Element and specify CookingTimeHeader as the Reference element.


Sample 2. Step 22: Creating a Servings element

To create the Servings element:

  1. Create an element of type Character String and name it Servings.
  2. Click the Character String tab.
  3. Set the required alphabet. Judging by the test images, the alphabet includes all the digits and the letters "T", "t", "O", and "o".
  4. Set the Percentage of alphabet characters to 1.
  5. Clear the Allow embedded hypotheses box.
  6. Set the Percentage of non-alphabet characters to 20.
  7. In the Character count field, specify this fuzzy range {0, 1, 10, 15}. This interval is an estimation of the length of the character string. We assume that the number of characters may be from 1 to 10. Any hypotheses outside this range will be penalized.
  8. Click the Relations tab.
  9. Since the number of servings is always located to the right of the word "Serves" and the distance between the right boundary of the word "Serves" and the right boundary of the number cannot exceed 200 dots, specify the following search constraints:
    - Right of the Serves element, Offset = 0
    - Left of the Serves element, Offset = -200, Element boundary = right
  10. Since the number of servings is always written on the same level with the word Serves, add the following search constraints:
    - Above the Serves element, Offset = -50
    - Below the Serves element, Offset = -50


Sample 2. Step 23: Describing the Cooking field

To create the CookingInstructions element:

  1. Create an element of type Text Fragment and name it CookingInstructions.
  2. Click the Relations tab.
  3. Since the cooking instructions are always located below the name Cooking but above the word "Serves", specify the following search constraints:
    - Below the InvertedHeader element, Offset = 0
    - Above the Serves element, Offset = 0


Sample 2. Step 24: Creating a CookingInstructions block

To create the CookingInstructions block:

  1. Click the FlexiLayout tab in the program main window.
  2. Select the Blocks object in the FlexiLayout tree.
  3. Select Blocks>New>Text in the FlexiLayout menu or in the shortcut menu.
  4. In the Properties dialog box, specify the name of the block in the Name field: CookingInstructions.
  5. to describe the location of the block, select Expression.
  6. You must describe the location of the block so that it includes only the cooking instructions and the number of servings. The block must not include unwanted text (i.e. any text that may precede the word "Serves"). Describe the block as a collection of rectangles around the following elements: CookingInstructions, Serves and Servings. This method allows you to specify non-rectangular regions.
    In the FlexiLayout language this must be written as follows:

RectArray outputRectArray;
//initializing the variable with the help of an empty constructor
outputRectArray = RectArray();
//adding the rectangles of the hypotheses of three elements
outputRectArray.Add (
    SearchElements.Cooking.Instructions.CookingInstructions.Rect );
outputRectArray.Add( SearchElements.Cooking.Instructions.Serves.Rect );
outputRectArray.Add( SearchElements.Cooking.Instructions.Servings.Rect );
OutputRegion = Region( outputRectArray );


Sample 2. Step 25: The FlexiLayout is ready

The resulting FlexiLayout can be saved as an *.afl file and exported into ABBYY FlexiCapture.

For more about exporting FlexiLayouts see Sample 1, Step 21 and Step 22.


Invoices

Important! For the sake of simplicity, this sample uses a one-page document. This sample describes the creation of a FlexiLayout for a simple invoice. Compared to the previous samples, this one includes a table.

This sample will guide you through all the steps of FlexiLayout creation and at the same time teach you some tricks you can use to describe the position of objects. Most importantly, it will teach you how to detect image objects which correspond to Table elements.

This sample contains references to the following sections of the help file: Help/Tutorial/Sample1 and Help/Tutorial/Sample2, which describe the creation of FlexiLayouts with blocks and elements of various types (except Tables). Some of the basic operations are described there in greater detail.

The sample document is a rather simple but typical invoice. It differs from the previous examples in that it has a table field and some fields of the form may be absent.

Show me the example...

Below we provide step-by-step instructions for creating a FlexiLayout.

The purpose of a FlexiLayout for this document is to ensure reliable detection of the following fields on all the test images (provided they occur on a document ):

  • Invoice Number
  • Invoice Date
  • Delivery Address
  • Total Quantity
  • Total Amount
  • Country
  • Invoice Table (only the following columns: Reference, Designation, Quantity, Unit Price, Total)
Show me the example...


Sample 3. Step 1: Preparatory settings

  1. Create a new folder and name it Invoices One-Page.

  2. Start ABBYY FlexiLayout Studio 9.0.

  3. Create a new project and name it Sample3 (for more details see Tutorial 1, Step 1).

  4. Add images to the batch (for more details see Tutorial 1, Step 2 ).

    Note: Test images of Tutorial 3 are stored in <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Invoice One-Page\Invoice One-PageBatch.

    Under Microsoft Windows Vista, the sample projects can be found in <disk name>:\\Users\Public\ABBYY\FlexiCapture9.0\Samples.

  5. Specify FlexiLayout properties (for more details see Tutorial 1, Step 3). Under Text type, select Typographic, and in Text languages select English. Note that the program allows you to specify more than one language. Name the FlexiLayout Invoice. Do not change the default Fast pre-recognition mode, and set Minimum number of pages and Maximum number of pages to 1.

Show me...

Note: See Tutorial 1, Step 3 for more about selecting the right pre–recognition parameters.

For one-page documents, you do not need to use predefined compound Header and Footer elements to indicate the beginning and end of the documents. Therefore, you can remove them from the list of FlexiLayout elements.

Note: You can add Header and Footer elements to your FlexiLayout to indicate the beginning and end of the documents. If neither the Header nor the Footer element is found when matching the FlexiLayout, the program will use the maximum number of pages specified in the FlexiLayout as the number of pages in the document. For this particular document we specified 1 as the maximum number of pages.


Sample 3. Step 2: Visual analysis of the images and pre-recognition results

Prior to creating elements, we must decide which objects on the form can serve to detect the data fields. These objects can be selected only from such graphical and/or text fragments of the image that are reliably detected during the pre-recognition process.

Start pre-recognition by clicking Pre-Recognize (see Tutorial 1, Step 4 for details).

Reviewing the pre-recognition results reveals that all the text objects corresponding to the names of the data fields (if a field has a name), names of columns, and horizontal separators have been reliably detected. So they may be used to search for other objects on the images.

Note: For more information on reviewing images and pre-recognition results, see Tutorial 1, Step 5 and Step 6.

Now we can start to create blocks and elements. To do this, activate the FlexiLayout window in the main window of ABBYY FlexiLayout Studio.


Sample 3. Step 3: Blocks

The main goal of the FlexiLayout creation is a reliable detection of the following blocks (provided they occur on an image):

  • Invoice Number
  • Invoice Date
  • Delivery Address
  • Total Quantity
  • Total Amount
  • Country
  • Invoice Table (only the following columns: Reference, Designation, Quantity, Unit Price, Total)

Let us start to create these blocks in order to have their list during FlexiLayout creation.

  1. Create a block InvoiceNumber of type Text, which will correspond to the field Invoice Number.

  2. Create a block InvoiceDate of type Text, which will correspond to the field Invoice Date.

  3. Create a block DeliveryAddress of type Text, which will correspond to the field Delivery Address.

  4. Create a block TotalQuantity of type Text, which will correspond to the field Total Quantity.

  5. Create a block TotalAmount of type Text, which will correspond to the field Total Amount.

  6. Create a block Country of type Text, which will correspond to the field Country.

  7. Create a block InvoiceTable of type Table, which will correspond to the field Invoice Table. In the Properties dialog box of the block, click the Columns tab, enter the names of the columns and specify their order, which will later be used in a FlexiCapture template. Add the column names in the following order: Reference, Designation, Quantity, UnitPrice, and Total. (For more information, see Table Block.)
Show me...

Note: At this stage we only specify the type of a block and its name (and the order of columns for the Table block). We will specify the location of each block later, when all auxiliary elements have been described and debugged. It is very important that the block of type Table be created before the element of type Table which is used to look for the block, as the Table element must keep a reference to the Table block. This requirement makes Table blocks different from blocks of types Text, Barcode, Checkmark, and Picture, which can be created after modifying a FlexiLayout, when all the elements for different blocks have been created (for instance see Tutorial 1 , Tutorial 2).

Now that the preparatory settings have been made, we can start to create elements.


Sample 3. Step 4: Analyzing the images to decide in which order elements must be detected

At this step, we are to decide:

  • Is there any pattern in the arrangement of the fields on the images?

  • Which elements can be used as reference elements for fields’ detection?

  • What sequence of search for elements is the best choice? (At each new step we can only refer to the above described elements.)

Let us analyze the available images.

  1. You will have noticed that the central part of the document contains a table which occurs on all the images.

    Note: Please note that in FlexiLayout Studio 9.0, a table is an image object made up of fragments that consist of rows and columns visually separated by separator lines or by white gaps. (See Table for more details.)

  2. Above the table there is a group of fields (which may be named the InvoiceHeader): Invoice Number, Invoice Date, and Delivery Address. Note that the field Invoice Number occurs on all the images and can be used as a identifier field, while the fields Invoice Date and Delivery Address are optional.
  3. Below the table there is a group of fields (which may be named the Footer): TotalQuantity, TotalAmount and Country. These fields also do not occur on all the images.

We will start to create our search for elements in the upper part of the document. To detect the upper fields, we will create a logical group uniting all the elements which are used to look for the fields Invoice Number, Invoice Date, and Delivery Address.

  1. Create an element of type Group and name it InvoiceHeader.
    The fields Invoice Number, Invoice Date, and Delivery Address are always located in the upper left corner. Moreover, their order is always the same: Delivery Address followed by Invoice Number followed by Invoice Date (provided they occur on the image). We will look for them in the same order.

  2. To describe search of the keywords for the names of the fields Invoice Number, Invoice Date, and Delivery Address, we will use elements of type Static Text. The InvoiceHeader element must contain the following elements:

    • kwDeliveryAddress element of the Static Text, which will correspond to the name of the field Delivery Address (for detailed instructions, see Step 5);

    • kwInvoiceNumber element of the Static Text, which will correspond to the name of the field Invoice Number (for detailed instructions, see Step 6);

    • kwDate element of the Static Text, which will correspond to the name of the field Invoice Date (for detailed instructions, see Step 7).

  3. As for the fields Number and Invoice Date, we are going to search for them in the same row as their corresponding names, to the right of the names.

    In the InvoiceHeader element, create the following elements:

    • InvoiceNumber element of type Character String, which will correspond to the field Invoice Number (for detailed instructions, see Step 8);

    • a Group element grDate of type Static Text to look for the field Invoice Date (for detailed instructions, see Step 9).

    In the InvoiceHeader.grDate element, create:

    • InvoiceDate element of the Date type, which will correspond to the Invoice Date field in the case of good quality images (for detailed instructions, see Step 9);

    • InvoiceDateAsString element of type Character String, which will correspond to the Invoice Date field if the program fails to find the InvoiceDate element (for detailed instructions, see Step 9).

    Note: For more information on finding dates on poor quality images, see the Tips and Tricks section.

  4. The field Delivery Address has multiple lines, so we need an element of the Text Fragment type to detect it. However, prior to creating this element, we should limit the search area as much as possible. For the right boundary of the search area, we will use element of the White Gap type. Afterwards, we will group all the elements which describe the location of the field Delivery Address into a Group element:

    • In the element InvoiceHeader, create a Group element and name it grAddress (for detailed instructions, see Step 10).

    In the grAddress element, create the following elements:

    • an auxiliary element wgAddressRight of the White Gap type, bordering on the right the field Delivery Address (for detailed instructions, see Step 11);

    • an element DeliveryAddress of the Text Fragment type, which will correspond to the field Delivery Address (for detailed instructions, see Step 12).


Sample 3. Step 5: Detecting the name of the Delivery Address field with a kwDeliveryAddress element

Analysis of the test images reveals that the string "DeliveryAddress" may be used as the keywords for the Delivery Address field name. Set the maximum percentage of errors to 20 per cent, i.e. in case of 15 letters string mean no more than 3 errors in the entire string.

Note: The case of the letters does not affect the search and is only used to make the text more readable. The maximum number of errors is determined by method of trial and error. For more information about the parameters of a Static Text element, see Help/Elements/Element Properties/Static Text.

To create the kwDeliveryAddress element:

  1. In the InvoiceHeader element, create an element of type Static Text and name it kwDeliveryAddress.

  2. Click the Static Text tab.

  3. In the Search text field, enter the text to find: "DeliveryAddress".

  4. Set the Max error percentage to 20.

  5. Click the Advanced tab.

  6. Since the Delivery Address field is in the upper third and in the left third of the image, set the following additional search constraint in the Advanced pre-search relations field: Look for the object in the left third of the image. Look for the object in the upper third of the image. In the FlexiLayout language:

    Above: PageRect.Top + PageRect.Height/3;
    LeftOf: PageRect.Left + PageRect.Width/3;

  7. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.

Note: To match the FlexiLayout with all the test images, you can use the shortcut keys:

  • Activate the Batch window

  • Press Ctrl + A for Select All pages

  • Press Ctrl + Shift + E for Match FlexiLayout


Sample 3. Step 6: Detecting the name of the Invoice Number field with a the kwInvoiceNumber element

Analysis of the images reveals that the name of the field Invoice Number occurs on all the images and distinguishes them from other document types. When processing semi-structured forms in ABBYY FlexiCapture, you will want to avoid accidental recognition of forms which do not belong to the selected type. One way to identify a form is to create at least one required element. So we will mark this element as required, i.e. use it as an identifier for this type of form.

Note that on some of the images this name is written as Invoice No., while on others it is written as Credit note no. Our search string must include both these variants, and we will specify each of the strings without spaces. In this case the maximum number of errors will apply to the entire phrase, not to separate words.

To create the kwInvoiceNumber element:

  1. In the InvoiceHeader element, create an element of type Static Text and name it kwInvoiceNumber.

  2. Clear the Optional element check box on the General tab (we have decided to make this element a required element).

  3. Click the Static Text tab.

  4. In the Search text field, enter the text to find: “InvoiceNo.|CreditNoteNo”.

  5. Set Max error percentage to 20.

  6. Click the Relations tab.

  7. On the Relations tab, specify that the keywords of the name of the Invoice Number field can only occur below the name of the field Delivery Address:

Below the element InvoiceHeader.kwDeliveryAddress, Offset = 0.

Show me...

  8. Click the Advanced tab.

  9. Since the Delivery Address field is in the upper third and in the left third of the image, set the following additional search constraint in the Advanced pre-search relations field: Look for the object in the left third of the image; Look for the object in the upper third of the image. In the FlexiLayout language:

    Above: PageRect.Top + PageRect.Height/3;
    LeftOf: PageRect.Left + PageRect.Width/3;

  10. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images.

Note: In practice, if the wording of a field name differs from image to image, you must be sure to specify all the possible variants of the name, or at least the majority of them. You may want to ask for more test images or contact your customer to learn about the possible variants of the name on the forms of this type.


Sample 3. Step 7: Detecting the name of the Invoice Date field with a kwInvoiceDate element

Analysis of the test images reveals that the name of the field Invoice Date is a short and very common word “Date.” This means that we have to restrict the search area as much as possible. You will have noticed that the name of the Date field (whenever it occurs on an image) is located very close to the name of the field Invoice Number.

To create the kwInvoiceDate element:

  1. In the InvoiceHeader element, create an element of type Static Text and name it kwInvoiceDate.

  2. Click the Static Text tab.

  3. In the Search text field, enter the text to find: “Date”.

  4. Leave 30 as the value for the Max error percentage (for the sought word of 4 letters it means no more than 1 error).

  5. Click the Relations tab.

  6. On the Relations tab, specify that the keywords of the name can only occur below the name of the field Invoice Number, but no more than 150 dots below its bottom boundary.

  • Below the element kwInvoiceNumber, Offset = 0, and

  • Above the bottom of the element kwInvoiceNumber, Offset = -150, Element boundary = Bottom.

Show me...

Note: To select the best values for offsets, you may want to analyze the geometrical properties (i.e. size and boundaries) of the objects detected during pre-recognition.

  7. Click the Advanced tab.

  8. Since the Invoice Date field is in the left half of the image, set the following additional search constraint in the Advanced pre-search relations field: Look for the object in the left half of the image. In the FlexiLayout language:

LeftOf: PageRect.Left + PageRect.Width/2;

  9. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.


Sample 3. Step 8: Describing the Invoice Number field with an InvoiceNumber element

The field Invoice Number is to the right of the name and is located on the same horizontal level. Analysis of the test images reveals that on some of the images the number has been poorly recognized. So we will not restrict the alphabet, but we will restrict the search area and restrict the length of the string to 3-20 characters.

To create the InvoiceNumber element:

  1. In the InvoiceHeader element, create an element of type Character String and name it InvoiceNumber.

    Note: The element and the block which corresponds to the field InvoiceNumber need not have identical names, but this is handy when working with the FlexiLayout.

  2. Click the Character String tab.

  3. Set the Percentage of non-alphabet characters to 100%, which means that there is no restriction for characters.

  4. In the Character count field, specify this fuzzy interval: [-1, 3, 20, 2147483647], which restricts the number of characters in the string. We assume that the possible values range from 3 to 20. Any hypotheses outside this range will be penalized.

  5. Click the Relations tab.

  6. Since InvoiceNumber can only occur to the right of the keywords of the name kwInvoiceNumber, but no farther than 550 dots from the right boundary of the name kwInvoiceNumber, set the following search constraints:

    • Right of the element kwInvoiceNumber, Offset = 0

    • Left of the element kwInvoiceNumber, Offset = -550, Element boundary = Right

    Note: Offset values are selected by method of trial and error.

  7. Since InvoiceNumber is always located on the same level with the keyword of the name kwInvoiceNumber, set the following search constraints:
    • Above the element kwInvoiceNumber, Offset = -10, Element boundary = Bottom
    • Below the element kwInvoiceNumber, Offset = -10, Element boundary = Top
Show me...

  8. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.

  9. To describe the location of the InvoiceNumber block, click its Properties and select the Source element option, then click "…" and select the InvoiceNumber element as the source element.


Sample 3. Step 9: Describing the Invoice Date field with grDate, InvoiceDate, and InvoiceDateAsString elements

Analysis of the test images reveals that the Invoice Date field is located to the right of its name and on the same horizontal level as the name. We will use a Date element to look for the date. In case there are poor quality images where dates may not be recognized properly so that the search for the Date gives no results, create an additional element of type Character String. To specify the properties common to all these elements, we need to create a compound grDate element.

To create the grDate element:

  1. In the InvoiceHeader element, create an element of type Group and name it grDate.

  2. Click the Relations tab.

  3. Since all the elements used to detect the Invoice Date field may only occur to the right of the keywords of the kwInvoiceDate name and on the same level as the name, set the following search constraints:

  • Right of the element kwInvoiceDate, Offset = 0.

  • Above the element kwInvoiceDate, Offset = -10, Element boundary = Bottom.

  • Below the element kwInvoiceDate, Offset = -10, Element boundary = Top.

Show me...

To create the InvoiceDate element:

  1. In the InvoiceHeader.grDate element, create an element of type Date and name it InvoiceDate.

  2. Click the Date tab.

  3. On the Date tab, specify all the possible date formats which may occur on the images. We assume that the date format is Day, month, year, the language is English, and there are no other constraints on the date.
Show me...

  4. Click the Advanced tab.

  5. Since the Invoice Date field is optional on this form but whenever it occurs, it occurs with its name and is always located next to the name, set the following additional search constraint in the Advanced pre-search relations field: Look for the object on the image only if the kwInvoiceDate element has been detected; Look for the image object closest to the kwInvoiceDate element. In the FlexiLayout language:

    If InvoiceHeader.kwInvoiceDate.IsNull Then DontFind;
    Nearest: InvoiceHeader.kwInvoiceDate;

    Note: The Nearest constraint can also be specified via the program’s graphical user interface. Click the Relations tab, select Nearest, and in the To: drop-down list select Element and specify kwInvoiceDate as the Reference element.

  6. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where there is an Invoice Date field.

Test and see that on some of the images the element has not been detected. Analysis of the pre-recognition results reveals that this has happened because of the noise in the area of the field. None of the standard properties of the Date element can be used to remedy the situation, so we have to create an alternative element with less stringent search constraints.

Note: For more information on finding dates on poor quality images, see the Tips and Tricks section of the Help file.

To create the InvoiceDateAsString element:

  1. In the InvoiceHeader.grDate element, create an element of type Character String and name it InvoiceDateAsString.

  2. Click the Character String tab.

  3. In the Character count field, specify this fuzzy interval: {-1, 8, 14, 2147483647}, which is an estimate of the string length. We assume that the string may be 8 to 14 characters long. Any hypothesis outside this range will be penalized.

  4. Set the Max space length to 20, which means that the space may be 20 dots long.

  5. For the other properties, leave the default values.

  6. Click the Advanced tab.

  7. Since we want the program to look for this element only if the InvocieDate element has not been detected, set the following additional search constraint in the Advanced pre-search relations field: Look for the object only if the InvocieDate element has not been detected. In the FlexiLayout language:

    If Not InvoiceDate.IsNull Then DontFind;

  8. Since the Invoice Date field is optional on this form but whenever it occurs, it is always present with its name and located next to the name, set the following additional search constraint in the Advanced pre-search relations field: Look for the object on the image only if the element kwInvoiceDate has been detected; Look for the image object closest to the kwInvoiceDate element. In the FlexiLayout language:

    If InvoiceHeader.kwInvoiceDate.IsNull Then DontFind;
    Nearest: InvoiceHeader.kwInvoiceDate;

    Note: The Nearest constraint can also be specified via the program’s graphical user interface. Click the Relations tab, select Nearest, and in the To: drop-down list select Element and specify kwInvoiceDate as the Reference element.

  9. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where there is an Invoice Date field and generates a null hypothesis for the InvoiceDate element.

  10. To describe the location of the InvoiceDate block, select the Source element option, then click “…” and select the InvoiceHeader.grDate element as the source element.

Note: The region of a Group element is calculated by uniting the regions of all the detected subelements.


Sample 3. Step 10: Creating a grAddress Group element

We have decided to look for the Delivery Address field by using the following two elements: a White Gap element on the right, and an element of the Text Fragment type. To specify the properties common to all these elements, we will create a Group element.

To create the grAddress element:

  1. In the InvoiceHeader element, create a Group element and name it grAddress.

  2. Click the Relations tab.

  3. Since all the elements used to search for the Delivery Address field can only occur below the keywords of the name kwDeliveryAddress and above the keywords of the name kwInvoiceNumber, set the following search constraints:
    • Below the element kwDeliveryAddress, Offset = 0.
    • Above the element kwInvoiceNumber, Offset = 0.
Show me...

  4. Click the Advanced tab.

  5. Since the Delivery Address field and the white gap bordering it are located in the left two fifths of the page, set the following additional search constraint in the Advanced pre-search relations field: Look for the objects in the left two fifths of the page. In the FlexiLayout language:

    LeftOf: PageRect.Left + PageRect.Width*2/5;


Sample 3. Step 11: Detecting the right border of the Delivery Address field with a wgAddressRight element

Sample 3. Step 11: Detecting the right boundary of the Delivery Address field with a wgAddressRight element

To specify the right boundary of the search area of the DeliveryAddress element, we need to describe the corresponding vertical white gap.

To create the wgAddressRight element:

  1. In the InvoiceHeader.grAddress element, create an element of type White Gap and name it wgAddressRight.

  2. Click the White Gap tab.

  3. In the Orientation group, choose Vertical. Set Min width to 100.

    Note: Prior to setting values for height or width of white gaps, you may want to analyze the geometrical properties (i.e. size and boundaries) of the neighboring objects detected during pre-recognition. Values for the noise threshold in the white gap area are selected by trial and error.

  4. Set Lower threshold limit: and Threshold coefficient (%): to 10.
    Note: The values of Lower threshold limit, Upper threshold limit, and Threshold coefficient (%) are selected by method of trial and error.
    For more information, see Help/Elements/Element Properties/White Gap.

  5. Leave the default values for the other parameters of the element.
    Show me...

  6. Click the Relations tab.

  7. Since the sought white gap can only be located to the right of the keywords of the name kwDeliveryAddress, set the following search constraint:
    - Right of the element kwDeliveryAddress, Offset = 0

  8. Click the Advanced tab.

  9. Since the Delivery Address field is optional on the images but whenever it occurs it has a name, set the following additional search constraint in the Advanced pre-search relations field: Look for the object only if the kwDeliveryAddress element has been detected. In the FlexiLayout language:

    0cm;text-indent:19.0pt">If InvoiceHeader.kwDeliveryAddress.IsNull Then DontFind;

  10. Since the sought white gap is adjacent to the Invoice Number field, set the following additional search constraint in the Advanced pre-search relations field: Look for the object on the image which is nearest to the kwInvoiceNumber element. In the FlexiLayout language:

    Nearest: InvoiceHeader.kwInvoiceNumber;

    Note: The Nearest constraint can also be specified via the program’s graphical user interface. Click the Relations tab, select Nearest, and in the To: drop-down list select Element and specify kwInvoiceNumber as the Reference element.

  11. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where the Delivery Address field occurs.


Sample 3. Step 12: Describing the Delivery Address field with a DeliveryAddress element

To create the DeliveryAddress element:

  1. In the InvoiceHeader.grAddress element, create an element of type Text Fragment and name it DeliveryAddress.

  2. Click the Relations tab.

  3. Since the DeliveryAddress field can only occur above the name kwInvoiceNumber, only to the left of the wgAddressRight white gap, and only to the right of the beginning of the name kwDeliveryAddress (with small offset), set the following search constraints:

    • Above the element wgAddressBottom, Offset = 0.

    • Left of the element wgAddressRight, Offset = 0.

    • Right of the element kwDeliveryAddress, Offset = -50, Element boundary = Left

    Note: Offset values are selected by method of trial and error.

  4. Since in the Group element InvoiceHeader.grAddress we have already specified that the DeliveryAddress field can only be located below the keywords of the name kwDeliveryAddress, we need not duplicate this constraint here.

  5. Click the Advanced tab.

  6. Since the Delivery Address field is optional on the images but whenever it occurs it has a name, set the following additional search constraint in the Advanced pre-search relations field: Look for the object only if the kwDeliveryAddress element has been detected. In the FlexiLayout language:

    If InvoiceHeader.kwDeliveryAddress.IsNull Then DontFind;

  7. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.

  8. To describe the location of the DeliveryAddress block, select the Source element option, then click "…" and select the DeliveryAddress element as the source element.


Sample 3. Step 13: Further analysis of the images

So far we have described the Invoice Number, Invoice Date, and DeliveryAddress fields.

Let us now decide in which order the other elements must be detected.

Analysis of the arrangement of the fields on the test images reveals that to detect the Country field, we can use the name of this field and an element of type Character String. But in order to detect the Total Quantity and Total Amount fields we will need to use not only the name, which is shared by the two fields, but also additional elements. The names of the corresponding columns of the table may be used for the purpose.

We also need to prepare the ground for the search of the Invoice Table field, which is to be detected by means of an element of type Table.

  1. We describe the Header of the table. There are two ways to detect column names.

    • The first one is to specify one or several keywords in the Column Properties dialog box (the Properties dialog box of the Table element > Columns tab). This method is quick but not very flexible.

    • The second way is to use a previously detected element as a reference element to find the location of the column name. This method allows you to take full advantage of the additional settings available for elements. Analysis of the pre-recognition results reveals that the recognition quality is good enough, so we can use the first method (the only snag would be the very short name of the Quantity column name — 20% of errors in a three-letter keyword “Qty” effectively means that no errors allowed). We will use the first method to detect the first two columns, Reference and Designation, and we can use the previously described elements to detect the names of the rest of the columns: Quantity, Unit Price, and Total (as far as we need to create these elements anyway to detect the TotalQuantity and TotalAmount fields).

  2. We describe the Footer of the table. It can also be described either by using keywords or by using an auxiliary element. Analysis of the keywords in the footer reveals that on some of the images the keywords also occur in the first row of the table, so we have to use an auxiliary element because of means to restrict the search area.

  3. We describe the table search area. After we have described the header and the footer, we need to describe the right boundary of the table (we do not need to describe the left boundary, as there are no other data in this part of the image). Since we cannot use the context to separate the figures in the Total column from the figures in the Sales column, we will need a different approach. We can use the name of the last column, Sales, to restrict the table search area on the right.

Note: Elements and the order in which they must be detected are selected by trial and error and can be changed during FlexiLayout adjustment.

Prior to describing the remaining fields, we will describe the auxiliary elements.

  1. Analysis of interdependencies among the elements reveals that first we have to detect the names of the Quantity, Unit Price, Total, and Sales columns.

  2. The header of the table begins with a horizontal separator between the column names and the Invoice Number, Invoice Date, and Delivery Address fields. This separator will help us to restrict the search areas of the column names.

    • For this purpose, create an element of type Separator and name it hsTableHeaderTop (for detailed instructions, see Step 14).
      We will look for the column names in their natural order.

    • Create an element of type Group and name it TableHeader (for detailed instructions, see Step 15).

    This element must include:

    • Element kwQuantity of type Static Text, which will correspond to the name of the Quantity column of the table InvoiceTable (for detailed instructions, see Step 16);

    • Element kwUnitPrice of type Static Text, which will correspond to the name of the Unit Price column of the table InvoiceTable (for detailed instructions, see Step 17);

    • Element kwTotal of type Static Text, which will correspond to the name of the Total column of the table InvoiceTable (for detailed instructions, see Step 18);

    • Element kwSales of type Static Text, which will correspond to the name of the Sales column of the table InvoiceTable (for detailed instructions, see Step 19).

  3. Let’s continue to describe the lower part of the form. The fields we are interested in are the name of the Total Quantity and the Total Amount fields (which serves as the bottom boundary of the table) and any other captions that can help locate the bottom boundary of the table. We will also describe the name element and the source element for the Country field in this logic group.

  4. Create a Group element and name it Footer.

    This element must include:

    • Element kwFooter of type Static Text, which will correspond to the footer of the Invoice Table (for detailed instructions, see Step 21);

    • Element kwTotal of type Static Text, which will correspond to the name of the Total Quantity and the Total Amount fields (for detailed instructions, see Step 22);

    • Element kwOrigin of type Static Text, which will correspond to the name of the Country field (for detailed instructions, see Step 23);

    • Element Country of type Character String, which will correspond to the Country field (for detailed instructions, see Step 24).

Now that all the preparations have been made and the order of creating additional elements has bee described, we can start looking for the remaining fields. Relying on the previously detected names of columns and Footer, we will describe the remaining Total Quantity, Total Amount, and Invoice Table fields.

  1. For this purpose, create two elements of typeCharacter String and name them TotalQuantity and TotalAmount. These elements will correspond to the Total Quantity and the Total Amount fields respectively (for detailed instructions, see Step 25).

  2. Create an element of type Table and name it InvoiceTable. This element describes the Invoice Table field (for detailed instructions, see Step 26).


Sample 3. Step 14: Detecting the auxiliary horizontal separator with an hsTableHeaderTop element

To create the hsTableHeaderTop element:

  1. Create an element of type Separator and name it hsTableHeaderTop.

  2. Click the Separator tab.

  3. In the Orientation group, click the Horizontal option.

  4. Set the Min length/Max length to 1500 / 2500.

  5. Click the Fits entirely within search area option.

  6. Set the Space, Max length to 20 and the Orthogonal shift to 20.

    Note: Prior to setting the values for the length of the separator, you may want to analyze the geometrical properties (i.e. size and boundaries) of the neighboring objects detected during pre-recognition. Separator error thresholds are selected by method of trial and error.

  7. Leave the default values for the other parameters of the element.
Show me...

  8. Click the Relations tab.

  9. Since the separator can only occur below the keywords of the names kwInvoiceDate and kwInvoiceNumber, set the following search constraint:

    • Below the element InvoiceHeader.kwInvoiceDate, Offset = 0;

    • Below the element InvoiceHeader.kwInvoiceNumber, Offset = 0;

  10. Click the Advanced tab.

  11. Since the sought separator is located at the top of the described search area, set the following additional search constraint in the Advanced pre-search relations field: Look for an object on the image nearest to its top boundary. In the FlexiLayout language:

    NearestY: PageRect.Top;

    Note: The Nearest constraint can also be specified via the program’s graphical user interface. Click the Relations tab, select Nearest, and in the To: drop-down list select Page top edge.

  12. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images.


Sample 3. Step 15: Analyzing the search constraints for column names with a TableHeader element of type Group

Analysis of the test images reveals that the column names are located directly below the previously detected horizontal separator. To specify the search constraints common to all the column names, we need to create a Group element — TableHeader.

To create the TableHeader element:

  1. Create a Group element and name it TableHeader.

  2. Click the Advanced tab.

  3. You will have noticed that if the hsTableHeaderTop separator has been detected on an image, the column names are located below the separator, but no lower than 100 dots from it. Otherwise, they are located in the top three fifths of the page. So set the following additional search constraint in the Advanced pre-search relations field: If the hsTableHeaderTop element has been detected, look for the objects of the image below the separator but no lower than 100 dots from it. Otherwise, look for the objects of the image in the top three fifths of the page. In the FlexiLayout language:

    If Not (hsTableHeaderTop.IsNull) Then
    {
    Below: hsTableHeaderTop, 0 * dot;
    Above: hsTableHeaderTop.Bottom, -100 * dot;
    } Else
    {
    Above: PageRect.Top + PageRect.Height*3/5;
    }


Sample 3. Step 16: Detecting the name of the Quantity column with a kwQuantity element

Analysis of the pre-recognition results reveals that even though the name is a very short keyword “Qty,” we can detect the name by using an element of type Static Text. Set the maximum error percentage to 35; this allows one wrong character in a three-letter word.

To create the kwQuantity element:

  1. In the TableHeader element, create an element of type Static Text and name it kwQuantity.

  2. Click the Static Text tab.

  3. In the Search text field, enter the text to find: “Qty”.

  4. Set the Max error percentage to 35.

  5. Click the Advanced tab.

  6. Since the name of the Quantity column is located to the right of the leftmost third of the image, set the following additional search constraint in the Advanced pre-search relations field: Look for the object to the right of the leftmost third of the page. In the FlexiLayout language:

    RightOf: PageRect.Left + PageRect.Width/3;

  7. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images.


Sample 3. Step 17: Detecting the name of the Unit Price column with a kwUnitPrice element

To describe the element which will be used to detect the keywords in the Unit Price column name, we will take advantage of the fact that the Unit Price column is always located to the right of the Quantity column.

To create the kwUnitPrice element:

  1. In the TableHeader element, create an element of type Static Text and name it kwUnitPrice.

  2. Click the Static Text tab.

  3. In the Search text field, enter the text to find: “UnitPrice”.

  4. Click the Advanced tab.

  5. Since the name of the Unit Price column is located to the right of the name of the Quantity column, set the following additional search constraint in the Advanced pre-search relations field: If the kwQuantity element has been detected, look for the kwUnitPrice element to the right of it. In the FlexiLayout language:

    If Not (TableHeader.kwQuantity.IsNull) Then
    RightOf: TableHeader.kwQuantity, 0 * dot;

  6. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images.


Sample 3. Step 18: Detecting the name of the Total column with a kwTotal element

To describe the element which will be used to look for the keywords in the name of the Total column, we will take advantage of the fact that the Total column is always located to the right of the Unit Price column.

To create the kwTotal element:

  1. In the TableHeader element, create an element of type Static Text and name it kwTotal.

  2. Click the Static Text tab.

  3. In the Search text field, enter the text to find: “TotalChf”.

  4. Click the Advanced tab.

  5. Since the name of the Total column is located to the right of the name of the Unit Price column (if the latter occurs on the form), set the following additional search constraint in the Advanced pre-search relations field: If the kwUnitPrice element has been detected, look for the kwTotal element to the right of it. In the FlexiLayout language:

    If Not (TableHeader.kwUnitPrice.IsNull) Then
    RightOf: TableHeader.kwUnitPrice, 0 * dot;

  6. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images.


Sample 3. Step 19: Creating a InvertedHeader element

Though we do not need the data from the Sales column, we have to detect its name in order to restrict the search area for the right boundary of the table.

To create the kwSales element:

  1. In the TableHeader element, create an element of type Static Text and name it kwSales.

  2. Click the Static Text tab.

  3. In the Search text field, specify the value for the sought text: “Sales”.

  4. Click the Advanced tab.

  5. Since the name of the Sales column is located to the right of the name of the Total column (if the latter occurs on the form), set the following additional search constraint in the Advanced pre-search relations field: If the kwTotal element has been detected, look for the kwSales element to the right of it. In the FlexiLayout language:

    If Not (TableHeader.kwTotal.IsNull) Then
    RightOf: TableHeader.kwTotal, 0 * dot;

  6. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images.


Sample 3. Step 20: Describing the Footer group with a Footer element of type Group

Analysis of the test images reveals that the footer of the table, the Country, Total Quantity, and Total Amount fields and their names are located in the lower part of the image, under the table header. To keep the first row of the table, where the keywords for the footer may also occur, out of the search area, we will lower the top boundary of the search area. To specify some common search constraints, we need to create a Group element.

To create the Footer element:

  1. Create a Group element and name it Footer.

  2. Click the Relations tab.

  3. Since the footer of the Invoice Table and the Country, Total Quantity, and Total Amount fields can only be located below the separator hsTableHeaderTop with some offset, set the following search constraint:

    Below the element hsTableHeaderTop, Offset = 300.


Sample 3. Step 21: Describing the footer of the table with a kwFooter element

Analysis of the test images reveals that the footer of the table can begin with the keywords ”Carried Over,” “Total Chf,” ”Goods total excl. tax,” ”Discount,” and ”SPECIAL DISCOUNT.” Let us list all these variants in a search text for the element of type Static Text.

To create the kwFooter element:

  1. In the Footer element, create an element of type Static Text and name it kwFooter.

  2. Click the Static Text tab.

  3. In the Search text field, enter the text to find: “Discount|TotalCHF|SPECIALDISCOUNT|Carriedover|Goodstotalexcl.tax”.

  4. Click the Advanced tab.

  5. The sought keywords are located in the left half of the image. If the program detects several of the keywords, we will only be interested in the topmost keyword. So set the following additional search constraint in the Advanced pre-search relations field: Look for the object in the left half of the page; Look for the object nearest to the top edge of the page. In the FlexiLayout language:

    LeftOf: PageRect.Left + PageRect.Width/2;
    NearestY: PageRect.Top;

  6. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.

Note: If the wording of a field name may differ from image to image, be sure to list all the possible variants of the name, or at least the majority of them. You may want to ask for more test images or contact your customer to learn about the possible variants of field names on the forms of this type.


Sample 3. Step 22: Describing the name of the Total fields with a kwTotal element

You will have noticed that the name of the Total Quantity and Total Amount fields may be represented by the keywords ”TotalChf” or ”Carried Over” and is located in the lower left part of the page.

To create the kwTotal element:

  1. In the Footer element, create an element of type Static Text and name it kwTotal.

  2. Click the Static Text tab.

  3. In the Search text field, specify the values for the sought text: “TotalChf|CarriedOver”.

  4. Set Max error percentage to 20.

  5. Click the Advanced tab.

  6. Since the name is located in the left half of the page and the sought string is nearest to the top edge of the page, set the following additional search constraint in the Advanced pre-search relations field: Look for the object in the left half of the page; Look for the object nearest to the top edge of the page. In the FlexiLayout language:

    LeftOf: PageRect.Left + PageRect.Width/2;
    NearestY: PageRect.Top;

  7. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.


Sample 3. Step 23: Detecting the name of the Country field with a kwOrigin element

We will use an element of type Static Text and the keyword “OriginOfGoods:” to detect the name of the Country field.

To create the kwOrigin element:

  1. In the Footer element, create an element of type Static Text and name it kwOrigin.

  2. Click the Static Text tab.

  3. In the Search text field, enter the text to find: “OriginOfGoods:”.

  4. Click the Relations tab.

  5. Since the Country field can only be located below the footer of the table, set the following search constraint:

    Below the element Footer.kwFooter, Offset = 0.

  6. Click the Advanced tab.

  7. Since the Country field is located in the left half of the image, set the following additional search constraint in the Advanced pre-search relations: Look for the object in the left half of the page. In the FlexiLayout language

    LeftOf: PageRect.Left + PageRect.Width/2;

  8. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.


Sample 3. Step 24: Describing the Country field with a Country element

We will use an element of type Character String to detect the Country field. The element must be located on the same horizontal level with the name of this field and will be used only if the name has been detected.

To create the Country element:

  1. In the Footer element, create an element of type Character String and name it Country.

  2. Click the Character String tab.

  3. Select all Latin characters as the alphabet and set the Percentage of non-alphabet characters to 20.

  4. In the Character count field, specify this fuzzy interval: [-1, 2, 25, 2147483647]. This is an estimation of the length of the character string. We assume that the possible values may range from 2 to 25. Any hypotheses outside this range will be penalized.
Show me...

  5. Leave the default values for the other parameters of the element.

  6. Click the Relations tab.

  7. Since the Country field can only be located to the right of the keywords of the name kwOrigin but no farther than 500 dots from its right boundary, set the following search constraints:

    • Right of the element kwOrigin, Offset = 10.

    • Left of the element kwOrigin, Offset = -500, Element boundary = Right.

  8. Since the Country element is always located on the same level with the keywords of the name kwOrigin, set the following search constraints:

    • Above the element kwOrigin, Offset = -10, Element boundary = Bottom.

    • Below the element kwOrigin, Offset = -10, Element boundary = Top.

    Note: Prior to setting the values for the offsets, you may want to analyze the geometrical properties (i.e. size and boundaries) of the neighboring objects detected during pre-recognition. Offset values are selected by trial and error.

  9. Click the Advanced tab.

  10. The Country field is optional on this form but whenever it occurs, it is always located next to its name. So set the following additional search constraint constraint in the Advanced pre-search relations field: Look for the object on the image only if the kwOrigin element has been detected. In the FlexiLayout language:

    If Footer.kwOrigin.IsNull Then DontFind;

  11. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.

  12. To describe the location of the Country block, select the Source element option, then click "…" and select the Country element as the source element.


Sample 3. Step 25: Detecting the TotalQuantity and TotalAmount fields with a TotalQuantity and TotalAmount elements

Sample 3. Step 25: Detecting the TotalQuantity and TotalAmount fields with TotalQuantity and TotalAmount elements

Analysis of the test images reveals that the Total Quantity and Total Amount fields only occur together with the name Footer.kwTotal and are located on the same level. We will use elements of type Character String to detect the Total Quantity and the Total Amount fields. To specify the search constraints common to these elements, we need to create a Group element — grTotal.

To create the Group element grTotal:

  1. In the Footer element, create a Group element and name it grTotal.

  2. Select the Optional element checkbox because we decided to stop the search of the subelements in case of name absence.

    Note: For some details see Help article Tips and tricks\The "Optional" property of a Group element.

  3. Click the Advanced tab.

  4. Since the Total Quantity and the Total Amount fields only occur on the image together with the name Footer.kwTotal, set the following additional search constraint in the Advanced pre-search relations field: If the Footer.kwTotal element has not been detected, do not look for the object on the image. In the FlexiLayout language:

    If Footer.kwTotal.IsNull Then DontFind;

The Total Quantity field is located at the intersection of the Total row and the Quantity column. The first constraint was already specified at the Group element level. To specify the second constraint, we will use the previously detected column name as a reference element.

To create the TotalQuantity element:

  1. In the grTotal element, create an element of type Character String and name it TotalQuantity.

  2. Click the Character String tab.

  3. In the Character count field, specify this fuzzy interval: [-1, 1, 10, 2147483647]. This is an estimation of the length of the character string. We assume that the possible values may range from 1 to 10. Any hypotheses outside this range will be penalized.

  4. Leave the default values for the other parameters of the element.

  5. Click the Relations tab.

  6. Since the Total Quantity field is always located on the same level with the keywords of the name Footer.kwTotal or slightly lower, set the following search constraints:

    • Above the element Footer.kwTotal, Offset = -200, Element boundary = Bottom

    • Below the element Footer.kwTotal, Offset = -20, Element boundary = Top

    Note: Prior to setting the values for the offsets, you may want to analyze the geometrical properties (i.e. size and boundaries) of the neighboring objects detected during pre-recognition. Offset values are selected by trial and error.

  7. Click the Advanced tab.

  8. Since the Total Quantity field is optional on the images but whenever it occurs it occurs together with the Quantity column and below its name, set the following additional search constraint in the Advanced pre-search relations field: Look for the object on the image only if the TableHeader.kwQuantity element has been detected; Look no farther than 50 dots to the left or to the right of the respective boundaries of the column name. In the FlexiLayout language:

    If Not (TableHeader.kwQuantity.IsNull) Then
    {
    LeftOf: TableHeader.kwQuantity.Right, -50 * dot;
    RightOf: TableHeader.kwQuantity.Left, -50 * dot;
    }
    Else DontFind;

  9. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.

  10. To describe the location of the TotalQuantity block, select the Source element option, then click "…" and select the TotalQuantity element as the source element.

The Total Amount field is located at the intersection of the Total row (the footer of the table) and the Total column. The first constraint was already specified at the Group element level. To specify the second constraint, we will use the previously detected column names as reference elements.

To create the TotalAmount element:

  1. In the grTotal element, crate an element of type Character String and name it TotalAmount.

  2. Click the Character String tab.

  3. In the Character count field, specify this fuzzy interval: [-1, 1, 20, 2147483647]. This is an estimation of the length of the character string. We assume that the possible values may range from 1 to 20. Any hypotheses outside this range will be penalized.

  4. Leave the default values for the other parameters of the element.

  5. Click the Relations tab.

  6. Since the Total Amount field is always located on the same level with the keywords of the name Footer.kwTotal, set the following search constraints:

    • Above the element Footer.kwTotal, Offset = -20, Element boundary = Bottom.

    • Below the element Footer.kwTotal, Offset = -20, Element boundary = Top.

  7. Click the Advanced tab.

  8. Since the Total Amount field can only be located immediately below (may be with a small shift) the name of the Total column and only between the Unit Price and Sales columns, set the following additional search constraint in the Advanced pre-search relations field: If the TableHeader.kwTotal element has been detected, look for the object no farther than 70 dots to the right of the right boundary of the TableHeader.kwTotal element and no farther than 50 dots to the left from the left boundary of the TableHeader.kwTotal element; or, if the TableHeader.kwUnitPrice and TableHeader.kwSales elements are detected, look for the object no farther than 40 dots to the right of the left boundary of the TableHeader.kwSales element and to the right of the right boundary of the TableHeader.kwUnitPrice element; otherwise do not look for the object. In the FlexiLayout language:

    If Not (TableHeader.kwTotal.IsNull) Then
    {
    LeftOf: TableHeader.kwTotal.Right, -70 * dot;
    RightOf: TableHeader.kwTotal.Left, -50 * dot;
    }
    Else
    If Not (TableHeader.kwUnitPrice.IsNull) and Not (TableHeader.kwSales.IsNull) Then
    {
    LeftOf: TableHeader.kwSales.Left, -40 * dot;
    RightOf: TableHeader.kwUnitPrice, 0 * dot;
    }
    Else DontFind;

    Note: Prior to setting the values for the offsets, you may want to analyze the geometrical properties (i.e. size and boundaries) of the neighboring objects detected during pre-recognition. Offset values are selected by trial and error.

  9. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.

  10. To describe the location of the TotalAmount block, select the Source element option, then click "…" and select the TotalAmount element as the source element.


Sample 3. Step 26: Detecting the Table element with an InvoiceTable element

Now that all the preparations are completed, we can search for the Invoice Table field. First, we describe an element of type Table:

  1. We describe the Header of the table. We decided (for detailed instructions, see Step 13) to describe the names of the Reference and the Designation columns by keywords (Table element > Properties dialog box > Columns tab > dialog box of column Properties), while the names of the Quantity, Unit Price, and Total columns will be detected with the help of the previously described auxiliary elements.

  2. We describe the Footer of the table. To describe the footer, we decided to use the previously described element which uses keywords and phrases to detect the beginning of the footer (for detailed instructions, see Step 13).

  3. We describe the search area of the table. We will use the Sales column name to restrict the search area on the right.

To create the InvoiceTable element:

  1. Create an element of type Table and name it InvoiceTable.

  2. Click the Columns tab.

  3. Click "…" and specify the previously described InvoiceTable block as the block to be detected by the InvoiceTable element (for detailed instructions, see Step 2).

  4. Select the Reference column and click Properties…. We will use the keyword Reference to look for this column name, so leave the default values.

  5. Select the Designation column and click Properties…. We will use the keyword Designation to look for this column name, so leave the default values.

  6. Select the Quantity column and click Properties…. We will use the previously detected element TableHeader.kwQuantity to find this column name. Select Use found element as column name option and click "…" to select the TableHeader.kwQuantity element.
    Show me...

  7. Select the UnitPrice column and click Properties…. We will use the previously detected element TableHeader.kwUnitPrice to find this column name. Select Use found element as column name option and click "…" to select the TableHeader.kwUnitPrice element.

    Show me...

  8. Select the Total column and click Properties…. We will use the previously detected element TableHeader.kwTotal to find this column name. Select Use found element as column name option and click "…" to select the TableHeader.kwTotal element.

  9. Click the Order tab.

  10. There can be other columns between the sought ones (for instance, Unit), but the sought columns are always located in the following order: Reference, Designation, Quantity, Unit Price, Total. Select the Rules for column order option, then click “Add…” and specify the following column order: Reference << Designation << Quantity << Unit Price << Total.

    Show me...

    Show me...

  11. Click the Header tab. We need the header but we are not going to add any search constraints, so leave the default values
    Show me...

  12. Click the Footer tab. We will use the previously detected element Footer.kwFooter to detect the footer. Select Use found element as footer option and click “…” to select the Footer.kwFooter element.

    Show me...

  13. Click the Rows tab.

  14. Since some columns in the table may have entries consisting of multiple lines, we have to specify master column to detect the rows. Select the Use master columns to detect rows option. Specify the Total column as the primary master column, as this column always contains data and a single row of the table corresponds to each entry. In case this column is not detected on a form, specify the Quantity and Unit Price columns as secondary and tertiary master columns respectively. Click "…" and specify this order of master columns.
    Show me...

  15. Click the Relations tab. Since the sought columns are located to the left of the beginning of the name of the Sales column (with a small gap), set the following search constraint:

    Left of the element TableHeader.kwSales,

    Offset = -40, Element boundary = Left.

    Note: When selecting values for offsets, you may want to analyze the geometrical properties (i.e. size and boundaries) of the reference and the sought objects detected during pre-recognition. Otherwise these values are selected by method of trial and error.

  16. Match the FlexiLayout with the test images. You see that the program has successfully detected the table element on all the images where it occurs. But on some of the images, the Quantity column also includes unwanted artifacts from the previous column. To separate the useful data from noise, let’s specify the type of content which may occur in the column.

  17. Open the Properties dialog box of the InvoiceTable element. Click the Columns tab, open the Properties dialog box for the Quantity column and select the Check content type option. Select Number in the Type of column content drop-down list.

    Show me...

  18. Try matching the FlexiLayout with the test images and make sure that the Quantity column does not contain any unwanted data.

  19. To describe the location of the InvoiceTable block, select the Source element option, then click "…" and specify the InvoiceTable element as the source element.


Sample 3. Step 27: Exporting the FlexiLayout into ABBYY FlexiCapture

The resulting FlexiLayout can be saved as an *.afl file and exported into ABBYY FlexiCapture.

For more about exporting FlexiLayouts see Sample 1, Step 21 and Step 22.


Multi-Page Invoice

Important! A multi-page document is used in this sample.

The sample document described in this section is a typical multi-page invoice. Unlike the sample documents described in the earlier sections, it has more than one page and contains a table that stretches over several pages.

Note: ABBYY FlexiLayout Studio 9.0 allows you to create FlexiLayouts for multi-page documents. Multi-page documents are treated as whole units and search for elements is not limited to individual pages. For details, see Multi-Page FlexiLayout.

The Invoice sample document will be used to illustrate some non-standard approaches to locating elements. You will learn how to detect image objects that correspond to the beginning and the end of a multi-page document and how to detect multi-page elements (in this case, a multi-page table). For details, see Header and Footer.

A FlexiLayout for the Invoice sample document should reliably detect the following fields on all the test images:

  • Invoice Number
  • Invoice Date
  • Delivery Address
  • Total Amount
  • Invoice Table (Reference, Designation, Unit, Quantity, Unit Price, and Total columns)
  • Company


Sample 4. Step 1: Preparatory settings

  1. Run ABBYY FlexiLayout Studio 9.0.
  2. Create a new project (File>New Project>FlexiLayout Project…).
  3. Type this name for your project: Invoices.
  4. Add the images to the batch (see. Sample 1. Step 2 for detailed instructions).
    Note: The test images for Sample 4 can be found in
    <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Invoice\InvoicesBatch.
  5. For each document in the batch, you can create a reference assembly which shows how the pages should be separated into documents. A reference assembly can be created either manually or automatically, when adding the images to the batch. A reference assembly allows you to compare the actually assembled documents with the correct "ideals." For details, see Reference document assembly.

To correctly assemble pages into documents, you first have to analyze them to see which pages go into to which document and in what order. In the Batch window, the pages that belong to the same batch must strictly follow one another (page 1, page 2, page 3, etc.).

Note: If the pages have been added to a batch in a random order and cannot be assembled into documents, they should be renumbered. To renumber the pages, use your mouse to drag and drop each page into the desired location in the Batch window. The program will automatically renumber the rearranged pages.

  • In the Batch window, select the pages relating to the same document.
  • Right-click the selection and select Assemble to Reference Documents….
  • In the Assemble to Reference Documents dialog box, select One document. The program will group all the selected pages into one document.
  • Select First page of document matches Header. This option means that the Header element must be matched with the first page of the document.
  • Select Last page of document matches Footer. This option means that the Footer element must be matched with the last page of the document.
  • Click OK. The reference layout will be displayed in Reference layout mode: the beginning and end of the document are marked with green markers.

    Note: If the pages have been assembled into a document incorrectly, you can cancel the operation by selecting Disassemble Reference Documents.

  6. Specify the properties of your FlexiLayout:
  • Name: Invoice.
  • Text type: select Typographic and Matrix printer text types.
  • Text languages: select English, as the sample documents are in English.
  • Mode: select Fast recognition mode.
  • Minimum number of pages: 1, as the sample documents may include a minimum of one pages.
  • Maximum number of pages: 3, as the sample documents may include a maximum of 3 pages.
Show me

Note: For detailed instructions on selecting pre-recognition parameters, see Sample 1. Step 3.


Sample 4. Step 2: Viewing the images and pre-recognition results

Before you start creating your FlexiLayout, you must consider which of the image objects can be used to identify the beginning and the end of the document and to find the required data fields. You can rely only on those graphical and/or text objects which are consistently detected on the images during pre-recognition.

Note: Special Header and Footer elements can be used to detect the beginning and the end of a document. The may consist of one or more elements that unambiguously identify the document's beginning and end respectively.

To launch the pre-recognition process:

  1. Select all the images in the batch.
  2. Select the Pre-Recognize command (Batch menu or the shortcut menu of the image).

Note: For more information about the pre-recognition process, see. Sample 1. Step 4.

Once you examine the pre-recognition results, you will see that all the text objects corresponding to the field names, column names and horizontal separators are detected reliably and can be used as starting points to look for other objects on the images.

Note: For more information about viewing images and pre-recognition results, see Sample 1. Step 5 and Sample 1. Step 6.

Now you can create and set up reference elements and search constraints for blocks corresponding to data fields. Activate the FlexiLayout window and go to the next step.


Sample 4. Step 3: Blocks

Our FlexiLayout should reliably detect the following blocks (provided they are present on a given image):

  • Invoice Number
  • Invoice Date
  • Delivery Address
  • Total Amount
  • Invoice Table (Reference, Designation, Unit, Quantity, Unit Price, and Total columns)
  • Company

For convenience, create a list of all the required blocks:

  1. For the Invoice Number field, create a block of type Text and name it InvoiceNumber.
  2. For the Invoice Date field, create a block of type Text and name it InvoiceDate.
  3. For the Delivery Address field, create a block of type Text and name it DeliveryAddress.
  4. For the Total Amount field, create a block of type Text and name it TotalAmount.
  5. For the Company field, create a block of type Text and name it Company.
  6. For the Invoice Table field, create a block of type Table and name it InvoiceTable.
    In the block's Properties dialog box, click the Columns tab and add the names of the columns in the following order: Reference, Designation, Unit, Quantity, Unit Price, Total.

Note: The provided column names and their order will correspond to this block in the FlexiCapture template.

Note: For more about creating Table blocks, see Sample 3. Step 3.

You have specified the properties of your FlexiLayout and can now create the required elements.


Sample 4. Step 4: Analyzing the images to determine the order in which the elements should be detected

At this stage, you have to establish the following:

  • Is there any pattern or method in the arrangement of the fields on the images?
  • Which elements can be relied on to look for the data fields?
  • In what order should we look for the elements? (This is important, because at each subsequent step we can only rely on the elements of the previous step.)

As we are dealing with a multi-page document, we must first establish which objects can be used to identify the first and last pages of the document. These objects can be described by means of special compound Header and Footer elements.

  • The Header element must match only the first page of the document.
    If a project also contains documents of other types, this elements will also be used as an identifier (i.e. a unique characteristic identifying this document type).
  • The Footer element must match the last page of the document only. We recommend creating required subelements in this group to prevent the Footer element from being matched with any other document page.

Once you have analyzed the images, you will notice that:

  1. On the first page, there is a group of fields that consists of Invoice Number, Invoice Date, Delivery Address. The name of the Invoice Number field always goes at the beginning of each document, whereas the Invoice Date and Delivery Address are not always present.
  • The Invoice Number and Invoice Date fields can be located either to the right of their corresponding names or below them.
  • For Delivery Address, we should also look either to the right or below the corresponding name, having limited the search area. Additionally, we will need an element to restrict the search area from below.
  • Since on some of the images these fields have no values, you can speed up the matching process by specifying the following condition: do not look for the value of a field if the field's name have not been detected.
  2. We can use this group of fields as an identifier for our document. We will describe these fields as part of a compound Header element named InvoiceHeader.
  3. The last page of the document has the words TOTAL AMOUNT MUST, Carried over, Total CHF, TOTAL below the table. However, these words may also occur elsewhere on the document (e.g. in the name or in the body of the table). To find these words, we will need to use additional reference elements (e.g. table column names). These reference elements will help us restrict the search area.
  4. The elements describing the last page of the document will be part of a compound Footer element named InvoiceFooter.
  5. For the Footer element to match only the last page of the document, it must contain a required element. As the words identifying the last page (see 3 above) occur on each last page of each document, we will make the element that describes them a required element.
  6. The table (name it InvoiceTable) starts on the first page and ends on the last one. Additionally, the table is always preceded by the column names on the first page. To identify the end of the table (on the last page), we will use an auxiliary element (e.g. the required element from the InvoiceFooter group).

    Note: The multitude of all pages of a document is called a multi-page canvas. A multi-page canvas is formed by joining all the pages of a document, top-down, without any gaps, the left boundary of all the pages lying on the same axis, which goes through the point (0, 0). The order in which the pages are joined together is determined by the order of the pages in the batch, therefore, we can only specify the start of the table (its header on the first page) and end of the table (its footer on the last page). The program will search for the table in the entire document, i.e. on the entire multi-page canvas.
  7. We will look for the name of the company in the Company field always on the first page and always in the first upper third of the page.
  8. The name of the Total Amount field is always located on the last page, below the table. The value of the field is located either to the right of the name or below it.


Sample 4. Step 5: Document header and InvoiceHeader group

In the InvoiceHeader group, we will describe the elements that will help us identify the first page of the document.

  1. To find the keywords contained in the names of the Invoice Number, Delivery Address, and Invoice Date fields, create the following elements of type Static Text:
  • kwInvoiceNumber element. See Step 5.1 for detailed instructions.
  • kwDeliveryAddress element. See Step 5.2 for detailed instructions.
  • kwInvoiceDate element. See Step 5.3 for detailed instructions.
  2. We will search for the Invoice Number and Invoice Date fields to the right and below the corresponding name, using the following elements:
  • InvoiceNumber of type Character String. See Step 5.4 for detailed instructions.
  • InvoiceDate of the Date type (for good quality images) and InvoiceDateAsString of type Character String (if the search for the InvoiceDate element produced no results) merged into a grDate element of type Group. See Step 5.5 for detailed instructions.

Note: For more information about searching for dates on poor quality images, see Tips and Tricks.

  3. To find the Delivery Address field, which has multiple lines, use a DeliveryAddress of type Text FragmentText Fragment (see Step 5.6 for detailed instructions). The search area should be specified as strictly as possible.
    We will use a wgAddressAbove element of the White Gap type to restrict the search area from below (see Step 5.6 for detailed instructions).
    Next will group all these elements that serve to detect the Delivery Address field into one group named grAddress:


Sample 4. Step 5.1: Name of Invoice Number field, kwInvoiceNumber element

Once you have examined the images, you will notice that:

  • The name of the Invoice Number field is present on all the images and it is the name that can be used to differentiate them from other documents. For this reason, we will make the name of the Invoice Number field a required element, i.e. it will be used as an identifier for this document type. For details, see Required, optional, and prohibited elements.
  • The name may contain one of the following phrases: Invoice no., Credit note No, Invoice Number:, Invoice Number.
    We will list all the possible variants in the search string. Type each phrase without spaces to make the maximum number of errors to apply to the entire phrase and not to separate words.
  • We are now interested only in the field located on the first page of each document, in the first part of the first page (some of the first pages contain static text which is similar to the name but located at the bottom of the page).

To create a kwInvoiceNumber element:

  1. In the InvoiceHeader element, create an element of type Static Text and name it kwInvoiceNumber.
  2. Clear the default Optional element option on the General tab (earlier we decided to make this element required).
  3. Click the Static Text tab.
  4. In the Search text field, type the search text: InvoiceNo.|CreditNoteNo|InvoiceNumber:|InvoiceNumber
  5. Set Max error percentage to 20.
  6. Click theSearch Constraints tab and use absolute coordinates to specify the rectangular search area on the first page:
  • Select Absolute search area constraints
  • In the Pages field, select Range from the drop-down list
  • In the Range field, type 1
  • In the Region field, specify the coordinates of the rectangle [1, 1, 2475, 1878]
  • Once you have specified the properties of the search area, click Add. The search area will appear in the Search areas list
Show me
  7. Click the Advanced tab.
  8. In the Advanced pre-search relations field, specify additional constraints:

    WholeWordMode: true; // Only whole text objects will be treated as possible hypotheses.
    MaxGapInLine: 50dt; // The maximum distance between neighboring words.
  9. By specifying an additional check in the Advanced post-search relations field, you can influence the quality of the generated hypotheses. For example: If the element has been detected, calculate the difference between the reference width and the width of the region of the detected element and check if it belongs to the fuzzy interval.
    In the FlexiLayout language, this condition can be written as follows:

    If not IsNull then
    { FuzzyQuality: 600dt - width, {-70000,0,0,70000}*dt;
    }
    //This condition means that the greater the difference, the greater the penalty/

    Note:. To specify the locations of objects and the distances among them, a two-dimensional coordinate system is used. The (0, 0) point, where the vertical and horizontal axes intersect, is located in the top left corner of the image. The abscissa axis is directed left to right, the ordinate axis is directed top to bottom.
  10. Temporarily exclude the InvoiceFooter element and match the FlexiLayout.
    Note: To exclude an element, select it in the tree of elements and then select Disable from the FlexiLayout menu.


Sample 4. Step 5.2: Name of Delivery Address field, kwDeliveryAddress element

Once you have examined the images, you will notice that:

  • The field in question is always located on the first page, in the first part of the page. Therefore, you can limit the search area to the first page and use absolute coordinates to specify a rectangular area.
  • We will use the AddressHeaders.txt file to search for the text.
    Note: Both the GUI and the FlexiLayout language allow you to use databases and text files to specify text lines to be found on an image. Text files can use either ANSI or Unicode encoding. Letter case does not affect the search and only serves to make the text more readable. Each search string must be placed on a separate line. Empty lines are ignored.
  • You can set the maximum error percentage to 20, which in our case means no more than 3 errors in each phrase.
    Note: The optimal number of errors can only be arrived at through trial and error. For details about the Static Text elements, see Static Text.

    .

To create a kwDeliveryAddress element:

  1. In the InvoiceHeader element, create an element of type Static Text and name it kwDeliveryAddress.
  2. Click the Static Text tab.
  3. Select Search text from file and provide the path to the AddressHeaders.txt file.
    Note: The AddressHeaders.txt file can be found in
    <disk name>:\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples\FlexiLayout Studio\Invoice\Dict.
    A text file is accessed by its name, which can be either absolute or relative. Relative names are specified relative to the FlexiCapture project folder (the folder that contains the *.fcproj file) or the FlexiLayout Studio project folder (the folder that contains the images).
    4. Show me

  4. Set Max error percentage to 20.
  5. Click theSearch Constraints tab and use absolute coordinates to specify the rectangular search area on the first page:
  • Select Absolute search area constraints
  • In the Pages field, select Range from the drop-down list
  • In the Range field, type 1
  • In the Region field, specify the coordinates of the rectangle [1, 1, 2475, 1878]
  • Once you have specified the properties of the search area, click Add. The search area will appear in the Search areas list
  6. Click the Advanced tab and in the Advanced pre-search relations specify WholeWordMode: true;
    // Only whole text objects will be treated as possible hypotheses.
  7. Temporarily exclude the InvoiceFooter element and match the FlexiLayout.


Sample 4. Step 5.3: Name of Invoice Date field, kwInvoiceDate element

Once you have examined the images, you will notice that:

  • The name of the Invoice Date field is a short and very common word Date.
    This means that we have to narrow down the search area as much as possible.
  • The name of the Date field (if this field is present on a given image) is located very close to the name of the Invoice Number field.

To create a kwInvoiceDate element:

  1. In the InvoiceHeader element, create an element of type Static Text and name it kwInvoiceDate.
  2. Click the Static Text tab.
  3. In the Search text field, type the text to search: Date.
  4. Set Max error percentage to 30 (which means that only one error can be made in our word which has four letters).
  5. Click the Relations tab.
  6. On the Relations tab, specify that the keywords may not be more than 30 dots above the upper boundary of the name of the Invoice Number field and not more than 700 dots below its lower boundary:
  • Below the upper boundary of the region of kwInvoiceNumber, Offset = -30, Element boundary = Top.
  • Above the lower boundary of the region of kwInvoiceNumber, Offset = -700, Element boundary = Bottom.

Note: Once you have created the new relation, click Add The new relation will appear in the Relations list.

Note: When selecting Offset values, you may wish to examine the geometrical properties (boundaries and sizes) of the reference and search image objects in pre-recognition results mode. You can use the Measure Rectangle tool to measure distances. Offset values can only be selected by method of trial and error.

  7. Temporarily exclude the InvoiceFooter element and match the FlexiLayout.

Try matching the FlexiLayout. You will notice that:

  • On the first page of some of the documents, several hypotheses have been generated for kwInvoiceDate and sometimes the wrong hypotheses has been selected. To correct the error, we need to adjust the properties of the element.
  • The field we are interested in is closest to the upper edge of the page.

To specify additional search constraints:

  1. Open the Properties dialog box for the kwInvoiceDate element.
  2. Click the Relations tab.
  3. Select Nearest and then select Page top edge from the To drop-down list.
Show me

Match the FlexiLayout again to make sure that the name of the Invoice Date field can be reliably detected.


Sample 4. Step 5.4: Invoice Number field, InvoiceNumber element

On some of the documents, the Invoice Number field is located to the right of the field name whereas on other documents it is located below the name (in documents 1 and 2 the field data are placed directly beneath the name).

To create an InvoiceNumber element:

  1. In the InvoiceHeader element, create an element of type Character String and name it InvoiceNumber.
    Note: The name of the element need not be the same as the name of the block corresponding to the InvoiceNumber field. However, having identical names is convenient when working with a FlexiLayout.
  2. Click the Character String tab.
  3. Specify the alphabet:
    -./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  4. Set Percentage of non-alphabet characters to 30%.
  5. In the Character count field, specify the fuzzy interval {-1, 3, 20, INF} for the length of the character string, assuming that possible values fall into the region of 3 to 20 characters. Any hypothesis outside this interval will be penalized.
  6. On some of the images, the search area for the Invoice Number field contains the already detected kwInvoiceDate element. Exclude this element from the search area, so that the program does not include this text in its hypotheses for the Invoice Number field:
  • Click the Add… button next to the Exclude elements field.
  • Select kwInvoiceDate from the list of elements.
  • Click OK. The string SearchElements.InvoiceHeader.kwInvoiceDate will appear in the Exclude elements field.
Show me

  7. Click the Advanced tab.
  8. In Advanced pre-search relations, specify additional conditions: if the name kwInvoiceNumber is not found, do not search for the InvoiceNumber field, otherwise specify the search area as an array of rectangles: one rectangle to the right of the name and another rectangle below the name with a small offset. In the FlexiLayout this condition can be written as follows:

if kwInvoiceNumber.IsNull then Dontfind();
else
{ WholeWordMOde: true;
MaxGapInLine: 30dt;

RectArray DataRegion;

Let r1= Rect (kwInvoiceNumber.Rect.Right, kwInvoiceNumber.Rect.Top -20dt,
  kwInvoiceNumber.Rect.Right + 650dt, kwInvoiceNumber.Rect.Bottom + 50dt);
// Limits the search area by a rectangle to the right of the name of the
  InvoiceNumber field.

Let r2 = Rect (kwInvoiceNumber.Rect.Left - 100dt, kwInvoiceNumber.Rect.Bottom,
  kwInvoiceNumber.Rect.Right + 100dt, kwInvoiceNumber.Rect.Bottom + 100dt);
// Limits the search area by a rectangle beneath the name of the
  InvoiceNumber field.

DataRegion = RectArray (r1);
DataRegion.Add (r2);
RestrictSearchArea (DataRegion);
}

  9. The search area for the field is limited to two rectangles, one to the right of the field name and one beneath it. If the field data are located to the right of the field name, there is often some other text beneath the field (on the test images, this is most commonly the name and data of the Date field). Since this extraneous text will be included into the search area for the Invoice Number field, the program will generate a hypothesis for this text. To influence the quality of this hypothesis, specify additional checks in the Advanced post-search relations field: the lower the text beneath the field name, the bigger the penalty. In the FlexiLayout language, this condition can be written as follows:

if not IsNull then
{ FuzzyQuality: Top - kwInvoiceNumber.Rect.Top, {-30000,0,0,10000}*dt;
}
// The greater the distance between the name and upper boundary of the field, the bigger the penalty for the corresponding hypothesis. In this particular case, the hypothesis for the element whose upper boundary coincides with the upper boundary of the name will have the highest quality.

  10. Temporarily exclude the InvoiceFooter element and match the FlexiLayout.
  11. Specify the location of the InvoiceNumber block as a rectangular region of the InvoiceNumber element enlarged by 5 dots vertically and horizontally. To do this, select Expression and type the following expression:

Rect outputRect;
outputRect = InvoiceHeader.InvoiceNumber.Rect;
IsNull = InvoiceHeader.InvoiceNumber.IsNull;
// Treats the block region as detected if the InvoiceNumber element has been
  detected.

OutputRegion = outputRect;
OutputRegion.Inflate (5dt, 5dt);


Sample 4. Step 5.5: Invoice Date field, grDate, InvoiceDate, and InvoiceDateAsString elements

Once you have examined the images, you will notice that:

  • On some of the documents, the Invoice Date field is located to the right of the field name and on others it is located beneath the name. Therefore, we will limit the search area to rectangles to the right and beneath the name.
  • We will use a Date element to search for the date. Additionally, we will specify the following condition: if the field name is not detected, do not search for the field data.
  • Quite often, dates may be recognized unreliably. This may be due to scanning defects, invalid date formats, etc. Therefore, we will specify an additional Character String element in case the Date element fails to find any date.

To specify the settings common to all the elements, we will create an element of type Group.

To create a grDate element of type Group:

1. In the InvoiceHeader element, create an element of type Group and name it grDate.

2. Click the Advanced tab and specify additional search constraints: limit the search area to the array of rectangles consisting of one rectangle to the right of the field name and rectangle below the field name with some offset. In the FlexiLayout language this constraint can be written as follows:

RectArray DataRegion;

Let r1= Rect (kwInvoiceDate.Rect.Right, kwInvoiceDate.Rect.Top -20dt,
kwInvoiceDate.Rect.Right + 650dt, kwInvoiceDate.Rect.Bottom + 50dt);
Let r2 = Rect (kwInvoiceDate.Rect.Left - 150dt, kwInvoiceDate.Rect.Bottom,
kwInvoiceDate.Rect.Right + 100dt, kwInvoiceDate.Rect.Bottom + 100dt);

DataRegion = RectArray (r1);
DataRegion.Add (r2);
RestrictSearchArea (DataRegion);

To create an InvoiceDate element:

1. In the InvoiceHeader.grDate element, create an element of type Date and name it InvoiceDate.

2. Click the Date tab.

3. Specify all the possible date formats for the InvoiceDate element:

Show me

  4. On some of the images, the search area of the Invoice Date field will include the already detected kwInvoiceNumber and InvoiceNumber elements. To prevent the program from considering the values of these elements as hypotheses for the Invoice Date field, exclude these elements from the search area:
  • Click the Add… button next to the Exclude elements field.
  • Select kwInvoiceNumber from the list of elements.
  • Click OK. The string SearchElements.InvoiceHeader.kwInvoiceNumber will appear in the Exclude elements field.

Repeat the above actions for the element SearchElements.InvoiceHeader.InvoiceNumber.

  5. Click the Advanced tab.
  6. The Invoice Date field is not a required element. However, if a document contains a date (in the Invoice Date field), there is always the corresponding field name on the document (described earlier by the kwInvoiceDate element). Therefore, you can specify an additional search condition in Advanced pre-search relations: Search for the image object only if the kwInvoiceDate has been detected. In the FlexiLayout language, this condition can be written as follows:

If InvoiceHeader.kwInvoiceDate.IsNull
Then DontFind();

  7. Temporarily exclude the InvoiceFooter element and match the FlexiLayout.

For poor quality images, when recognition results do not fit any of the standard parameters of the Date element, we will add an alternative element which will use more lax conditions to search for the Invoice Date field.

To create an InvoiceDateAsString element:

  1. In the InvoiceHeader.grDate element, create an element of type Character String and name it InvoiceDateAsString.
  2. Click the Character String tab.
  3. Specify the alphabet:
    ,-./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  4. Set the percentage of non-alphabet characters to 30%.
  5. In the Character count field, specify the fuzzy interval {-1, 8, 14, INF}for the length of the character string, assuming that possible values fall into the region of 8 to 14 characters. Any hypothesis outside this interval will be penalized.
  6. Set Max space length to 20. This limits the maximum length of space in the text string to 20 dots.
  7. For the other element properties, keep the default settings.
  8. Click the Advanced tab.
  9. Since we are going to search for the InvoiceDateAsString element only if the InvoiceDate is not detected on the image, specify the following condition in the Advanced pre-search relations field: Search for the image object only if the InvoiceDate element is not detected. In the FlexiLayout language, this condition can be written as follows:

If Not InvoiceDate.IsNull Then DontFind;

  10. Specify an additional condition for InvoiceDate similar to the one above: Search for the image object only if the kwInvoiceDate element has been detected. Search for an image object closest to the kwInvoiceDate element. In the FlexiLayout language, this condition can be written as follows:

If InvoiceHeader.kwInvoiceDate.IsNull Then DontFind;
Nearest: InvoiceHeader.kwInvoiceDate;

  11. Specify the location of the InvoiceDate block as the rectangular region of the detected InvoiceDate or InvoiceDateAsString element increased by 5 dots vertically and horizontally. To do this, select the Expression option and type the following expression:

Rect outputRect;
if not InvoiceHeader.grDate.InvoiceDate.IsNull then
outputRect = InvoiceHeader.grDate.InvoiceDate.Rect;
else
{ outputRect = InvoiceHeader.grDate.InvoiceDateAsString.Rect;
IsNull = InvoiceHeader.grDate.InvoiceDateAsString.IsNull;
}
OutputRegion = outputRect;
OutputRegion.Inflate (5dt, 5dt);


Sample 4. Step 5.6: Delivery Address field, grAddress, wgAddressAbove, and DeliveryAddress elements

We have decided to search for the Delivery Address field:

  • to the right of and below the field name
  • using the White Gap element to limit the search area from below
  • using a Text Fragment element

To specify the properties common to all these elements, we will create a Group element.

To create a group grAddress element:

1. In the InvoiceHeader element create an element of type Group and name it grAddress.

2. Click the Relations tab and specify the following search constraints for the elements of the group:

  • Above the kwDeliveryAddress element, Offset = -400
  • Left of the right boundary of the kwDeliveryAddress element, Offset = -800, Element boundary = Right.
  • Right of the left boundary of the kwDeliveryAddress element, Offset = -50, Element boundary = Left.
  • Below the upper boundary of the kwDeliveryAddress element, Offset = -20, Element boundary = Top.
Show me

To limit the search area for the DeliveryAddress element from below, we will specify a horizontal White Gap.

To create a wgAddressAbove element:

  1. In the InvoiceHeader.grAddress element, create an element of type White Gap and name it wgAddressAbove.
  2. Click the White Gap tab.
  3. Under Orientation, select Horizontal. Set Min height to 55.
    Note: When selecting values for the heights/widths of white gaps, you may wish to consider the geometry (i.e. boundaries and sizes) of the adjacent image objects in pre-recognition results mode.
  4. We are going to look for a white gap inside a text fragment, therefore under Search among objects of type, select only Text.
  5. Under Rubbish, specify the following values:
  • Lower threshold limit – 20;
  • Upper threshold limit – 80;
  • Threshold coefficient (%) – 10.
Show me

Note: The values for the properties Lower threshold limit, Upper threshold limit, and Threshold coefficient (%) can only be selected by method of trial and error. We recommend starting with the default values. If the default values do not work, altering them until the white gap is detected on all the test images.

  6. Do not specify any additional search constraints and retain the default values for the other options.
  7. Click the Relations tab.
  8. Since the white gap can be located only beneath the keywords of the name kwDeliveryAddress, specify the following search constraints:

Below the kwDeliveryAddress element, Offset = 20
Offset is required in order to prevent the program from finding white gaps in other areas on the image, e.g. between the field name and the text. Click the Advanced tab.

  9. Since the Delivery Address field is not present on all of the images, but when it does occur it is always accompanied with its name, specify the following additional condition in the Advanced pre-search relations field: Search for the image object only if the kwDeliveryAddress element is detected. In the FlexiLayout language, this condition can be written as follows:

If InvoiceHeader.kwDeliveryAddress.IsNull Then DontFind;

  10. Match the FlexiLayout to see if the wgAddressAbove element is detected on all images.
  11. Since the program sometimes finds more than one white gap in the specified search area and cannot always select the right one, we need to impose additional search constraints. If you examine the images, you will notice that the white gap we are interested in is the topmost gap in the given search area. Therefore, in the Advanced pre-search relations field, specify the following additional condition: Search for an image object closest to the upper boundary of the first page. In the FlexiLayout language, this condition can be written as follows:

NearestY: Page(1).RectGlobal.Top;

  12. Temporarily exclude the InvoiceFooter element and match the FlexiLayout.

To create a DeliveryAddress element:

  1. In the InvoiceHeader.grAddress element, create an element of type Text FragmentText Fragment nd name it DeliveryAddress.
  2. Click the Relations tab.
  3. Since DeliveryAddress can be located only above the white gap wgAddressAbove, specify the following search constraint:

Above the wgAddressAbove element, Offset = 0.

  5. Since the search area for the DeliveryAddress element has already been specified at the level of the InvoiceHeader.grAddress group, we need not specify it once again here.
  6. Click the Advanced tab.
  7. Since the name of the DeliveryAddress field is also located inside the search area, we need to exclude it in order to obtain only the value of DeliveryAddress. Additionally, there are separators and noise in the search area which are also best excluded. For the above reasons, we cannot just exclude the region of the kwDeliveryAddress element. It would be more appropriate to take the region of the kwDeliveryAddress element, enlarge this region so that it encompasses all the noise, and then exclude the resulting rectangle. To do this, specify the following search constraints in the Advanced pre-search relations field:

If InvoiceHeader.kwDeliveryAddress.IsNull Then DontFind;
Else

// Draws a rectangle around the field name (with some offset for the
  boundaries)
{ Let Left = InvoiceHeader.kwDeliveryAddress.Rect.Left - 100dt;
Let Top = InvoiceHeader.kwDeliveryAddress.Rect.Top - 100dt;
Let Right = InvoiceHeader.kwDeliveryAddress.Rect.Right + 20dt;
Let Bottom = InvoiceHeader.kwDeliveryAddress.Rect.Bottom;

// Exclude the resulting rectangle from the search area of the field
ExcludeRect (Left, Top, Right, Bottom);
}

  8. Temporarily exclude the InvoiceFooter element and match the FlexiLayout.
  9. Specify the location of the DeliveryAddress block as the rectangular region of the detected DeliveryAddress element, simplified for better visual perception and expanded by 5 dots vertically and horizontally. To do this, select the Expression option and type the following expression:

Rect outputRect;
OutputRegion = InvoiceHeader.grAddress.DeliveryAddress.SimplifiedRegion;
IsNull = InvoiceHeader.grAddress.DeliveryAddress.IsNull;
OutputRegion.Inflate (5dt, 5dt);


Sample 4. Step 6: Document Footer, InvoiceFooter group

In the InvoiceFooter group we will specify the elements that will enable the program to identify the last page of the document:

  • The last page of the document always has the keywords "TOTALAMOUNTMUST", "Carriedover," "TotalCHF," "Total."
  • To search for this text, we will create two elements. In the first element, specify "TOTALAMOUNTMUST," "Carriedover," and "TotalCHF" Create a second element below the first one in the tree of elements and specify only "Total" in this second element (the program will search for this element only if the first element has not been detected). This will reduce the number of hypotheses generated for the element and speed up the FlexiLayout matching process.
  • These words are always located below the column names Description and Product Total on the same page.

To search for the keywords in the Product Total and Description column, we will create elements of type Static Text:

  • ExtraTag element: see detailed instructions in Step 6.1.
  • AddTag element: see detailed instructions in Step 6.2.

We will also use Static Text elements to search for the keywords "TOTALAMOUNTMUST," "Carriedover," "TotalCHF," and "Total" :

  • LongFooter element: see detailed instructions in Step 6.3.
  • ShortFooter element (to search for the keyword "Total"): see detailed instructions in Step 6.4.

To mate Footer match only the last page of the document, it must contain a required element. Since the keywords that identify the last page of the document can be found on every last page of every document, in the InvoiceFooter group, create a required element of type Text FragmentText Fragment and name it InvoiceFooter. Specify the search area for this element as the rectangular region of the detected LongFooter or ShortFooter element, slightly expanded vertically and horizontally (for detailed instructions, see Step 6.5).


Sample 4. Step 6.1: Product Total column name, ExtraTag element

To create an ExtraTag element:

  1. In the InvoiceFooter element, create an optional element of type Static TextStatic Text and name it ExtraTag.
  2. Click the Static Text tab.
  3. In the Search text field, type the text to search: PRODUCTTOTAL.
  4. Do not impose any additional constraints and leave default values for the other options.


Sample 4. Step 6.2: Description column name, AddTag element

To create an AddTag element:

  1. In the InvoiceFooter element, create an optional element of type Static Text and name it AddTag.
  2. Click the Static Text tab.
  3. In the Search text field, type the text to search: Designation|Description.
  4. In Advanced pre-search relations specify additional constraints:

WholeWordMode: true; // Only whole words must be considered as hypotheses.
MaxGapInLine: 10dt; // This is the maximum distance between adjacent characters.


Sample 4. Step 6.3: The final part of the document, LongFooter element

To create a LongFooter element:

  1. In the InvoiceFooter element, create an optional element of type Static Text and name it LongFooter.
  2. Click the Static Text tab.
  3. In the Search text field, type the text to search: TOTALAMOUNTMUST|Carriedover|TotalCHF.
  4. Since the search text is always located below the name of the Description column, click the Relations tab and specify the following relation:

Below the AddTag element, Offset = 100;

  5. Since on some of the documents (e.g. on documents 3 and 9) the program finds several text variants and selects the wrong one, we must impose additional constraints. Once you have analyzed the images, you will notice that the text we are interested in is the topmost text in the given search area (we want to find the text that is closest to the table order, because it can then be used as the Footer of the table). On the Relations tab, specify additional search constraints: Search for a string closest to the upper boundary of the document:
  • Select the Nearest option.
  • In the To field, select Y coordinate from the drop-down list.
  • In the Y field, type 0.
Show me


Sample 4. Step 6.4: The final part of the document, ShortFooter element

To create a ShortFooter element:

  1. In the InvoiceFooter element, create an optional element of type Static Text and name it ShortFooter.
  2. Click the Static Text tab.
  3. In the Search text field, type the text to search: Total.
  4. Click the Search Constraints tab and exclude the already detected ExtraTag element from the search area of the ShortFooter element. This will prevent the program from finding the word "Total" in the name of the table:
  • Click the Add… button next to the Exclude elements field.
  • Select ExtraTag from the list of elements.
  • Click OK. The SearchElements.InvoiceFooter.ExtraTag string will appear in the Exclude elements field.

5. Since the search text is always located below the name of the Description column, click the Relations tab and specify the following relation:

Below the AddTag element, Offset = 100;

6. earlier we decided that we will search for the ShortFooter element only if LongFooter has not been detected. To implement this condition, specify the following in Advanced pre-search relations: Do not search for the element if LongFooter has not been detected. In the FlexiLayout language, this condition can be written as follows:

If not LongFooter.IsNull then Dontfind();


Sample 4. Step 6.5; The final part of the document, TextFragment element

To create a TextFragment element:

  1. In the InvoiceFooter element, create a required element of type Text Fragment and name it Text Fragment.
  2. Click the Advanced tab and in the Advanced pre-search relations field, specify additional search conditions: Do not search for the element if neither, LongFooter nor ShortFooter has been detected. If LongFooter has been detected, specify the search area as the rectangular region of this element expanded by 10 dots vertically and horizontally. If ShortFooter has been detected, specify the search area as the rectangular region of this element expanded by 10 dots vertically and horizontally. In the FlexiLayout language, this condition can be written as follows:

If LongFooter.IsNull and ShortFooter.IsNull then Dontfind();
// Do not
  search for the element if none of the
  elements are detected
else
{ if not LongFooter.IsNull then
//
  If LongFooter is detected, the search area is defined based on its region
{ LeftOf: LongFooter.Rect.Right + 10dt;
RightOf: LongFooter.Rect.Left - 10dt;
Below: LongFooter.Rect.Top - 10dt;
Above: LongFooter.Rect.Bottom + 10dt;
}
else if not ShortFooter.IsNull then
// If ShortFooter is detected, the search area is defined as the region of ShortFooter
{ LeftOf: ShortFooter.Rect.Right + 10dt;
RightOf: ShortFooter.Rect.Left - 10dt;
Below: ShortFooter.Rect.Top - 10dt;
Above: ShortFooter.Rect.Bottom + 10dt;
}
}

Try matching the FlexiLayout and make sure that the pages are correctly separated into documents as defined by the Header and Footer elements. Once the FlexiLayout is matched with all the pages, the documents should be assembled as specified in the reference assembly created when we started work on this FlexiLayout.

Note: To apply the FlexiLayout to all test images, use keyboard shortcuts:

  • Activate the Batch window
  • Press Ctrl + A to select all the pages.
  • Press Ctrl + Shift + E to analyze all the selected pages.

Note: In the case of a multi-page document, be sure to apply the FlexiLayout to all the pages of the document, not just to some of the pages. Otherwise, the program may fail to apply the FlexiLayout to some of the documents.


Sample 4. Step 7: Table column names, TableHeader group

We will use a Table element to search for the Invoice Table field. However, some preparations have to be done: we have to detect the column names first. In this sample, auxiliary elements are used to search for column names.

Therefore, before we start searching for the fields, we need to create a number of elements.

To described the column names, create a TableHeader group, which will include the descriptions of all the column names. Also, limit the search area to the first page.

To create a TableHeader element:

  1. In the tree of elements, create an element of typeGroup and name it TableHeader.
  2. Click the Search Constraints tab and specify the search area for the element:
  • Select the Absolute search area constraints option.
  • In the Pages field, select Range from the drop-down list.
  • In the Range field, type 1.
  • In the Region field, keep the default value <whole page>.
  • Click the Add button.

We will use Static Text elements to search for the column names.

In the TableHeader group, create the following elements:

  1. kwDesignation element: see detailed instructions in Step 7.1,
  2. ExtraQtyTag element: see detailed instructions in Step 7.2,
  3. kwQuantity element: see detailed instructions in Step 7.3,
  4. kwUnitPrice element: see detailed instructions in Step 7.4,
  5. kwTotal element: see detailed instructions in Step 7.5,
  6. kwReference element: see detailed instructions in Step 7.6,
  7. kwSales element: see detailed instructions in Step 7.7,
  8. kwUnit element: see detailed instructions in Step 7.8.


Sample 4. Step 7.1: Name of Designation column, kwDesignation element

Once you have analyzed the pre-recognition results, you will notice that there are only two variants of the name - Designation and Description. Since we specified the search area at the level of the group, we need not specify it here.

To create a kwDesignation element:

1. In the TableHeader element, create an element of type Static TextStatic Text and name it kwDesignation.

2. Click the Static Text tab.

3. In the Search text field, specify the text to search: Designation|Description.

4. Keep the default values for the other options.

5. Match the FlexiLayout to make sure that the element is detected on the mages.


Sample 4. Step 7.2: Name of ExtraQuantity column, ExtraQtyTag element

Now we need to detected the name Quantity, which appears on the documents as "Qty," "Quantity," "ORDERED," or "QtyNet". However, there is one more name in the table which may also contain the word "Quantity". This name also contains unique text. Therefore, we will first described the ExtraQtyTag and then exclude it from the search area of the name Quantity.

On all the documents, the name of the ExtraQtyTag column is exactly the same. Even though the quality of the images is fairly good, set the maximum error percentage to 35%. For a seven- or eight-letter word this means that two characters may be incorrect.

Additionally, since all the names are placed on the same level, specify an additional search constraint relative to the already detected name of the Designation column.

To create an ExtraQtyTag element:

  1. In the TableHeader element, create an element of type Static TextStatic Text and name it ExtraQtyTag.
  2. Click the Static Text tab.
  3. In the Search text field, specify the text to search: {Quantity *BK.ORD}.
  4. Set Max error percentage to 35.
  5. Since the ExtraQuantity field contains multiple lines, select the options Take spaces into account and Permit multiple lines.
  6. We will not penalize hypotheses carried over to the next line: set Line break penalty to 1.
  7. To specify that the name we are searching is located on the same level with the name Designation, click the Relations tab and specify the following additional constraints:

Above the lower boundary of the kwDesignation element, Offset = -50, Element boundary = Bottom,
Below the upper boundary of the kwDesignation element, Offset = -50, Element boundary = Top.

Show me

  8. To optimize the search process, specify an additional condition: Do not search for the name if the name Designation has not been detected. Click the Advanced tab and specify this condition in Advanced pre-search relations. In the FlexiLayout language, this condition can be written as follows:

If kwDesignation.IsNull then Dontfind();

  9. In Advanced pre-search relations, also specify additional constraints:

WholeWordMode: true; // Only whole words will be considered as hypotheses.
Note: This constrain can also be specified via the GUI by selecting Whole words only on theStatic Text tab.

  10. Match the FlexiLayout to make sure that the element is detected on the first page of the document.


Sample 4. Step 7.3: Name of Quantity column, kwQuantity element

We will rely on the already detected kwDesignation and ExtraQtyTag elements to describe this name.

To create a kwQuantity element:

  1. In the TableHeader element, create an element of type Static TextStatic Text and name it kwQuantity.
  2. Click the Static Text tab.
  3. In the Search text field, specify the text to search: Qty|Quantity|ORDERED|QtyNet.
  4. Set Max error percentage to 35.
  5. Click the Search Constraints tab and exclude the already detected element SearchElements.TableHeader.ExtraQtyTag from the search area.
  6. To specify that the name we are searching is located on the same level with the name Designation, click the Relations tab and specify the following additional constraints. See Step 7.2 for details.
  7. To optimize the search process, specify an additional condition: Do not search for the name if the name Designation has not been detected. See Step 7.2 for details.
  8. In Advanced pre-search relations, specify additional search constraints:

WholeWordMode: true; // Only whole words will be considered as hypotheses.
MaxGapInLine: 20dt; // This is the maximum distance between adjacent characters.

  10. Match the FlexiLayout to make sure that the element is detected on the first page of the document.


Sample 4. Step 7.4: Name of UnitPrice column, kwUnitPrice element

Once you have analyzed the images you will notice that the name of the Unit Price column can be described by the following search text: "UnitPrice," "Price," and "RATE", and the name Unit appears as "Unit." To prevent the program from detecting the word "Unit" in the name of the Unit Price column, we will first describe Unit Price, because it contains unique text, and then we will use an additional relation do describe Unit.

When creating an element to search for the keywords of the name of the Unit Price column, take into account the fact that the Unit Price column is always located to the right of the Quantity column.

To create a kwUnitPrice element:

  1. In the TableHeader element, create an element of type Static TextStatic Text and name it kwUnitPrice.
  2. Click the Static Text tab.
  3. In the Search text field, specify the text to search: UnitPrice|Price|RATE.
  4. To specify that the name we are searching is located on the same level with the name Designation, click the Relations tab and specify the following additional constraints. See Step 7.2 for details.
  5. On the Relations tab, specify the following condition: search for an element closest to the X coordinate with value = 0.
Show me

  6. Click the Advanced tab.
  7. Since the name of the Unit Price column is located to the right of the name of the kwQuantity column, specify the following additional conditions in Advanced pre-search relations: If the kwQuantity element has been detected, search for the image object to the right of the kwQuantity element. In the FlexiLayout language, this condition can be written as follows:

If Not (TableHeader.kwQuantity.IsNull) Then
RightOf: TableHeader.kwQuantity, 0 * dot;

  8. To optimize the search process, specify an additional condition: Do not search for the name if the name Designation has not been detected. See Step 7.2 for details.
  9. WE can influence the quality of generated hypotheses by specifying additional checks in the Advanced post-search relations field. In this case, we may specify the following check: If the element has been detected, calculate the difference between the reference width and the width of the detected element and see if it belongs to the given fuzzy interval. In the FlexiLayout language, this condition can be written as follows:

If not IsNull then
{ FuzzyQuality: 400dt - width, {-50000,0,0, 50000}*dt;
}
//This check means that the greater the difference, the greater the penalty
  coefficient

  10. Match the FlexiLayout to make sure that the element is detected on the first page of the document.


Sample 4. Step 7.5: Name of Total column, kwTotal element

You will notice that the Total column on all the images is located to the right of the Unit Price column. Therefore, we can search for the Total column relative to the Unit Price column.

To create a kwTotal element:

  1. In the TableHeader element, create an element of type Static TextStatic Text and name it kwTotal.
  2. Click the Static Text tab.
  3. In the Search text field, specify the text to search: TotalChf|Total|Extension|AMOUNT|PRODUCTTOTAL.
  4. To specify that the name we are searching is located on the same level with the name Designation, click the Relations tab and specify the following additional constraints. See Step 7.2 for details.
  5. On the Relations tab, specify the following condition: search for an element closest to the X coordinate with value=6000.
Show me

  6. Click the Advanced tab.
  7. Since the name of the Total column is located to the right of the name of the kwUnitPrice column (if the latter is present on the image), specify an additional condition in Advanced pre-search relations: If the element kwUnitPrice is detected, search for kwUnitPrice. In the FlexiLayout language, this condition can be written as follows:

If Not (TableHeader.kwUnitPrice.IsNull) Then
RightOf: TableHeader.kwUnitPrice, 0 * dot;

  8. To optimize the search process, specify an additional condition: Do not search for the name if the name Designation has not been detected. See Step 7.2 for details.
  9. Match the FlexiLayout to make sure that the element is detected on the first page of the document.


Sample 4. Step 7.6: Name of Reference column, kwReference element

You will notice that on the documents this name appears as "Reference," "ID," "Item" or "CODE."

To create a kwReference element:

1. In the TableHeader element, create an element of type Static TextStatic Text and name it kwReference.

2. Click the Static Text tab.

3. In the Search text field, specify the text to search: Reference|ID|Item|CODE.

4. To specify that the name we are searching is located on the same level with the name Designation, click the Relations tab and specify the following additional constraints. See Step 7.2 for details.

5. To optimize the search process, specify an additional condition: Do not search for the name if the name Designation has not been detected. See Step 7.2 for details.

6. Match the FlexiLayout to make sure that the element is detected on the first page of the document.


Sample 4. Step 7.7: Name of Sales column, kwSales element

Even we do not need the Sales column per se, it can be used to limit the table on the right.

To create a kwSales element:

  1. In the TableHeader element, create an element of typeStatic Text and name it kwSales.
  2. Click the Static Text tab.
  3. In the Search text field, specify the text to search: Sales
  4. To specify that the name we are searching is located on the same level with the name Designation, click the Relations tab and specify the following additional constraints. See Step 7.2 for details.
  5. Click the Advanced tab.
  6. Since the name of the Sales column is located to the right of the kwTotal column (if the latter is present on the image), specify an additional condition in Advanced pre-search relations: If the kwTotal element is detected, search for the image object to the right of the kwTotal element. In the FlexiLayout language, this condition can be written as follows:

If Not (TableHeader.kwTotal.IsNull) Then
RightOf: TableHeader.kwTotal, 0 * dot;

  7. To optimize the search process, specify an additional condition: Do not search for the name if the name Designation has not been detected. See Step 7.2 for details.
  8. Match the FlexiLayout to make sure that the element is detected on the first page of the document.


Sample 4. Step 7.8: Name of Unit column, kwUnit element

When creating an element to search for the keywords of the name of the Unit column, we will rely on the already detected column UnitPrice and specify an additional relation: Search for the name of the Unit column to the left of the left boundary of the name of the UnitPrice column.

To create a kwUnit element:

  1. In the TableHeader element, create an element of typeStatic Text and name it kwUnit.
  2. Click the Static Text tab.
  3. In the Search text field, specify the text to search: Unit.
  4. To specify that the name we are searching for is located on the same level with the name Designation, click the Relations tab and specify the following additional constraints. See Step 7.2 for details.
  5. To specify that the name is located to the left of the left boundary of the name of the UnitPrice column, specify the following additional constraint on the Relations tab:

Left of the left boundary of the kwUnitPrice element Offset = 20, Element boundary = Left;

  6. To optimize the search process, specify an additional condition: Do not search for the name if the name Designation has not been detected. See Step 7.2 for details.
  7. Match the FlexiLayout to make sure that the element is detected on the first page of the document.


Sample 4. Step 8: Table element, InvoiceTable element

Now that all the preparations have been made we can search for the Invoice Table field by creating a Table element:

  1. Header of the table. As decided earlier, we will specify column names using already detected auxiliary elements.
  2. Footer of the table. To specify the Footer, we decided to use an already detected required element TextFragment from the InvoiceFooter group, which identifies the beginning of the final part. We described this element as the closest to the bottom of the table.
  3. Search area for the table. We can limit the search area on the right using the name of the last Sales column, which we do not need for any other purposes.

To create an InvoiceTable element:

  1. In the SearchElements tree, create and element of typeTable and name it InvoiceTable.
  2. Click the Columns tab
  3. Click "…" to select the previously created (see Step 3) InvoiceTable block as the block to search
  4. Specify the search parameters for the table columns:

    4.1. In the list of columns, select Reference and click the Properties… button.
    For the name of this column, we will use the previously deselected TableHeader.kwReference element. To use it, select Use found element as column name, then click "…" and select TableHeader.kwReference.

    4.2. In the list of columns, select Designation and click the Properties… button.
    For the name of this column, we will use the previously deselected TableHeader.kwDesignation element.

    4.3. In the list of columns, select Unit and click the Properties… button.
    For the name of this column, we will use the previously deselected TableHeader.kwUnit element.

    4.4. In the list of columns, select Quantity and click the Properties… button.
    For the name of this column, we will use the previously deselected TableHeader.kwQuantity element.

    4.5. In the list of columns, select UnitPrice and click the Properties… button.
    For the name of this column, we will use the previously deselected TableHeader.kwUnitPrice element.

    4.6. In the list of columns, select Total and click the Properties… button.
    For the name of this column, we will use the previously deselected TableHeader.kwTotal element.
  5. Click the Order tab.
  6. Since the columns we are looking for may be separated from one another by other columns (e.g. ExtraQtyTag), but their order is always fixed (first Designation, next Unit Price, next Total), select Rules for column order, click "Add…", and add the columns in the following order: Designation << Unit Price << Total.
Show me

  7. Click the Header tab. We need the Header of the table, but we do not need to impose any additional constraints, so keep the default values.
  8. Click the Footer tab. We will use the previously detected element InvoiceFooter.TextFragment for the final part of the table. Select the Use found element as footer option, click "…," and then select the InvoiceFooter.TextFragment element.
Show me

  9. Click the Rows tab.
  10. Since the cells in some of the columns may contain multiple lines, we need to specify master columns for line separation. Select Use master columns to detect rows.
    First specify the Total column, as this column always contains data and for each table record this column has one line of data. In case this column is no detected on the image, specify the Unit Price and Quantity columns as the next line separation option. Use the "…" button to select these columns.
Show me

  11. Select the Relations tab. Since the table columns we are interested in are located to the left of the name of the Sales column, add the following search constraints:

Left of the TableHeader.kwSales element, Offset = 0;

Note: For poor quality images (e.g. there is noise between the body and footer of the table, or there is no header or footer) you may whish to specify upper and lower table limits. In this case, we can use the kwDesignation element as an upper limit and the TextFragment element as the lower limit. On the Relations tab, add the following search constraints:

Below the upper boundary of the kwDesignation element, Offset = -50, Element boundary = Top;
Above the TextFragment element, Offset = -50; Element boundary = Bottom;

  12. Match the FlexiLayout with the test images.
    You will notice that the program correctly detects the table element on all the images, but on some of the images the Quantity column includes redundant text from the preceding column.
    To separate the good data in the Quantity column from irrelevant data, we will specify the type of context for this column.
  13. Open the Properties dialog box of the table element InvoiceTable.
    Click the Columns tab, open the Properties… dialog box of the Quantity column, and select the Check content type option. In Type of column content, select Number.
Show me

  14. Now if you match the FlexiLayout on the images, you will see that the Quantity contains only digits, which is what we need.
  15. Similarly, specify the Currency context for the UnitPrice and Total columns.
  16. To specify the location of the InvoiceTable block, select the Source element option. Click "..." and specify InvoiceTable as the source element.


Sample 4. Step 9: TotalAmount field, SumGroup Group element

Once you have analyzed the test documents, you will notice that the Total Amount field occurs only together with the field name on the last page below the table. Additionally, the field itself is either on the same level as the field name or below the name. Since the field contains only one line, we will create a Character String element to search for it.

To specify the settings common to the field and its name, we will use a Group element.

To create a SumGroup element:

  1. Create an element of type Group and name it SumGroup.
  2. Click the Advanced tab and in the Advanced pre-search relations field, specify additional search constraints for all the elements in the group: Search for the object below the last detected table. In the FlexiLayout language, this constraint can be written as follows:

If not InvoiceTable.LastSubTable.Body.IsNull then
Below: InvoiceTable.LastSubTable.Body.Rect.Bottom;

To search for the keywords in the TotalAmount field, use a SumGroup.kwTotal element of type Static Text. See Step 9.1 for detailed instructions.

To search for the one-line TotalAmount field, use a SumGroup. TotalAmount element of type Character String. See Step 9.2 for detailed instructions.


Sample 4. Step 9.1: Total Amount name, kwTotal element

This field name occurs on the images as "Total Chf," "Carried Over," or "Total." It is located below the table (this constraint has already been specifies for the SumGroup element) and always occurs on the last page.

To create a kwTotal element:

  1. In the SumGroup element, create an element of typeStatic Text and name it kwTotal.
  2. Click the Static Text. tab.
  3. In the Search text field, specify the text to search: TotalChf|CarriedOver|Total.
  4. Set Max error percentage to 20.
  5. Click the Search Constraints tab and limit the search area to the last page:
  • Select Absolute search area constraints
  • In the Pages field, select Last from the drop-down list
  • Do not select any other options
  • Click the Add button. The search area will appear in the Search areas list
Show me

  6. Click the Advanced tab.
  7. Among the many detected elements that contain the specified text, we must select the one that is located closest to the bottom boundary of the table. This location allows us to influence the quality of the hypotheses. In Advanced post-search relations specify additional parameters for the hypothesis: If a non-null hypothesis has been generated, calculate the distance between the upper boundary of the detected element and the bottom boundary of the last table detected in the document. Then check if this distance belongs to the specified fuzzy interval. In the FlexiLayout language, this condition can be written as follows:

If not IsNull then
{ FuzzyQuality: Top - InvoiceTable.LastSubTable.Body.Rect.Bottom, {0,0,0, 50000}*dt;
}
//This check means that the greater the distance between the boundaries, the greater the penalty coefficient.


Sample 4. Step 9.2: Total Amount field, TotalAmount element

We will search for the TotalAmount field both to the right of and below its name.

To create a TotalAmount field:

  1. In the SumGroup element, create an element of typeCharacter String and name it TotalAmount.
  2. Click the Character String tab.
  3. Specify the alphabet:
    ',-.0123456789OSZosz
  4. Set Percentage of non-alphabet characters to 30%.
  5. In the Character count field, specify the following fuzzy interval {-1, 1, 20, INF}, which assesses the string length. We assume that all the possible values will fall into the interval of 1 to 20 characters. Any hypothesis outside this interval will be penalized
  6. Do not impose any additional constraints and keep the default settings.
  7. Click the Search Constraints tab and exclude the region of the hypothesis for the kwTotal element from the search area.
  8. Click the Advanced tab.
  9. In Advanced pre-search relations specify additional search conditions: If the kwTotal name has been detected, specify the search area as an array of rectangles: one rectangle to the right of the field name and one rectangle below the field name with some offset. Otherwise, do not search for the image object. In the FlexiLayout language, this condition can be written as follows:

If not kwTotal.IsNull Then // If the field name kwTotal has been
    detected
{
WholeWordMOde: true;
MaxGapInLine: 30dt;

RectArray DataRegion;

Let r1= Rect (kwTotal.Rect.Right, kwTotal.Rect.Top -20dt, kwTotal.Rect.Right +
1800dt, kwTotal.Rect.Bottom + 50dt);
// Limits the search area to a rectangle
    to the right of the field name.
Let r2 = Rect (kwTotal.Rect.Left - 100dt, kwTotal.Rect.Bottom,
kwTotal.Rect.Right + 100dt, kwTotal.Rect.Bottom + 200dt);
//  Limits the
    search area to a rectangle below the field name.

DataRegion = RectArray (r1);
DataRegion.Add (r2);

RestrictSearchArea (DataRegion);
}
else Dontfind(); // Otherwise, do not search for the object.

  10. The search area of the field value is limited to two rectangles, one to the right of and the other below the field name. If the field value is located to the right of the field name, there is some text below the field name on most of the images. Since on most of the images this redundant text is included into the search area of the TotalAmount field, the program will create a hypothesis for this text. To influence the quality of this hypothesis (i.e. to lower its quality), in Advanced post-search relations specify an additional check: The lower the field value below the field name, the greater the penalty. In the FlexiLayout language, this check can be written as follows:

If not IsNull then
{FuzzyQuality: 400dt - width, {-50000,0,0, 50000}*dt;
//Hypotheses for elements with region 400 dots wide will have the maximum quality
if width < 50dt then Quality: 0;
// Elements less than 50 dots are not considered
if Top > kwTotal.Rect.Top then
{ FuzzyQuality: Top - kwTotal.Rect.Top, {0,0,0, 20000}*dt;
}
}
//This check means that the higher the difference, the greater the penalty.

Note: A 2D coordinate system is used to describe the locations of objects on the page and distances between them. The (0, 0) point is located in the top left corner of the image. The horizontal axis is directed left to right, the vertical axis is directed top down.

  11. Match the FlexiLayout on the images to make sure that the program can reliably detect the element on all the images where it occurs.
  12. Specify the location of the TotalAmount block as the rectangular region of the TotalAmount element expanded by 5 dots vertically and horizontally. To do this, select Expression and specify the following expression:

Rect outputRect;
outputRect = SumGroup.TotalAmount.Rect;
IsNull = SumGroup.TotalAmount.IsNull;
OutputRegion = outputRect;
OutputRegion.Inflate (5dt, 5dt);


Sample 4. Step 10: Company field, CompanyGroup Group element, Company element

Once you have analyzed the images, you will notice that the Company field is always located in the first third of the first page of each document.

To search for the Company field, use an element of type Static Text which is part of a CompanyGroup element of type Group.

To create a CompanyGroup element, create an element of type Group and name it CompanyGroup. Keep the default settings.

To create a Company element:

  1. In the CompanyGroup element, create an element of type Static TextStatic Text and name it Company.
  2. Click the Static Text tab.
  3. Select Search text from file and specify the path to the Companies.txt file.
    Note: The Companies.txt files is located in
    <disk name>:\\\Documents and Settings\All Users\Application Data\ABBYY\FlexiCapture\9.0\Samples \FlexiLayout Studio\Invoice\Dict.
Show me

  4. Click the Advanced tab.
  5. In Advanced pre-search relations, specify an additional search constraint: Search for the image object in the first third of the first page of the document. In the FlexiLayout language, this constraint can be written as follows:

Above: Page(1).RectGlobal.Top + Page(1).RectGlobal.Height/3;

  6. Match the FlexiLayout to make sure that it reliably detects the element on all the images where it occurs.
  7. When you review the matching results, you will notice that the program failed to find the name of the comapny on some of the documents. This is becuase on some of the documents the text is written on two lines, whereas we specified one-line text in the properties of the element. To correct this, make the following changes
  • Open the Companies.txt file and specify the company name as YOUR SERVICE with spaces. This means that the program should look for a phrase which need not be written on one line.
  • Open the Properties dialog box of the Company element and click the Static Text tab.
  • Select Permit multiple lines to specify that the phrase can be written on more than one line.
  • Set Line break penalty to 1. This will retain the quality of the generated hypothesis even if the text is written on more than one line. A smaller value would mean that the hypothesis should be penalized.
  8. Match the FlexiLayout to maker sure that the program reliably detects the element on the test images.
  9. Specify the location of the Company block as the rectangular region of the Company element expanded by 5 dots vertically and horizontally. To do this, select Expression and specify the following expression:

Rect outputRect;
outputRect = CompanyGroup.Company.Rect;
IsNull = CompanyGroup.Company.IsNull;
OutputRegion = outputRect;
OutputRegion.Inflate (5dt, 5dt);


Sample 4. Step 11: Exporting the FlexiLayout and adding it to a FlexiCapture template

You can export your FlexiLayout into an *.afl file and add it to an ABBYY FlexiCapture template.

Note: For detailed instructions, see Sample 1, Step 21 and Step 22.


Technical support

Should you have any questions regarding the way in which ABBYY FlexiLayout Studio works, first of all consult the documentation supplied with the software (Help). You may also browse the technical support section on our website www.abbyy.com. You may find the answer to your question there.

Our technical support service experts will need the following information to answer your question competently:

  • your first and last name
  • your organization name
  • your telephone number (or fax, or e-mail)
  • the serial number of your FlexiCapture package
  • build number (see Help/About…/Build)
  • general description of your problem and the full error message text (if there was one)
  • your computer and processor type
  • the version of your Windows operating system

You may supply us with any other information you consider important.

You can get some information automatically by clicking the System Info… button in the About ABBYY FlexiLayout Studio 9.0 dialog box (menu Help).

Important!
Only registered users are eligible for free technical support. You can register your copy of the application on our website.

ABBYY Offices


Selecting table columns

Option | Description
Available Columns list | Shows the list of columns of the Table element.
Selected Columns list | Shows the list of selected columns.
 | Adds the selected column to the Selected Columns list.
 | Adds all the selected columns to the Selected Columns list.
 | Removes a column form the Selected Columns list.
 | Removes all the columns from the Selected Columns list.
 | Moves columns up in the Selected Columns list.
 | Moves columns down in the Selected Columns list.

More

Order of table columns

Table rows


Add Relation dialog box

Field | Description
Relation The element's location relative to other elements:
  • Leftof
  • Rightof
  • Above
  • Below
Reference element | The full name of the reference element.
Element boundary Selects the boundary of the element's region relative to which the half-plane (i.e. the search area) obtained in Relation must be moved:
  • <whole>
  • left
  • right
  • top
  • bottom
Offset | The distance by which the half-plane obtained in Relation must be moved. Offset may be specified as a positive or a negative number. In the case of Rightof and Leftof constraints, the half-plane is moved horizontally. In the case of Above and Below constraints, the half-plane is moved vertically.
Select reference element | Selects a reference element in the tree of elements.


Dialog box: Image Properties

The Image Tab in the Properties Dialog

Displays the open image information. There may be several images for a batch page: if you scan color or gray images, FlexiLayout Studio creates its black& white copy and uses the latter for recognition.

Option

Description
Black and White Image group
Width | Image width in pixels.
Height | Image height in pixels.
Resolution | Image resolution in dpi.
Image type | Specifies the type of the black&white image.
Color or Gray Image group
Width | Image width in pixels.
Height | Image height in pixels.
Resolution | Image resolution in dpi.
Image type | Specifies the image type (actual).
Source Image group
Resolution | Image resolution in dpi.
File type | Specifies the file type (actual).


ABBYY Offices

ABBYY Russia | Phone: +7 495 783 3700 Fax: +7 495 783 2663 Mailing address: Russia, 127273, Moscow, P.O. box 32, ABBYY Address of business: Moscow, ul. Otradnaya 2B, str. 6, Otradny Business Centre E-mail: sales@abbyy.ru Technical support: support@abbyy.ru Web: http://www.abbyy.ru MAP
ABBYY USA | Tel.: +1 408-457-9777 Fax: +1 408-457-9778 Address: 880 North McCarthy Blvd., Suite #220 Milpitas, CA 95035, USA E-mail: sales@abbyyusa.com Technical support: support@abbyyusa.com Web: http://www.abbyy.com
ABBYY Ukraine | Phone: +380 44 490 9999 Fax: +380 44 490 9461 Address: P.O. Box 23, 02002 Kiev, Ukraine E-mail: forms@abbyy.ua Support phone: +380 44 490 9463 Support e-mail: formsupport@abbyy.ua Web: http://www.abbyy.ua
ABBYY Europe GmbH | Phone: +49 (0)89 511 159 0 Fax: +49 89 (0)511 159 59 Address: Elsenheimerstraße 49, 80687 Munich, Germany E-mail: sales_eu@abbyy.com Support e-mail: support_eu@abbyy.com Web: http://www.abbyy.com http://www.abbyy.de http://www.france.abbyy.com
ABBYY UK Ltd. | Phone:+0870 600 0231 Fax: +01344 392 611 Address: Abbey House, Grenville Place, Bracknell RG12 1BP, United Kingdom E-mail: sales_UK@abbyy.com Support E-mail: support_eu@abbyy.com Web: http://www.abbyy.co.uk
ABBYY Japan | Phone:+81-42-795-1901 Fax: +81-42-795-1901 Address: 658-1 Tsuruma, Machida-shi, Tokyo 194-8510 E-mail: sales@abbyyusa.com Support E-mail: support@abbyyusa.com Web: http://www.abbyy.com
ABBYY Taiwan | Phone:+886-2-2655-0556 Fax: +886-2-2655-2339 Address: Room #524, 5Fl, Building E, No.19-11, Sanchong road, Nangang District, Taipei 115, Taiwan, R.O.C. E-mail: sales@abbyyusa.com Support E-mail: support@abbyyusa.com Web: http://www.abbyy.com


Glossary

A

ABBYY FlexiLayout™ Studio

ABBYY FlexiLayout Studio is an application for creating formalized descriptions (FlexiLayouts) of semi-structured documents. The descriptions are then used by a forms processing application to capture data from the described documents.

layout alternative

A set of elements which describes a document subtype.

B

block

An area on a form image which outlines the possible location of a field.

building a FlexiLayout

When you build a FlexiLayout, FlexiLayout Studio checks the properties and relations you specified in the FlexiLayout for correctness.

C

classifier

A project in FlexiLayout Studio intended for the preliminary identification of the pages and selecting the appropriate FlexiLayout or layout alternative for them.

D

dot (dt)

An abbreviation of document unit, equals 1/300 of an inch. A unit of measurement used to measure distances on an image. Does not depend on resolution. For a 300 dpi image, a distance of 1 dot equals 1 pixel.
Note: ABBYY FlexiLayout Studio 9.0 allows you to select a unit of measurement to be used for all search constraints specified in the Properties dialog boxes of the elements. See Units of measurement for details. When specifying search constraints in the FlexiLayout language (the Advanced tab of the Properties dialog box), other units of measurement can also be used: cm, mm, inch, pt (see Coordinates and units of measurement). All these units of measurement also do not depend on the resolution of your images, allowing you to match one and the same FlexiLayout with images scanned at different resolutions.

E

element

A description of an image object which contains information about the type of the object, its properties, search area and location in relation to other objects.

H

hypothesis

An assumption made by the program that the object(s) detected on the image correspond(s) to the element of the FlexiLayout, i.e. meet(s) the search constraints and properties specified for the element.

M

matching a FlexiLayout with an image

A process of looking on the image for the elements and blocks described in the FlexiLayout.

multi-page sheet

The multitude of all pages in a document. a multi-page sheet is created by joining the pages of a document top down, without gaps or joints, with the left edge of all pages located on the same axis that goes through the point (0,0). The sequence of the pages in the sheet depends on their order in the batch..

Two coordinate systems are used – global (goes through the entire document) and local (bound to a particular page. The only difference between the global and local coordinate systems is that the global system has parallel shifts, each page having its own shift.

N

null hypothesis

A hypothesis formulated by the program if it fails to find any objects corresponding to an optional element. The quality of the null hypothesis is set by the user when specifying the element’s properties.

O

optional element

An element that need not be present on the image. If the program fails to find an optional element, it will formulate a null hypothesis and continue matching the FlexiLayout. The quality of the null hypothesis is set by the user.

P

pre-recognition

The preliminary recognition of the image performed by the program during which it tries to detect elementary objects on the image.

prohibited element

An element which may not occur on the image. A chain of hypotheses that contains a prohibited element is discarded.

R

reference layout

Manually selected blocks on the image to be used as a "model" layout.

region

An area on an image which consists of several rectangles. The bottom of one rectangle is part of the top of another rectangle.

required element

An element that must be present on the image. If the program fails to find a required element, it stops matching the FlexiLayout.

S

search area

An area on a form image where the program will look for objects described by the corresponding FlexiLayout element. Search areas are specified by the user in the Properties dialog box.


Glossary

A B C D E H M N O P R S