CHMlib Logo Leading Translation Management System for Translation Agencies, Top Translation Management Software for Freelance Translators, Time Tracking Software, Word Count, Character Count and Line Count Software, Computer Assisted Translation Tool for Easy Word Count, Clipboard Character Count Software, User-Friendly Translation Memory Software, Terminology Management Software, Terminology Management Server, Microsoft Glossary Software, Dictionary of Acronyms, Social Network for Translators and Translation Agencies, Acronyms and Abbreviations Search Engine, Russian Translation Lab, Ukrainian Translation Lab.
You are reading help file online using chmlib.com
CrisisHelper - First Aid in Tough Times of World Economic Crisis


The Microsoft.com Speech website Microsoft Speech SDK

SAPI 5.1

ISpPhraseAlt::Commit

ISpPhraseAlt::Commit replaces a section of the parent phrase to which the alternate corresponds.

HRESULT  Commit  ( void );

Parameters

None

Return values

Value Description
S_OK Function completed successfully.
SPERR_NOT_FOUND The alternate object is not related to a valid parent phrase object.

Remarks

After an alternate has been committed, the parent phrase will be modified to reflect the substitution.

Upon committing the alternate phrase, the SR engine also has the ability to update its language model to improve future recognitions of the same or similar phrases (see ISpSRAlternates::Commit).

Example

The following code snippet illustrates the use ISpPhraseAlt::Commit to commit an alternate phrase.

    HRESULT hr = S_OK;

    // ... obtain a recognition result object from the recognizer...

    // get the recognized phrase object
    hr = cpRecoResult->GetPhrase(&pPhrase);
    // Check hr

    // get the phrase's text
    hr = pPhrase->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &pwszText, NULL);
    // Check hr

    // ... check the phrase's text... assume the phrase isn't a correct recognition

    // setup MY_MAX_ALTERNATES phrase alternate objects 
    CComPtr<ISpPhraseAlt>   pcpPhrase[MY_MAX_ALTERNATES];
    ULONG ulCount;

    // get the top MY_MAX_ALTERNATES alternates to the entire recognized phrase
    hr = cpRecoResult->GetAlternates(pPhrase->Rule.ulFirstElement,
                                     pPhrase->Rule.ulCountOfElements, 
                                     MY_MAX_ALTERNATES,
                                     pcpPhraseAlt,
                                     &ulCount);
    // Check hr

    // check each alternate in order of highest likelihood
    for (int i = 0; i < ulCount; i++) {
         hr = pcpPhraseAlt[i]->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &pwszAlternate, NULL);
         // Check hr

         // ... check if this alternate is more appropriate ...

         // if it is more appropriate, then commit the alternate
         if (fMoreAppropriate) {
             hr = pcpPhraseAlt[i]->Commit();
             // Check hr
         }

         // free the alternate text
         if (pwszAlternate) ::CoTaskMemFree(pwszAlternate);
         
    }

    // free the initial phrase object
    if (pPhrase) ::CoTaskMemFree(pPhrase);


You are reading help file online using chmlib.com

If you want your help file to be removed or added please send e-mail to chmlibcom@gmail.com
Partner sites: Logo Design, Simple Anti-Crisis Accounting Software, Voice Search for Web