> ## 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.

# Hypotheses for Character String elements

> Character String hypotheses split lines into alphabet fragments: see how embedded hypotheses work, how quality is scored, and the full property reference.

If a regular expression is specified in the properties of an element, FlexiLayout Studio looks for any strings in the search area that meet the conditions in the regular expression. If no regular expression is specified, FlexiLayout Studio uses the user-defined alphabets.

## How lines and fragments are identified

FlexiLayout Studio considers all the text objects that 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 and stop when the maximum length of space (set in the **Max space length** property) is exceeded.

In the resulting lines, FlexiLayout Studio identifies character strings, each of which contains characters from only one of the user-defined alphabets. In the same way, it divides lines into fragments.

## Embedded hypotheses

Next, FlexiLayout Studio formulates a hypothesis for each of the fragments. Depending on whether the **Allow embedded hypotheses** option is selected, hypotheses are formulated in one of two ways.

Suppose FlexiLayout Studio detected three fragments at a previous stage. If the **Allow embedded hypotheses** option is selected, hypotheses are formulated as follows:

```text theme={null}
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, FlexiLayout Studio checks that the percentage of characters of each alphabet does not exceed the value set in the **Percentage of alphabet characters** field. It also checks that the percentage of non-alphabet characters does not exceed the value set in the **Percentage of non-alphabet characters** field. If at least one check fails, no hypothesis is formulated.

If the **Allow embedded hypotheses** option is not selected, the embedded hypotheses in the preceding list are discarded. Embedded hypotheses are those contained within another hypothesis in that list. If the checks succeed for all of the hypotheses, only one hypothesis remains: fragment 1 + fragment 2 + fragment 3.

So, when the **Allow embedded hypotheses** option is not selected, FlexiLayout Studio formulates hypotheses of maximum length that meet all of the conditions. Even though embedded hypotheses are excluded, hypotheses may still intersect. The intersecting part may be a stand-alone character or word, or a string of characters that are part of other hypotheses but for which no separate hypotheses have been formulated. For example, FlexiLayout Studio may formulate two hypotheses (that is, two strings): one ending in a certain word or phrase and another starting with that word or phrase.

Two intersecting hypotheses might look like this:

```text theme={null}
hypothesis 1: fragment 1 + fragment 2
hypothesis 2: fragment 2 + fragment 3
```

## How hypothesis quality is calculated

Once all the possible hypotheses are generated, FlexiLayout Studio calculates the **Pre-search quality** for each. This value estimates 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 depends on three checks:

* Whether the length of the hypothesis in characters falls within the fuzzy interval specified in the **Character count** property
* Whether the length of the total gap in the line falls within the fuzzy interval specified in **TotalGapLength**
* Whether the number of words in the line falls within the fuzzy interval specified in the **Word count** property

The overall quality of a hypothesis is the product of all these qualities.

## Character String hypothesis properties

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

## Related topics

* [Character String](/flexi-capture/fls/template/character-chain)
* [Search area](/flexi-capture/fls/template/search-constraints)
* [Additional search constraints](/flexi-capture/fls/template/advanced-constraints)
