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:
- In the SumGroup element, create an element of type Character String and name it TotalAmount.
- Click the Character String tab.
- Specify the alphabet:
',-.0123456789OSZosz - Set Percentage of non-alphabet characters to 30%.
- 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
- Do not impose any additional constraints and keep the default settings.
- Click the Search Constraints tab and exclude the region of the hypothesis for the kwTotal element from the search area.
- Click the Advanced tab.
- 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. - 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. - Match the FlexiLayout on the images to make sure that the program can reliably detect the element on all the images where it occurs.
- 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);
12.04.2024 18:16:02