Dictionary Object (IDictionary Interface)
This object is designed for working with user dictionaries and dictionary extensions. User dictionaries are dictionaries that contain word forms of words of a certain language. Each word form in the dictionary has its own weight that defines its priority when there appear several variants for a word during recognition. The weight may have a set of discrete values. The range of values is from 0 to 100. User dictionaries may be connected to the BaseLanguage object — object representing one base recognition language. Dictionary extensions may exist only for those languages which have standard dictionary support.
A pointer to the Dictionary object interface may be obtained from the CreateNewDictionary, OpenExistingDictionary, or OpenDictionaryExtension methods of the LanguageDatabase object. The OpenExistingDictionary method can open dictionaries created with the help of the CreateNewDictionary method. The OpenDictionaryExtension provides access to the interface of a dictionary extension.
The Edit method displays the Dictionary dialog box that allows a user to edit the dictionary and 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).
|Application||Engine, read-only||Returns the Engine object.|
|Name||BSTR||Stores the name of the dictionary. It is this name that is displayed at the caption of the Dictionary dialog box that is displayed when calling the Edit method. After creation of the Dictionary object this property stores the name of the dictionary file (without path and extension). You may assign it any other value. This property is not saved into the file associated with the dictionary, and should be initialized every time the dictionary is edited.|
|WordsCount||int, read-only||Returns the number of words in the dictionary.|
|AddWord||Adds a word to the dictionary.|
|AddWords||Adds a group of words to the dictionary.|
|DeleteAllWords||Deletes all words from the dictionary.|
|DeleteWord||Deletes a word from the dictionary.|
|DeleteWords||Deletes a group of words from the dictionary.|
|Edit||Displays the Dictionary dialog box that allows a user to edit the dictionary.|
|EnumWords||Returns an object of the EnumDictionaryWords type that allows you to iterate through the words in the dictionary.|
// The sample code creates a user dictionary and assigns it to a base language FREngine.IEngine engine; string dictionaryFileName = "D:\\Sample.amd"; FREngine.IBaseLanguage baseLanguage; // Create new dictionary ILanguageDatabase languageDatabase = Engine.CreateLanguageDatabase(); IDictionary dictionary = languageDatabase.CreateNewDictionary( dictionaryFileName, LanguageIdEnum.LI_EnglishUnitedStates ); dictionary.Name = "SampleUserDictionary"; // Add words to dictionary dictionary.AddWord( "the", 100 ); dictionary.AddWord( "a", 100 ); dictionary.AddWord( "an", 100 ); // Get collection of dictionary descriptions of a base language and remove all items IDictionaryDescriptions dictionaryDescriptions = baseLanguage.DictionaryDescriptions; dictionaryDescriptions.DeleteAll(); // Create user dictionary description and add it to the collection IDictionaryDescription dictionaryDescription = dictionaryDescriptions.AddNew( DictionaryTypeEnum.DT_UserDictionary ); IUserDictionaryDescription userDictionaryDescription = dictionaryDescription.GetAsUserDictionaryDescription(); userDictionaryDescription.FileName = dictionaryFileName;
The object is used in the following code samples: CustomLanguage.