home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / WAIS / ir / irext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-02  |  6.3 KB  |  224 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer. */
  4.  
  5. /* Include file for the irhash.c file.
  6.    Implements the building functions in irext.h */
  7.  
  8. #ifndef IREXT_H
  9. #define IREXT_H
  10.  
  11.  
  12. /* An interface for adding new server types into the WAIS system.
  13.  * The idea is to use the parsing and bookkeeping operatios of the serial 
  14.  * indexer, while allowing different invered file and signiture systems 
  15.  * to be added as back ends.
  16.  *
  17.  * - Tracy Shen and Brewster 3/91
  18.  */
  19.  
  20. /*
  21.  * Tracy changes:
  22.  *  - in function "add_word", add two more parameters, source and date
  23.  *  - add a new function "set_query_parameter"
  24.  * proposed changes by brewster:
  25.  *  replace date_type with time_t: accepted
  26.  *  take out all "unsigned" type modifiers (tracey will concider this)
  27.  *  replace short with long: accepted
  28.  *  replace int with long (we port to 16 bit machines still): accepted
  29.  *  added source to delete_doc_id parameters: accepted
  30.  * Proposed changes by brewster and tracy:
  31.  *  if routines are successful return 0, otherwise an error code: accepted
  32.  * Proposed changes by harry:
  33.  *  make the dictionary value be any size.  This can be done by 
  34.  *   passing in a size arg or by passing in read and write routines.
  35.  *  have a function that says we will not be calling best_hit anymore.
  36.  * proposed changes by brewster:
  37.  *  took out hash_pos from add word.
  38.  *  change source to a database* db.
  39.  *  added finished_best_hit, finished_search_word(db), finished_add_word
  40.  *
  41.  */
  42.  
  43. #include "cdialect.h"
  44. #include "irfiles.h" /* for database */
  45.  
  46. #ifdef __cplusplus
  47. /* declare these as C style functions */
  48. extern "C"
  49.     {
  50. #endif /* def __cplusplus */
  51.  
  52.  
  53.  
  54. /* ============================
  55.  * ===  Building Functions  ===
  56.  * ============================*/
  57.  
  58. long init_add_word _AP ((database *db, long parameter1, long parameter2));
  59.  
  60. /*
  61.  *  add_word: add this word to the database
  62.  *   return values: 0 if successful, non-0 if error
  63.  *       defined error conditions:
  64.  *
  65.  */
  66. long add_word _AP((
  67.            char *word,    /* the word to be indexed, this could be a
  68.                    word pair. If NULL there are no more words
  69.                    to be indexed */
  70.            long char_pos, /* the position of the start of the
  71.                      word */
  72.            long line_pos, /* this is passed for the best
  73.                      section calculation */
  74.            long weight,    /* how important the word looks
  75.                    syntactically (such as is it bold)
  76.                    NOT used by signature system */
  77.            long doc_id,    /* current document, this will never be 0 */
  78.            time_t date, /* display day of this document, 0 if not known */
  79.            database* db /* database to insert the document */
  80.            ));
  81.  
  82. /*
  83.  *  finished_add_word: states that there are no more words to add
  84.  *   to this database.
  85.  *
  86.  *   return values: 0 if successful, non-0 if error
  87.  *       defined error conditions:
  88.  *
  89.  */
  90.  
  91. long finished_add_word _AP((database *db));
  92.  
  93. /* ===============================
  94.  * ===  Maintenance Functions  ===
  95.  * ===============================*/
  96.  
  97. /*
  98.  *  delete_doc_id : delete a document
  99.  *   return values:  0, successfull
  100.  *                  -1, document not found
  101.  *
  102.  */
  103. long delete_doc_id _AP((long doc_id, database *db));
  104.  
  105. /* =============================
  106.  * ===  Searching Functions  ===
  107.  * =============================*/
  108.  
  109.  
  110. /*
  111.  *  set_query_parameter : set query parameter
  112.  *      set search attributes such as date factor, document source ids,
  113.  *      and maximum number of documents returned in a search ( the last
  114.  *      one is an important performance factor to signature  type system)
  115.  *      The search artributes applies to all comming queries until
  116.  *      they are re-set by next set_query_parameter call.
  117.  *
  118.  *   return values:  none
  119.  *
  120.  */
  121. #define SET_MAX_RETRIEVED_MASK 1
  122. #define SET_DATE_FACTOR_MASK   2
  123. #define SET_SELECT_SOURCE      4
  124.  
  125. /* enum literals for date_factor */
  126. #define DF_INDEPENDENT          1
  127. #define DF_LATER                2
  128. #define DF_EARLIER              3
  129.  
  130. typedef struct {
  131.   long max_hit_retrieved;
  132.   /* max number of hits can be returned by
  133.    * the search engine. For a signature
  134.    * type system, the default value is 20
  135.    */
  136.   long date_factor;        /* default is DF_INDEPENDENT */
  137.   long num_db;            /* value of zero indicating select all,
  138.                  * default is selecting all
  139.                  */
  140.   database **db_list;        /* list of databases to be searched */
  141. }  query_parameter_type;
  142.  
  143. /*
  144.  *  set_query_parameter: set a mode variable for the search engine
  145.  *   return values: 0 if successful, non-0 if error
  146.  *       defined error conditions:
  147.  *
  148.  */
  149.  
  150. long set_query_parameter _AP ((
  151.              long mask,
  152.              query_parameter_type *parameters
  153.              /* fields in the query parameter structure are only
  154.               * interpreted when the corresponding mask bit 
  155.               * is set in the mask argument.
  156.               */
  157.              ));
  158.  
  159.  
  160. /*
  161.  *  search_word: searches for a word in the index.  it side effects 
  162.  *               internal state so that best_hit will return the correct 
  163.  *               results.
  164.  *   return values: 0 if successful, non-0 if error
  165.  *       defined error conditions:
  166.  *
  167.  */
  168.  
  169. long search_word 
  170.   _AP ((char *word, /* the word to be searched for */
  171.     long char_pos,        /* the position of the start of the word */
  172.     long line_pos,        /* is this needed? not for signature system */
  173.     long weight,        /* how important the word looks syntactically,
  174.                    such as is it bold */
  175.     long doc_id,        /* current document, seed words is 0,
  176.                    then it increments into the relevant 
  177.                    document */
  178.     long dictionary_value,    /* this is from the disk dictionary,
  179.                    a signature system would use weight,
  180.                    inverted file systems would put
  181.                    position information */
  182.     database *db
  183.     ));
  184.  
  185.  
  186. /*
  187.  *  finished_search_word: states that there are no more words that will
  188.  *   be searched for before best_hit will be called.
  189.  *
  190.  *   return values: 0 if successful, non-0 if error
  191.  *       defined error conditions:
  192.  *
  193.  */
  194.  
  195. long finished_search_word _AP((database *db));
  196.  
  197. /*
  198.  *  best-hit :
  199.  *
  200.  *   return values:  0, successfull
  201.  *                  -1, no more documents to return
  202.  *            Other values returned to signal future signals.
  203.  *
  204.  */
  205. long best_hit _AP ((long *doc_id, long *score));
  206.  
  207. /*
  208.  *  finished_best_hit: states that there are no more best_hits will be called
  209.  *   before the next set of search_words or add_words.
  210.  *
  211.  *   return values: 0 if successful, non-0 if error
  212.  *       defined error conditions:
  213.  *
  214.  */
  215.  
  216. long finished_best_hit _AP((void));
  217.  
  218.  
  219. #ifdef __cplusplus
  220.     }
  221. #endif /* def __cplusplus */
  222.  
  223. #endif /* ndef IREXT_H */
  224.