#include "ltdoc2.h"

L_LTDOC2_API L_INT L_Doc2GetWordSuggestionsExt(hDoc, nDocId, nPageIndex, nWordIndex, pppWordSuggestions, plSuggestionsCount)

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


L_HDOC2 hDoc

Handle to the OCR document.

L_INT nDocId

Document ID created by calling L_Doc2CreateDocument.

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.


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


Be sure to call L_Doc2GetRecognizedWords / L_Doc2GetRecognizedWordsExt before calling L_Doc2GetWordSuggestionsExt.

L_Doc2GetWordSuggestionsExt obtains an array of recognized alternative words for the specified word index (if any are available).

L_Doc2GetWordSuggestionsExt obtains the number of alternative word suggestions in plSuggestionsCount.


Be sure to free the memory associated with the pppWordSuggestions parameter when it is no longer needed by calling the L_Doc2FreeWordSuggestions function.

Required DLLs and Libraries

See Also




L_INT Doc2GetWordSuggestionsExampleExt(L_HDOC2 hDoc, L_INT nDocId) 
   L_INT nRet; 
   RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2); 
   RecogOpts.nPageIndexStart = 0; 
   RecogOpts.nPagesCount = 1; 
   RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH; 
   nRet = L_Doc2RecognizeExt (hDoc, nDocId, &RecogOpts, NULL, NULL); 
   if (nRet == SUCCESS) 
      pRECOGWORDS2 pRecogWords = NULL; 
      L_INT nWordsCount = 0; 
      nRet = L_Doc2GetRecognizedWordsExt(hDoc, nDocId, 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_Doc2GetWordSuggestionsExt(hDoc, nDocId, 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.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.