> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fuzzy interval

> Fuzzy intervals in ABBYY FlexiLayout Studio score hypothesis quality by length: set four boundary values, avoid rigid ranges, and use the visual editor.

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

## How fuzzy intervals work

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`. The quality of the hypothesis depends on where `L` falls relative to the four boundary values.

| String length                                 | Hypothesis quality                                                                |
| --------------------------------------------- | --------------------------------------------------------------------------------- |
| Between `f2` and `f3` (`L >= f2 and L <= f3`) | `1`                                                                               |
| Between `f1` and `f2`                         | Rises in direct proportion from `0` to `1` (`Quality(f1) = 0`, `Quality(f2) = 1`) |
| Between `f3` and `f4`                         | Falls in direct proportion from `1` to `0` (`Quality(f3) = 1`, `Quality(f4) = 0`) |
| Outside `f1` to `f4` (`L < f1 or L > f4`)     | `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.

<Frame>
  <img src="https://mintcdn.com/abbyy/fmgRWFNHKYN2MLSg/images/flexi-capture/fls/Fuzzy_interval.gif?s=fc532bf381c169e80445c27fa714ac66" alt="Diagram of the fuzzy interval quality function, showing hypothesis quality rising from 0 to 1 between f1 and f2, holding at 1 between f2 and f3, and falling from 1 to 0 between f3 and f4." width="293" height="152" data-path="images/flexi-capture/fls/Fuzzy_interval.gif" />
</Frame>

<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.
</Note>

## Guidelines for setting intervals

Make sure that the selected hypothesis has the highest 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, 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 makes the dependence of quality in the range from `0` to `1` less steep, which reduces the penalty.

To also set a lower limit for the length, type an expression on the **Advanced** tab. For example, if the string cannot be shorter than 10 characters and the fuzzy interval for the length is `[-10,20,30,40]`, type `Value.Length >= 10` in the **Advanced post-search relations** pane.

<Frame>
  <img src="https://mintcdn.com/abbyy/fmgRWFNHKYN2MLSg/images/flexi-capture/fls/Fuzzy_interval_I.gif?s=cf40affeda6339dd02cc88d36e34d3b7" alt="Diagram of a fuzzy interval with a negative left boundary, showing a less steep quality curve that reduces the penalty on hypothesis length." width="223" height="85" data-path="images/flexi-capture/fls/Fuzzy_interval_I.gif" />
</Frame>

In general, it is advisable not to set too rigid intervals. This is particularly important when processing images of varying quality. On some images, there may be spaces within letters due to poor quality of the source document or poor scan settings.

In this case the program may interpret one character as several characters, which may drastically reduce the quality of the hypothesis if the fuzzy interval was too rigid. As a result, the program discards a hypothesis that is in essence correct and selects another. For this reason, if you need to select between **Character String** hypotheses by comparing their lengths, specify additional constraints in the **Advanced post-search relations** pane.

## Fuzzy interval visual editor

ABBYY FlexiLayout Studio offers a [visual editor](/flexi-capture/fls/interface/fuzzy-editor) to make specifying fuzzy intervals easier.

Open the fuzzy interval editor in one of the following ways:

* From the **Properties** dialog box of a **Character String** element, on the **Character String** tab, click the browse button (<img src="https://mintcdn.com/abbyy/fmgRWFNHKYN2MLSg/images/flexi-capture/fls/Button_points.gif?s=494881c954b44aa8b446880d31ab4d12" alt="Browse button" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="19" height="18" data-path="images/flexi-capture/fls/Button_points.gif" />).
* From the main menu, select **Tools → Fuzzy Interval Editor**.
