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

# Setting Up Recognition Languages

One of the main recognition parameters is the language to be used for recognition. The recognition languages can be specified for the entire document and for individual data fields.

## Recognition language for the entire document

The recognition language for the entire document is specified in the Document Definition. To specify the recognition language for a document, use the [**IDocumentDefinition::DefaultLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/documentdefinition.md#defaultlanguage) property.

The recognition language which is used for the entire document is usually one of the predefined languages, or a group of such languages. Predefined languages are the languages supported in ABBYY FlexiCapture SDK by default. The collection of available predefined languages represented by the [**PredefinedLanguages**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/predefinedlanguages.md) object is accessible via the **PredefinedLanguages** property of the [**Engine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine.md) object. It is a collection of [**Language**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/language.md) objects.

To change the language used for recognition of a document, do the following:

1. Find the necessary predefined language in the collection of available languages. Use the [**FindLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/predefinedlanguages-findlanguage.md) method of the **PredefinedLanguages** subobject of the **Engine** object. The predefined languages are identified by their internal names. For the list of the internal names of the predefined languages see [Predefined Languages in ABBYY FlexiCapture SDK](https://docs.abbyy.com/flexi-capture/sdk/specifications/langnames.md).
2. Assign the received **Language** object to the **IDocumentDefinition::DefaultLanguage** property.

> [accordion] C++ (COM) code
>
> ```cpp theme={null}
> FCEngine::IEnginePtr Engine;
> // We assume we have opened a project and obtained one of its Document Definitions
> FCEngine::IDocumentDefinitionPtr documentDefinition;
> // Set the default language
> FCEngine::ILanguagePtr language = Engine->PredefinedLanguages->FindLanguage(L"English");
> documentDefinition->DefaultLanguage = language;
> ```

Languages may be simple (e.g. English, Russian), or compound (composed of several simple languages). See the **Type** property of the [**Language**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/language.md) object. The **Language** object exposes methods which cast it to a type-specific interface and thereby provide access to the extended attributes of a language of specific type.

## Changing the recognition language for individual fields

The recognition language can be changed for an individual field by setting the recognition parameters of this field. The [**IFieldDefinition::RecognitionParams**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fielddefinition.md#recognitionparams) property provides access to the parameters of field recognition. The recognition language can be set for text fields only (**IFieldDefinition::Type** = [FT\_TextField](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldtypeenum.md)).

To tune the recognition parameters of a text field, receive the [**RecognitionParams**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/recognitionparams.md) object as a [**TextRecognitionParams**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/textrecognitionparams.md) object. (Use the [**AsTextParams**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/recognitionparams-astextparams.md) method of the **RecognitionParams** object.)

> [accordion] To use a group of languages for recognition...
>
> 1. Create a group language with the [**CreateEmbeddedLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/textrecognitionparams-createembeddedlanguage.md) method of the **TextRecognitionParams** object. Pass an [LT\_Group](https://docs.abbyy.com/flexi-capture/sdk/api-reference/languagetypeenum.md) constant as the first parameter of this method.
> 2. Obtain the created object as a [**GroupLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/grouplanguage.md) object using the [**AsGroupLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/language-asgrouplanguage.md) method of the **Language** object.
> 3. Add languages to this group language. Use the [**Add**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/grouplanguage-add.md) method of the **GroupLanguage** object.
> 4. Assign the created language to the **Language** property of the **TextRecognitionParams** object.
>
> ### C++ (COM)
>
> ```cpp theme={null}
> FCEngine::IEnginePtr Engine;
> // We assume we have opened a project and obtained one of its Document Definitions
> FCEngine::IDocumentDefinitionPtr documentDefinition;
> // Find the necessary field definition
> FCEngine::IFieldDefinitionPtr fieldDefinition;
> ...
> // Create a group language
> FCEngine::ITextRecognitionParamsPtr textParams = fieldDefinition->RecognitionParams->AsTextParams();
> FCEngine::ILanguagePtr language = textParams->CreateEmbeddedLanguage(FCEngine::LT_Group, 0);
> // Add languages to the group language
> language->AsGroupLanguage()->Add (Engine->PredefinedLanguages->FindLanguage(L"English"));
> language->AsGroupLanguage()->Add (Engine->PredefinedLanguages->FindLanguage(L"Russian"));
> // Use the created language for recognition
> textParams->Language = language;
> ```

> [accordion] To use regular expressions for recognition...
>
> 1. Create a simple language with the [**CreateEmbeddedLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/textrecognitionparams-createembeddedlanguage.md) method of the **TextRecognitionParams** object. Pass an [LT\_Simple](https://docs.abbyy.com/flexi-capture/sdk/api-reference/languagetypeenum.md) constant as the first parameter of this method.
> 2. Obtain the created object as a [**SimpleLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/simplelanguage.md) object using the [**AsSimpleLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/language-assimplelanguage.md) method of the **Language** object.
> 3. The created simple language is empty. You must specify its alphabet. Pass the set of alphabet letters to the [**LetterSet**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/simplelanguage-letterset.md) property of the **SimpleLanguage** object with an [LLS\_Alphabet](https://docs.abbyy.com/flexi-capture/sdk/api-reference/languagelettersetenum.md) constant as a parameter.
> 4. Set the regular expression via the **RegularExpression** property of the **SimpleLanguage** object. The semantics of ABBYY FlexiCapture regular expressions is described in [Working with Regular Expressions](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/regularexpressionsemantics.md).
> 5. Assign the created language to the **Language** property of the **TextRecognitionParams** object.
>
> ### C++ (COM)
>
> ```cpp theme={null}
> FCEngine::IEnginePtr Engine;
> // We assume we have opened a project and obtained one of its Document Definitions
> FCEngine::IDocumentDefinitionPtr documentDefinition;
> // Find the necessary field definition
> FCEngine::IFieldDefinitionPtr fieldDefinition;
> ...
> // Create a simple language
> FCEngine::ITextRecognitionParamsPtr textParams = fieldDefinition->RecognitionParams->AsTextParams();
> FCEngine::ILanguagePtr language = textParams->CreateEmbeddedLanguage(FCEngine::LT_Simple, 0);
> // Set the alphabet and regular expression
> language->AsSimpleLanguage()->put_LetterSet(FCEngine::LLS_Alphabet,L"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
> language->AsSimpleLanguage()->put_RegularExpression(L"[A-Z]{1-}");
> // Use the created language for recognition
> textParams->Language = language;
> ```

> [accordion] To use user dictionaries for recognition...
>
> 1. Create a simple language with the [**CreateEmbeddedLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/textrecognitionparams-createembeddedlanguage.md) method of the **TextRecognitionParams** object. Pass an [LT\_Simple](https://docs.abbyy.com/flexi-capture/sdk/api-reference/languagetypeenum.md) constant as the first parameter of this method. You may create this language on the basis of a predefined language. If you do not use any predefined language as a prototype, you must then set the alphabet of the language.
> 2. Obtain the created object as a [**SimpleLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/simplelanguage.md) object using the [**AsSimpleLanguage**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/language-assimplelanguage.md) method of the **Language** object.
> 3. Set the **UseUserDefinedDictionary** property of the **SimpleLanguage** object to TRUE. You may use both a user dictionary and a predefined dictionary for recognition. If you want to use only a user dictionary, set the **UsePredefinedDictionary** property to FALSE.
> 4. Receive the user dictionary via the **UserDefinedDictionary** property of the **SimpleLanguage** object. The user dictionary is represented by the [**Dictionary**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/dictionary.md) object. With the help of methods and properties of this object you may add words to the dictionary, delete words from it, and load an existing dictionary via the provided user interface.
> 5. Assign the created language to the **Language** property of the **TextRecognitionParams** object.
>
> ### C++ (COM)
>
> ```cpp theme={null}
> FCEngine::IEnginePtr Engine;
> // We assume we have opened a project and obtained one of its Document Definitions
> FCEngine::IDocumentDefinitionPtr documentDefinition;
> // Find the necessary field definition
> FCEngine::IFieldDefinitionPtr fieldDefinition;
> ...
> // Create a simple language
> FCEngine::ITextRecognitionParamsPtr textParams = fieldDefinition->RecognitionParams->AsTextParams();
> FCEngine::ILanguagePtr language = textParams->CreateEmbeddedLanguage(FCEngine::LT_Simple, Engine->PredefinedLanguages->FindLanguage (L"English"));
> // Allow the user dictionary and edit it
> language->AsSimpleLanguage()->UseUserDefinedDictionary = VARIANT_TRUE;
> FCEngine::IDictionaryPtr dictionary = language->AsSimpleLanguage()->UserDefinedDictionary;
> dictionary->AddWord(L"one",100);
> dictionary->AddWord(L"two",100);
> dictionary->AddWord(L"three",100);
> // Use the created language for recognition
> textParams->Language = language;
> ```

> [accordion] To use a special recognition language for a data type...
>
> It is not always convenient to specify the type of field value ([**IFieldDefinition::ValueType**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fielddefinition.md#valuetype)) as this restricts field values. E.g. if a user enters incorrect data into such field, this will produce an error. To avoid specifying some special type of field value, you may:
>
> 1. Create a simple language with the [**CreateEmbeddedLanguageByDataType**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/textrecognitionparams-createembeddedlanguagebydatatype.md) method of the **TextRecognitionParams** object. Pass a [**FieldValueTypeEnum**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldvaluetypeenum.md) constant as the parameter of this method.
> 2. Set the necessary parameters of the created language.
> 3. Assign the created language to the **Language** property of the **TextRecognitionParams** object.
>
> ### C++ (COM)
>
> ```cpp theme={null}
> FCEngine::IEnginePtr Engine;
> // We assume we have opened a project and obtained one of its Document Definitions
> FCEngine::IDocumentDefinitionPtr documentDefinition;
> // Find the necessary field definition
> FCEngine::IFieldDefinitionPtr fieldDefinition;
> ...
> // Create a language for the data type and configure this language
> FCEngine::ITextRecognitionParamsPtr textParams = fieldDefinition->RecognitionParams->AsTextParams();
> FCEngine::ILanguagePtr language = textParams->CreateEmbeddedLanguageByDataType(FCEngine::FVT_DateTime);
> ...
> // Use the created language for recognition
> textParams->Language = language;
> ```

## See also

[**Language**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/language.md)

[**PredefinedLanguages**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/predefinedlanguages.md)
