n_xpminfo(), n_freexpmi() - Hit information

SYNOPSIS

#include "napi.h"
XPMI *n_xpminfo(SERVER *se,SRCH *sr,int index);
XPMI *n_freexpmi(SERVER *se,XPMI *xi);


DESCRIPTION
These functions may be used within the hit callback function to obtain detailed information about any search terms that may have used the approximate pattern matcher (XPM). n_xpminfo() is called with the index of the desired XPM.

It returns a structure containing everything about that XPM. It returns XPMIPN if index is out of bounds.

To get all XPM subhits put n_xpminfo() in a loop with index starting at zero and incrementing until XPMIPN is returned.

Each valid structure returned by n_xpminfo() should be freed by calling n_freexpmi() when it is no longer needed.

The XPMI structure contains the following members:

XPMI                                                      /* XPM Info */
{
 word  thresh;               /* threshold above which a hit can occur */
 word  maxthresh;                            /* exact match threshold */
 word  thishit;                               /* this hit's threshold */
 word  maxhit;                        /* max threshold located so far */
 char *maxstr;                      /* string of highest value so far */
 char *srchs;                              /* string being search for */
};


CAVEATS
Don't expect XPMI.thresh to be the percentage entered in the query passed to n_setqry(). It is an absolute number calculated from that percentage and the search string.


EXAMPLE

int
hit_handler(usr,sr,url)
void *usr;  /* my pointer */
SRCH *sr;   /* The search info data structure */
str url;    /* The Uniform Resource Locator string AKA filename */
{
 ...
 int i;
 XPMI *xi;
 ...
 for(i=0;(xi=n_xpminfo(ts->se,sr,i))!=XPMIPN;i++)
    {
     printf("XPM: \"%s\": thresh %u, maxthresh %u, thishit %u\n",
            xi->srchs,xi->thresh,xi->maxthresh,xi->thishit);
     printf("   : maxhit %u, maxstr \"%s\"\n",xi->maxhit,xi->maxstr);
     n_freexpmi(ts->se,xi);
    }
 ...
 return(1);           /* tell the server to keep giving me more hits */
}


SEE ALSO
The example program netex1.c, n_reghitcb().


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.