L_Doc2RemoveItemFromUserDictionary

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2RemoveItemFromUserDictionary(hDoc, pSection, pUDitem, uMask)

L_HDOC2 hDoc;

/* handle to the OCR document */

L_CHAR * pSection;

/* section name */

L_WCHAR * pUDitem;

/* UNICODE string containing the section item to be deleted */

L_UINT32 uMask;

/* mask */

Removes the specified section item from the specified section in the User dictionary.

Parameter

Description

hDoc

Handle to the OCR document.

pSection

Name of the section from which the item should be deleted.

pUDitem

Pointer to a UNICODE string containing the word to be deleted. (The string must be terminated with a double zero.)

uMask

Attribute for the pUDitem to be deleted. Possible values are:

 

Value

Meaning

 

DOC2_USER_DICT_LITERAL

[0x0000] Delete the literal dictionary. This is the default value.

 

DOC2_USER_DICT_REGULAR_EXPRESSION

[0x0001] Delete the regular expression dictionary.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

When the characters to be deleted are contained in the ANSI (1252) Code Page, the easiest way to define the pUDitem string is with a wide-character-string literal, L"characters".

When there are two pUDItems items in the pSection with the same name, but with different attributes, the uMask parameter will determine the item to be deleted.

Deleting the last User dictionary item from a section causes the section to be removed automatically from the User dictionary.

Required DLLs and Libraries

LTDOC2

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_Doc2SetUserDictionary, L_Doc2GetUserDictionary, L_Doc2GetUserDictionaryState, L_Doc2GetUserDictionarySection, L_Doc2GetUserDictionarySectionItem, L_Doc2AddItemToUserDictionary

Topics:

OCR Functions: User Dictionary

 

Working with a Dictionary

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


L_LTDOC2TEX_API L_INT Doc2RemoveItemFromUserDictionaryExample(L_HDOC2 hDoc)
{
   L_INT nRet;
   L_CHAR * pszSectName = "cities";
   L_WCHAR * pwcItem = L"Peabody";

   nRet = L_Doc2RemoveItemFromUserDictionary(hDoc, pszSectName, pwcItem, DOC2_USER_DICT_LITERAL);
   if (nRet == SUCCESS)
   {
      USERDICTIONARY2 UDict;
      UDict.uStructSize = sizeof(USERDICTIONARY2);
      UDict.pszFileName = MAKE_IMAGE_PATH(TEXT("USERDIC1.DIC"));
      UDict.pszDefSection = pszSectName;

      // save the updated dictionary into a file
      nRet = L_Doc2SetUserDictionary(hDoc, &UDict, FALSE);
      if(nRet != SUCCESS)
         return nRet;
   }
   else
      return nRet;
   return SUCCESS;
}