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

# Character String

> Set Character String element properties in the FlexiLayout language: alphabets, regular expressions, quality limits, word counts, and gap constraints.

The **Character String** element supports the following parameters in the FlexiLayout language.

## Character String parameters

| Parameter                                                                                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Void AllowEmbeddedHypotheses( Logic )`                                                                    | See [**Character String**](/flexi-capture/fls/template/character-chain), **Allow embedded hypotheses**.                                                                                                                                                                                                                                                                                                                                                                                         |
| `Void MinQuality( Real )`                                                                                  | Sets the minimum quality of the hypothesis. Hypotheses with a quality lower than this minimum are discarded.                                                                                                                                                                                                                                                                                                                                                                                    |
| `Void MaxNonDefinedCount( Real )`                                                                          | See [**Character String**](/flexi-capture/fls/template/character-chain), **Percentage of non-alphabet characters**.                                                                                                                                                                                                                                                                                                                                                                             |
| `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 the **Element Properties** dialog box, [**Character String**](/flexi-capture/fls/template/character-chain) 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 the **Element Properties** dialog box, [**Character String**](/flexi-capture/fls/template/character-chain) tab, **Detect words by interword space**) and specifies the minimum width of the space to `Distance` (the **Min interword space** parameter).                                                                                                                                                                       |
| `Void WordsCount( Int, Int, Int, Int )`                                                                    | See the **Element Properties** dialog box, [**Character String**](/flexi-capture/fls/template/character-chain) tab, **Words count**.                                                                                                                                                                                                                                                                                                                                                            |
| `Void TotalChainLength( Int, Int, Int, Int )`                                                              | See [**Character String**](/flexi-capture/fls/template/character-chain), **Characters Count**.                                                                                                                                                                                                                                                                                                                                                                                                  |
| `Void TotalGapLength( Distance, Distance, Distance, Distance )`                                            | Specifies the maximum allowed total length of spaces in the string as a [fuzzy interval](/flexi-capture/fls/template/fuzzy-interval). The quality of the hypotheses is assessed based on the total length of the spaces.                                                                                                                                                                                                                                                                        |
| `Void MaxGapInLine( Distance )`                                                                            | Sets the maximum distance between neighboring characters. When generating a hypothesis, FlexiLayout Studio adds characters to the hypothesis as long as the distance between two neighboring characters does not exceed `MaxGapInLine`. See also [**Character String**](/flexi-capture/fls/template/character-chain), **Max space length**.                                                                                                                                                     |
| `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 that do not fit entirely within the left and right boundaries should be included in 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`. Characters that have the specified or smaller part outside the search area are included in the hypothesis.                                                                                                                                                                                                                         |
| `Void MaxYOutsidePart( 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`. Characters that have the specified or smaller part outside the search area are included in the hypothesis.                                                                                                                                                                                                                           |
| `Void AddAlphabet( String alphabet, Real portion, Logic isRestrictionStrong )`                             | Sets the alphabet and the allowed percentage of alphabet characters in the hypothesis. The `isRestrictionStrong` flag specifies whether hypotheses that exceed the permissible percentage of alphabet characters must be considered valid. If the flag is set to `true`, hypotheses that exceed the permissible percentage are discarded. If the flag is set to `false`, excess symbols are considered to belong to no alphabet. The default setting is `true`.                                 |
| `Void RegularExpression( String )`                                                                         | Sets the regular expression defining the text of the hypothesis.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `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 are discarded. The default setting is `false`. **Note.** This property is different from `AllowChoppedWords` 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. For more information, see [Databases and text files in the FlexiLayout language](/flexi-capture/fls/language/bd-textfiles). 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. For more information, see [Databases and text files in the FlexiLayout language](/flexi-capture/fls/language/bd-textfiles). 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](/flexi-capture/fls/template/fuzzy-interval).                                                                                                                                                                                                                                                                                                                                                                                        |
| `Void Height( Distance, Distance, Distance, Distance )`                                                    | The height of the hypothesis specified as a [fuzzy interval](/flexi-capture/fls/template/fuzzy-interval).                                                                                                                                                                                                                                                                                                                                                                                       |
| `Void TrimSymbols( String )`                                                                               | Specifies the characters to be trimmed at the beginning and at the end of a hypothesis.                                                                                                                                                                                                                                                                                                                                                                                                         |
| `Void SimilarSymbolQuality( Real )`                                                                        | Specifies a coefficient by which the quality of a hypothesis should be multiplied if it includes a character from the list of characters that look like those in the alphabet.                                                                                                                                                                                                                                                                                                                  |
| `Void AllowedTextRotations ( TextRotations )`                                                              | Specifies a set of orientations of the recognized text in which an element search is allowed.                                                                                                                                                                                                                                                                                                                                                                                                   |

## Parameter examples

### `AllowEmbeddedHypotheses`

The following code tells FlexiLayout Studio to generate the longest hypothesis.

```text theme={null}
AllowEmbeddedHypotheses (False);
```

### `MinQuality`

The following code tells FlexiLayout Studio to ignore hypotheses whose quality is lower than 0.95.

```text theme={null}
MinQuality: 0.95;
```

### `MaxNonDefinedCount`

The following code tells FlexiLayout Studio that the string may contain up to 30% of characters that do not belong to any of the specified alphabets.

```text theme={null}
MaxNonDefinedCount (0.3);
```

### `TotalChainLength`

The following code tells FlexiLayout Studio to look for a line 5 to 10 characters long.

```text theme={null}
TotalChainLength (4, 5, 10, 11);
```

### `MaxGapInLine`

The following code tells FlexiLayout Studio that the maximum distance between neighboring characters may not exceed 5 mm. Otherwise, a null hypothesis is generated.

```text theme={null}
MaxGapInLine (5mm);
```

### `AddAlphabet`

The following code tells FlexiLayout Studio to add an alphabet consisting of the characters №, #, %, and `*`, whose percentage in the hypothesis may not exceed 10%.

```text theme={null}
AddAlphabet ("№#%*", 0.1, True);
```

<Note>
  You can only add characters that are not part of any of the alphabets specified for the current element.
</Note>

### `RegularExpression`

The following regular expression looks for a string where characters may be arranged in one of two ways: 2 digits, a hyphen (`-`), 1 digit; or the letter `N`, a digit from 1 to 5, a forward slash (`/`), 1 to 3 digits.

```text theme={null}
RegularExpression: ("([0-9]{2}[-][0-9])|([N][1-5][/][0-9]{1-3})");
```

This is equivalent to:

```text theme={null}
RegularExpression: ("([0-9]{2}\"-\"[0-9])|(\"N\"[1-5]\"/\"[0-9]{1-3})");
```
