#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.
Handle to the OCR document.
Document ID created by calling L_Doc2CreateDocument.
A zero-based index of the recognized page for which to get the recognized words suggestions.
A zero-based index of the word to get its recognized alternatives/suggestions.
Address of pointer to pointer that represents an array of strings to be allocated and updated with the available word's suggestions.
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.
✅ IMPORTANT
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
L_INT Doc2GetWordSuggestionsExampleExt(L_HDOC2 hDoc, L_INT nDocId)
{
L_INT nRet;
RECOGNIZEOPTS2 RecogOpts;
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;
}