n_xpminfo(), n_freexpmi() - Hit information


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

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 */

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.


void *usr;  /* my pointer */
SRCH *sr;   /* The search info data structure */
str url;    /* The Uniform Resource Locator string AKA filename */
 int i;
 XPMI *xi;
     printf("XPM: \"%s\": thresh %u, maxthresh %u, thishit %u\n",
     printf("   : maxhit %u, maxstr \"%s\"\n",xi->maxhit,xi->maxstr);
 return(1);           /* tell the server to keep giving me more hits */

The example program netex1.c, n_reghitcb().

Copyright © Thunderstone Software     Last updated: May 19 2023
Copyright © 2023 Thunderstone Software LLC. All rights reserved.