C# samples are applicable only to FRE for Windows.
Dictionary types
Dictionaries may be of several types:Standard dictionary
Standard dictionary
This type of dictionary is already provided for the predefined languages that have built-in dictionary support (see the comments in the list of predefined languages). Additionally, for some languages, there are dictionaries of specialized terms (e.g., medical and law) packed in the .zmd archive. Standard dictionaries are represented by three or four files. They have names that are usually the same as the full or short name of the language and an .amd, .amm, .amt, or .ame extension. Files with .amd, .amm, and .amt extensions are always present. They are stored in the following folders and cannot be changed: Data/ExtendedDictionaries (Linux), Resources/ExtendedDictionaries (macOS), Data\ExtendedDictionaries (Windows).No .ame files are provided with ABBYY FineReader Engine: this is a format for storing a dictionary extension, i.e., words added to the dictionary by the user. You can create a dictionary extension in ABBYY FineReader, where it is called user dictionary, and then copy the created file to the folder mentioned above under the ABBYY FineReader Engine folder (or you may specify the full path to it in ILanguageDatabase::DictionaryExtensionsPath property). ABBYY FineReader stores the extensions of standard dictionaries in %appdata%\ABBYY\FineReader\15\FineReaderShell\UserDictionaries. Dictionary extensions can be edited in ABBYY FineReader Engine using ILanguageDatabase::OpenDictionaryExtension method.This dictionary type is described by the StandardDictionaryDescription object.
User dictionary
User dictionary
Can be created using the Dictionary object. The Dictionary object allows you to add and remove words using its methods.In Windows, the Dictionary object also allows you to edit the dictionary with the help of the Dictionary dialog box. This dialog box allows you to import any text file in Windows ANSI and Unicode encoding (the only requirement is that words must be separated by spaces or other non-alphabetic characters).This dictionary type is described by the UserDictionaryDescription object.
The user dictionary in FineReader Engine has .amd file format and can be created for any language. It can take place of the standard dictionary for languages that do not have dictionary support. The user dictionary of ABBYY FineReader is called dictionary extension in FineReader Engine; it is a .ame file and can be created only for the languages with dictionary support, as an extension of standard dictionary for that language.
Regular-expression-based dictionary
Regular-expression-based dictionary
Specifies the rules that define what words are allowed in a language and what words are not allowed.This dictionary type is described by the RegExpDictionaryDescription object.
External dictionary
External dictionary
Allows you to implement your own type of dictionary. This dictionary is represented as the IExternalDictionary interface, which is implemented on the client-side. Guidelines for external dictionary creation you can find in the description of this interface.This dictionary type is described by the ExternalDictionaryDescription object.
Creating a dictionary description
To create dictionary descriptions, the AddNew method of the DictionaryDescriptions object is used. This method returns a reference to the DictionaryDescription object. To obtain a reference to the object describing the corresponding dictionary type, use the GetAsStandardDictionaryDescription, GetAsUserDictionaryDescription, GetAsRegExpDictionaryDescription, GetAsExternalDictionaryDescription methods of the DictionaryDescription object.Dictionary properties
For each dictionary, the identification property of the dictionary must be specified:- For a standard dictionary (StandardDictionaryDescription), specify its LanguageId property, which defines the ID of the language.
- For a user dictionary (UserDictionaryDescription), specify its FileName property, which provides the path to the user dictionary.
- For a regular-expression-based dictionary (RegExpDictionaryDescription), use the SetText method to specify the regular expression. See Working with ABBYY FineReader Engine Regular Expressions.
- For an external dictionary (ExternalDictionaryDescription), use the SetDictionary method to specify the dictionary.
Dictionaries of a recognition language
A text recognition language (the TextLanguage object) can have both dictionaries containing words of the language and dictionaries with prohibited words. The first ones are specified for each basic recognition language of the text language and are accessible via the IBaseLanguage::DictionaryDescriptions property. A base language may have no dictionary attached to it. The prohibiting dictionaries are attached directly to the text recognition language through the ITextLanguage::ProhibitingDictionaries property. If you want only the dictionary words to be allowed during recognition, set the IBaseLanguage::AllowWordsFromDictionaryOnly property to TRUE. In this case, a word that is not found in the dictionary of the base language can appear in the recognized text only if ABBYY FineReader Engine found no dictionary variants.How to attach a dictionary to a recognition language
- Create a TextLanguage object using one of the available methods (e.g., the CreateTextLanguage method of the LanguageDatabase object).
- Obtain the collection of base languages of the new text language (use the BaseLanguages property).
- Create a new BaseLanguage object and add it to a collection of base languages.
- Obtain the collection of dictionary descriptions of the new base language (the DictionaryDescriptions property).
- Create a dictionary description and add it to the collection of dictionary descriptions of the base language. Use the AddNew method of the DictionaryDescriptions collection.
You can create several dictionaries of different types and add them to the DictionaryDescriptions collection of one base recognition language.
- [Optional] Specify the weight of the created dictionary.
- Specify the identification property of the dictionary: the LanguageId property for a standard dictionary, the FileName property for a user dictionary, call the IRegExpDictionaryDescription::SetText method for a regular-expression-based dictionary or call the IExternalDictionaryDescription::SetDictionary method for an external dictionary.
- [Optional] Specify other properties of the BaseLanguage object.
- [Optional] Set the prohibiting dictionaries using the ProhibitingDictionaries property of the TextLanguage object.
- Assign the created TextLanguage object to the TextLanguage property of the RecognizerParams object.
C++ (COM) code
C++ (COM) code
C# code
C# code
