Changeset 8919 for trunk/indexers/mg


Ignore:
Timestamp:
2005-01-20T16:06:52+13:00 (19 years ago)
Author:
kjdon
Message:

added some bits (copied from mgquery) to make paragraph searching work - it wasn't returning doc numbers, but was returning para numbers which are not in the gdbm database

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/indexers/mg/jni/MGWrapperImpl.c

    r7629 r8919  
    5757#define MAX_INDEXES_CACHED 3
    5858
     59/* copied from mgquery, needed to convert paragraph numbers to document numbers
     60   for greenstone */
     61#if defined(PARADOCNUM) ||  defined(NZDL)
     62static int GetDocNumFromParaNum(query_data *qd, int paranum) {
     63  int Documents = qd->td->cth.num_of_docs;
     64  int *Paragraph = qd->paragraph;
     65  int low = 1, high = Documents;
     66  int mid = (low+high)/2;
     67
     68  while ((mid = (low+high)/2) >=1 && mid <= Documents)
     69    {
     70      if (paranum > Paragraph[mid])
     71        low = mid+1;
     72      else if (paranum <= Paragraph[mid-1])
     73        high = mid-1;
     74      else
     75        return mid;
     76    }
     77  FatalError(1, "Bad paragraph number.\n");
     78  return 0;
     79}
     80#endif
     81
    5982
    6083/*********************************************
     
    407430    rqi.MaxDocsToRetrieve = data->queryInfo->maxDocs;  /* Get only the desired number */
    408431    rqi.MaxParasToRetrieve = rqi.MaxDocsToRetrieve;  /* OK? */
     432    /* we may need to get more paragraphs to get enough documents. I copied the following from mgquery. it seems to work, not sure why - kjdon */
     433    if (qd->id->ifh.InvfLevel == 3 && GetEnv ("maxparas")) {
     434      rqi.MaxParasToRetrieve = atoi (GetEnv ("maxparas"));
     435    }
     436   
    409437    rqi.Sort = 1;  /* Sort the query terms by frequency before ranking */
    410438    rqi.AccumMethod = 'L';  /* Use a list when accumulating (has bugs though...) */
     
    450478  /* Record the matching documents, but only the number requested */
    451479  printf("Number of matching documents: %d\n", qd->DL->num);
     480 
    452481  for (i = 0; (i < qd->DL->num && i < data->queryInfo->maxDocs); i++) {
    453482    int doc_num = qd->DL->DE[i].DocNum;
     483#if defined(PARADOCNUM) || defined(NZDL)
     484    if (qd->id->ifh.InvfLevel == 3) {
     485      /* pararaph level, need to convert to doc level*/
     486      doc_num = GetDocNumFromParaNum(qd, doc_num);
     487    }
     488#endif
    454489    float doc_weight = qd->DL->DE[i].Weight;
    455490
Note: See TracChangeset for help on using the changeset viewer.