L_Doc2GetWordSuggestions

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2GetWordSuggestions(hDoc, nPageIndex, nWordIndex, pppWordSuggestions, plSuggestionsCount)

Gets an array of all available alternatives/suggestions for the recognized words.

Parameters

L_HDOC2 hDoc

Handle to the OCR document.

L_INT nPageIndex

A zero-based index of the recognized page for which to get the recognized words suggestions.

L_INT nWordIndex

A zero-based index of the word to get its recognized alternatives/suggestions.

L_WCHAR *** pppWordSuggestions

Address of pointer to pointer that represents an array of strings to be allocated and updated with the available word's suggestions.

L_INT32 * plSuggestionsCount

Pointer to a variable to be updated with the number of elements in the pppWordSuggestions array.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function obtains an array of recognized alternative words at the specified word index (if any are available).

This function obtains the number of alternative word's suggestions in plSuggestionsCount.

✅ IMPORTANT

You must free the memory associated with pppWordSuggestions parameter when it is no longer needed, by calling the L_Doc2FreeWordSuggestions function.

This function should not be called before calling the L_Doc2GetRecognizedWords / L_Doc2GetRecognizedWordsExt function.

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT Doc2GetWordSuggestionsExample(L_HDOC2 hDoc) 
{ 
   L_INT nRet; 
   RECOGNIZEOPTS2 RecogOpts; 
   RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2); 
   RecogOpts.nPageIndexStart = 0; 
   RecogOpts.nPagesCount = 1; 
   RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH; 
 
   nRet = L_Doc2Recognize (hDoc, &RecogOpts, NULL, NULL); 
   if (nRet == SUCCESS) 
   { 
      pRECOGWORDS2 pRecogWords = NULL; 
      L_INT nWordsCount = 0; 
 
      nRet = L_Doc2GetRecognizedWords(hDoc, 0, &pRecogWords, sizeof(RECOGWORDS2), &nWordsCount); 
      if (nRet == SUCCESS) 
      { 
         for (L_INT32 i=0; i<nWordsCount; i++) 
         { 
            L_WCHAR ** ppWordSuggestions = NULL; 
            L_INT nSuggestionsCount = 0; 
            nRet = L_Doc2GetWordSuggestions(hDoc, 0, i, &ppWordSuggestions, &nSuggestionsCount); 
            if(nRet == SUCCESS && nSuggestionsCount > 0) 
            { 
               L_TCHAR szBuffer[1024]; 
               ZeroMemory(szBuffer, sizeof(szBuffer)); 
 
               wsprintf(szBuffer, TEXT("Word Index: %d\nWord: %s\nSuggestions Count: %d"), i, pRecogWords[i].szWord, nSuggestionsCount); 
               MessageBox(NULL, szBuffer, TEXT("Word Suggestions Count"), MB_OK); 
 
               L_Doc2FreeWordSuggestions(hDoc, &ppWordSuggestions, nSuggestionsCount); 
            } 
         } 
 
         nRet = L_Doc2FreeRecognizedWords(hDoc, &pRecogWords); 
         if(nRet != SUCCESS) 
            return nRet; 
      } 
   } 
   return SUCCESS; 
} 
Help Version 21.0.2021.1.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help