lxaGetUserEntityMarkup

<< lxaGetNamedEntityMarkup | Back to Salience 6 C API Index | lxaGetPOSMarkup >>

Summary

Provides a structured representation of the document with annotation of user-defined entities identified within the text. The SalienceDocument structure contains a set of SalienceSentence structures, which contain SalienceWord structures that contain information about the entities within the document.
The acConfigurationID parameter specifies the configuration for the results. Configurations are defined using the method lxaAddSalienceConfiguration.
After use, you should free allocated memory by calling lxaFreeDocument.

Syntax

int lxaGetUserEntityMarkup(SalienceSession *pSession,
                           SalienceDocument *pDocument,
                           const char *acConfigurationID);

Parameters

pSession Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession
pDocument Pointer to a SalienceDocument structure that will get filled in by the call
acConfigurationID Character string specifying the configuration for the results, blank for the default configuration

Returns

This method returns an integer return code.

Example

     std::string sMarkup = "";
     int nPrimaryId = -1;
     int nSecondaryId = -1;
     std::string sType = "";

     SalienceDocument oDocument;
     lxaGetUserEntityMarkup(pSession,&oDocument);

     for(size_t i = 0; i < oDocument.nSentenceCount; i++)
     {
          for(size_t j = 0; j < oDocument.pSentences[i].nLength; j++)
          {
               if(oDocument.pSentences[i].pTokens[j].nId == -1)
               {
                    if(nPrimaryId != -1)
                    {
                         sMarkup += "</";
                         sMarkup += sType;
                         sMarkup += ">";
                         nPrimaryId = -1;
                         nSecondaryId = -1;
                    }
                    if(oDocument.pSentences[i].pTokens[j].nPostFixed == 0)
                    {
                         sMarkup += " ";
                    }
                    sMarkup += oDocument.pSentences[i].pTokens[j].acToken;
               }
               else
               {
                    if(nPrimaryId == oDocument.pSentences[i].pTokens[j].nId && 
                       nSecondaryId == oDocument.pSentences[i].pTokens[j].nSecondaryId)
                    {
                         if(oDocument.pSentences[i].pTokens[j].nPostFixed == 0)
                         {
                              sMarkup += " ";
                         }
                         sMarkup += oDocument.pSentences[i].pTokens[j].acToken;
                    }
                    else
                    {
                         if(nPrimaryId != -1)
                         {
                              sMarkup += "</";
                              sMarkup += sType;
                              sMarkup += ">";
                         }
                         if(oDocument.pSentences[i].pTokens[j].nPostFixed == 0)
                         {
                              sMarkup += " ";
                         }
                         nPrimaryId = oDocument.pSentences[i].pTokens[j].nId;
                         nSecondaryId = oDocument.pSentences[i].pTokens[j].nSecondaryId;
                         sType = oDocument.pSentences[i].pTokens[j].acEntityType;
                         sMarkup += "<";
                         sMarkup += sType;
                         sMarkup += ">";
                         sMarkup += oDocument.pSentences[i].pTokens[j].acToken;
                    }
               }
          }
     }
     if(nPrimaryId != -1)
     {
          sMarkup += "</";
          sMarkup += sType;
          sMarkup += ">";
          nPrimaryId = -1;
          nSecondaryId = -1;
     }

     std::cout << sMarkup << std::endl;
     lxaFreeDocument(&oDocument);

<< lxaGetNamedEntityMarkup | Back to Salience 6 C API Index | lxaGetPOSMarkup >>