pike.git / src / modules / _WhiteFish / whitefish.c

version» Context lines:

pike.git/src/modules/_WhiteFish/whitefish.c:1:   #include <math.h>      #include "global.h"   #include "stralloc.h"   #include "global.h" - RCSID("$Id: whitefish.c,v 1.33 2002/01/02 12:48:46 js Exp $"); + RCSID("$Id: whitefish.c,v 1.35 2004/08/07 15:26:57 js Exp $");   #include "pike_macros.h"   #include "interpret.h"   #include "program.h" - #include "program_id.h" +    #include "object.h" - #include "operators.h" +    #include "array.h"   #include "module_support.h" -  + #include "module.h"      #include "config.h"      #include "whitefish.h"   #include "resultset.h"   #include "blob.h"   #include "blobs.h"   #include "linkfarm.h"    -  + /* 7.2 compatibility stuff. */ +  + #ifndef PIKE_MODULE_INIT   /* must be included last */   #include "module_magic.h" -  + #define PIKE_MODULE_INIT void pike_module_init(void) + #define PIKE_MODULE_EXIT void pike_module_exit(void) + #endif      struct tofree   {    Blob **blobs;    Blob **tmp;    int nblobs;    struct object *res;   };      static void free_stuff( void *_t )
pike.git/src/modules/_WhiteFish/whitefish.c:370:    }   end:    /* Free workarea and return the result. */       UNSET_ONERROR( e );    __f->res = 0;    free_stuff( __f );    return res;   }    + /*! @module Search +  */      static void f_do_query_phrase( INT32 args )   /*! @decl ResultSet do_query_phrase( array(string) words, @    *! array(int) field_coefficients, @    *! function(int:string) blobfeeder) -  *! @[words] +  *! @param words    *! -  *! Arrays of word ids. Note that the order is significant -  *! for the ranking. +  *! Arrays of word ids. Note that the order is significant for the +  *! ranking.    *! -  *! @[field_coefficients] +  *! @param field_coefficients    *! -  *! An array of ranking coefficients for the different fields. -  *! In the range of [0x0000-0xffff]. The array (always) has 65 -  *! elements: +  *! An array of ranking coefficients for the different fields. In the +  *! range of [0x0000-0xffff]. The array (always) has 65 elements:    *! -  *! Index Coefficient for field -  *! ----- --------------------- -  *! 0 body -  *! 1..64 Special field 0..63 +  *! @array +  *! @elem int 0 +  *! body +  *! @elem int 1..64 +  *! Special field 0..63. +  *! @endarray    *! -  *! @[blobfeeder] +  *! @param blobfeeder    *! -  *! This function returns a Pike string containing the word hits -  *! for a certain word_id. Call repeatedly until it returns 0. +  *! This function returns a Pike string containing the word hits for a +  *! certain word_id. Call repeatedly until it returns @expr{0@}.    */   {    double proximity_coefficients[8];    double field_coefficients[65];    int numblobs, i;    Blob **blobs;       struct svalue *cb;    struct object *res;    struct array *_words, *_field;
pike.git/src/modules/_WhiteFish/whitefish.c:440:    res = low_do_query_phrase(blobs,numblobs, field_coefficients );    pop_n_elems( args );    wf_resultset_push( res );   }      static void f_do_query_and( INT32 args )   /*! @decl ResultSet do_query_and( array(string) words, @    *! array(int) field_coefficients, @    *! array(int) proximity_coefficients, @    *! function(int:string) blobfeeder) -  *! @[words] +  *! @param words    *! -  *! Arrays of word ids. Note that the order is significant -  *! for the ranking. +  *! Arrays of word ids. Note that the order is significant for the +  *! ranking.    *! -  *! @[field_coefficients] +  *! @param field_coefficients    *! -  *! An array of ranking coefficients for the different fields. -  *! In the range of [0x0000-0xffff]. The array (always) has 65 -  *! elements: +  *! An array of ranking coefficients for the different fields. In the +  *! range of [0x0000-0xffff]. The array (always) has 65 elements:    *! -  *! Index Coefficient for field -  *! ----- --------------------- -  *! 0 body -  *! 1..64 Special field 0..63 +  *! @array +  *! @elem int 0 +  *! body +  *! @elem int 1..64 +  *! Special field 0..63. +  *! @endarray    *! -  *! @[proximity_coefficients] +  *! @param proximity_coefficients    *! -  *! An array of ranking coefficients for the different -  *! proximity categories. Always has 8 elements, in the range -  *! of [0x0000-0xffff]. +  *! An array of ranking coefficients for the different proximity +  *! categories. Always has 8 elements, in the range of +  *! [0x0000-0xffff].    *! -  *! Index Meaning -  *! ----- ------- -  *! 0 spread: 0 (Perfect hit) -  *! 1 spread: 1-5 -  *! 2 spread: 6-10 -  *! 3 spread: 11-20 -  *! 4 spread: 21-40 -  *! 5 spread: 41-80 -  *! 6 spread: 81-160 -  *! 7 spread: 161- +  *! @array +  *! @elem int 0 +  *! spread: 0 (Perfect hit) +  *! @elem int 1 +  *! spread: 1-5 +  *! @elem int 2 +  *! spread: 6-10 +  *! @elem int 3 +  *! spread: 11-20 +  *! @elem int 4 +  *! spread: 21-40 +  *! @elem int 5 +  *! spread: 41-80 +  *! @elem int 6 +  *! spread: 81-160 +  *! @elem int 7 +  *! spread: 161- +  *! @endarray    *! -  *! The 'spread' value should be defined somehow. +  *! @param blobfeeder    *! -  *! @[blobfeeder] -  *! -  *! This function returns a Pike string containing the word hits -  *! for a certain word_id. Call repeatedly until it returns 0. +  *! This function returns a Pike string containing the word hits for a +  *! certain word_id. Call repeatedly until it returns @expr{0@}.    */   {    double proximity_coefficients[8];    double field_coefficients[65];    int numblobs, i, cutoff;    Blob **blobs;       struct svalue *cb;    struct object *res;    struct array *_words, *_field, *_prox;
pike.git/src/modules/_WhiteFish/whitefish.c:533:       pop_n_elems( args );    wf_resultset_push( res );   }      static void f_do_query_or( INT32 args )   /*! @decl ResultSet do_query_or( array(string) words, @    *! array(int) field_coefficients, @    *! array(int) proximity_coefficients, @    *! function(int:string) blobfeeder) -  *! @[words] +  *! @param words    *! -  *! Arrays of word ids. Note that the order is significant -  *! for the ranking. +  *! Arrays of word ids. Note that the order is significant for the +  *! ranking.    *! -  *! @[field_coefficients] +  *! @param field_coefficients    *! -  *! An array of ranking coefficients for the different fields. -  *! In the range of [0x0000-0xffff]. The array (always) has 65 -  *! elements: +  *! An array of ranking coefficients for the different fields. In the +  *! range of [0x0000-0xffff]. The array (always) has 65 elements:    *! -  *! Index Coefficient for field -  *! ----- --------------------- -  *! 0 body -  *! 1..64 Special field 0..63 +  *! @array +  *! @elem int 0 +  *! body +  *! @elem int 1..64 +  *! Special field 0..63. +  *! @endarray    *! -  *! @[proximity_coefficients] +  *! @param proximity_coefficients    *! -  *! An array of ranking coefficients for the different -  *! proximity categories. Always has 8 elements, in the range -  *! of [0x0000-0xffff]. +  *! An array of ranking coefficients for the different proximity +  *! categories. Always has 8 elements, in the range of +  *! [0x0000-0xffff].    *! -  *! Index Meaning -  *! ----- ------- -  *! 0 spread: 0 (Perfect hit) -  *! 1 spread: 1-5 -  *! 2 spread: 6-10 -  *! 3 spread: 11-20 -  *! 4 spread: 21-40 -  *! 5 spread: 41-80 -  *! 6 spread: 81-160 -  *! 7 spread: 161- +  *! @array +  *! @elem int 0 +  *! spread: 0 (Perfect hit) +  *! @elem int 1 +  *! spread: 1-5 +  *! @elem int 2 +  *! spread: 6-10 +  *! @elem int 3 +  *! spread: 11-20 +  *! @elem int 4 +  *! spread: 21-40 +  *! @elem int 5 +  *! spread: 41-80 +  *! @elem int 6 +  *! spread: 81-160 +  *! @elem int 7 +  *! spread: 161- +  *! @endarray    *! -  *! The 'spread' value should be defined somehow. +  *! @param blobfeeder    *! -  *! @[blobfeeder] -  *! -  *! This function returns a Pike string containing the word hits -  *! for a certain word_id. Call repeatedly until it returns 0. +  *! This function returns a Pike string containing the word hits for a +  *! certain word_id. Call repeatedly until it returns @expr{0@}.    */   {    double proximity_coefficients[8];    double field_coefficients[65];    int numblobs, i, cutoff;    Blob **blobs;       struct svalue *cb;    struct object *res;    struct array *_words, *_field, *_prox;
pike.git/src/modules/_WhiteFish/whitefish.c:620:    field_coefficients[i] = (double)_field->item[i].u.integer;       res = low_do_query_or(blobs,numblobs,    field_coefficients,    proximity_coefficients,    cutoff );    pop_n_elems( args );    wf_resultset_push( res );   }    + /*! @endmodule +  */    - void pike_module_init(void) +  + PIKE_MODULE_INIT   {    init_resultset_program();    init_blob_program();    init_blobs_program();    init_linkfarm_program();       add_function( "do_query_or", f_do_query_or,    "function(array(string),array(int),array(int),int"    ",function(string,int:string):object)",    0 );
pike.git/src/modules/_WhiteFish/whitefish.c:644:    "function(array(string),array(int),array(int),int"    ",function(string,int:string):object)",    0 );       add_function( "do_query_phrase", f_do_query_phrase,    "function(array(string),array(int)"    ",function(string,int:string):object)",    0 );   }    - void pike_module_exit(void) + PIKE_MODULE_EXIT   {    exit_resultset_program();    exit_blob_program();    exit_blobs_program();    exit_linkfarm_program();   }