Ignore:
Timestamp:
1999-07-01T15:52:05+12:00 (25 years ago)
Author:
rjmcnab
Message:

Added a function to get the equivalent terms of a query term. I also
fixed a small bug that was causing massive slowdown :-

Location:
trunk/gsdl/src/colservr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/mgq.c

    r319 r324  
    1212/*
    1313   $Log$
     14   Revision 1.6  1999/07/01 03:52:05  rjmcnab
     15   Added a function to get the equivalent terms of a query term. I also
     16   fixed a small bug that was causing massive slowdown :-^
     17
    1418   Revision 1.5  1999/06/30 04:04:11  rjmcnab
    1519   made stemming functions available from mgsearch and made the stems
     
    6771#include "words.h"
    6872#include "stemmer.h"
     73#include "stem_search.h"
    6974 
    7075#ifdef __cplusplus
     
    214219  } while (NextDoc (qd) && output_failure == 0 && --howmany > 0);
    215220 
    216   if (need_text) FreeTextBuffer (qd);
     221  /*  if (need_text) FreeTextBuffer (qd);*/
    217222 
    218223  return (DocCount);
     
    567572}
    568573
     574/* get all the terms that match wordstem using the current stemmer and */
     575/* stemming method. The callback is the same style used by mgq_results */
     576int mgq_equivterms (unsigned char *wordstem, int (*sender)(char *, int, int, float, void *),
     577            void *ptr) {
     578  int stem_method = 0;
     579  query_data *qd = NULL;
     580  TermList *equivterms = NULL;  /* used for equivalent terms */
     581
     582  if (cur_cachenum == -1) return 0;
     583  qd = dbcache[cur_cachenum].qd;
     584  if (qd == NULL || wordstem == NULL || sender == NULL) return 0;
     585
     586  if (qd->sd->sdh.indexed) {
     587    stem_method = BooleanEnv(GetEnv("casefold"),0) | (BooleanEnv(GetEnv("stem"),0) << 1);
     588  } else {
     589    stem_method = qd->sd->sdh.stem_method;
     590  }
     591
     592  /* make the term list */
     593  equivterms = MakeTermList (0);
     594 
     595  /* expand out this word */
     596  if (FindWords (qd->sd, wordstem, stem_method, &equivterms) > 0) {
     597    int i;
     598    for (i=0; i < equivterms->num; i++) {
     599      (* sender)((char *)(equivterms->TE[i].Word+1), equivterms->TE[i].Word[0],
     600         equivterms->TE[i].Count, (float)0.0, ptr);
     601    }
     602  }
     603
     604  /* free the term list */
     605  if (equivterms != NULL) FreeTermList (&equivterms);
     606
     607  return 0;
     608}
    569609
    570610/* use mgq_getmaxstemlen to determine the length of the word stems to pass */
     
    628668  /* search for the index */
    629669  i = search_gensuffix (gensuffix);
    630   if (i > 0) {
     670  if (i >= 0) {
    631671    make_current (i);
    632672    return 1;
  • trunk/gsdl/src/colservr/mgq.h

    r319 r324  
    2727
    2828int mgq_ask(char *line);
    29 int mgq_results(enum result_kinds kind,int skip, int howmany,
     29int mgq_results(enum result_kinds kind, int skip, int howmany,
    3030        int (*sender)(char *, int, int, float, void *), void *ptr);
    3131int mgq_numdocs(void);
    3232int mgq_numterms(void);
    3333
     34/* get all the terms that match wordstem using the current stemmer and */
     35/* stemming method. The callback is the same style used by mgq_results */
     36int mgq_equivterms (unsigned char *wordstem, int (*sender)(char *, int, int, float, void *),
     37            void *ptr);
     38 
    3439/* use mgq_getmaxstemlen to determine the length of the word stems to pass */
    3540/* to mgq_stemword */
Note: See TracChangeset for help on using the changeset viewer.