✎ NOTE
User words and dictionaries are no longer supported in the LEADTOOLS OCR Module - OmniPage Engine.
#include "ltdoc2.h"
L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2SetUserDictionary(hDoc, pUDOpts, bCreateUD)
Sets the User dictionary and its default section for the checking subsystem.
Handle to the OCR document.
Pointer to the USERDICTIONARY2 structure, which contains the User dictionary to be set.
Flag that determines function behavior. Possible values are:
Value | Meaning |
---|---|
TRUE | Create a new dictionary or disable an existing one. |
FALSE | Set the User dictionary to use the dictionary set in the pUDOpts parameter. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function specifies a User dictionary and its default section for the checking subsystem.
This function can also be used to create a new, empty User dictionary in memory.
To disable a previously enabled User dictionary, pass TRUE for bCreateUD when calling L_Doc2SetUserDictionary.
To create a new, empty User dictionary, pass TRUE for bCreateUD.
If you save a User dictionary by calling this function with bCreateUD set to FALSE the User dictionary is saved to the file specified in pUDOpts. To set the User dictionary to use a file, call the L_Doc2SetUserDictionary function with the name of the file that contains the User dictionary set in the pUDOpts parameter of this function and pass FALSE for the bCreateUD parameter.
Required DLLs and Libraries
L_INT Doc2SetUserDictionaryExample(L_HDOC2 hDoc)
{
L_INT nRet;
USERDICTIONARY2 UDict;
UDict.uStructSize = sizeof(USERDICTIONARY2);
UDict.pszFileName = NULL;
UDict.pszDefSection = NULL;
// creates new user dictionary in memory
nRet = L_Doc2SetUserDictionary(hDoc, &UDict, TRUE);
if (nRet == SUCCESS)
{
L_CHAR * pszSectName = "cities";
L_WCHAR * pwcItem1 = L"Peabody";
L_WCHAR * pwcItem2 = L"Budapest";
nRet = L_Doc2AddItemToUserDictionary(hDoc, pszSectName, pwcItem1, DOC2_USER_DICT_LITERAL);
if(nRet != SUCCESS)
return nRet;
nRet = L_Doc2AddItemToUserDictionary(hDoc, pszSectName, pwcItem2, DOC2_USER_DICT_LITERAL);
if(nRet != SUCCESS)
return nRet;
UDict.uStructSize = sizeof(USERDICTIONARY2);
UDict.pszFileName = MAKE_IMAGE_PATH(TEXT("USERDIC1.DIC"));
UDict.pszDefSection = pszSectName;
nRet = L_Doc2SetUserDictionary(hDoc, &UDict, FALSE);
if(nRet != SUCCESS)
return nRet;
if (nRet == SUCCESS)
MessageBox(NULL, TEXT("The user dictionary is saved into a file."), TEXT("Notice!"), MB_OK);
else
return nRet;
}
else
return nRet;
return SUCCESS;
}