-/* $Id: zvrank.c,v 1.7 2004-06-13 18:44:57 adam Exp $
+/* $Id: zvrank.c,v 1.11 2004-10-26 15:32:11 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
** "ntc-atn", "atc-atn", etc.
*/
+#if SKIPTHIS /* FIXME - Disabled while changing the interface to ranking */
+
#include <math.h> /* for log */
#include <stdio.h>
/* structures */
-struct rank_class_info { /* now we need this */
- int dummy;
+struct rank_class_info {
char rscheme[8]; /* name of weighting scheme */
};
char rscheme[8]; /* name of weighting scheme */
/**/
int veclen;
+ NMEM nmem;
void (*d_tf_fct)(void *, void *); /* doc term frequency function */
void (*d_idf_fct)(void *, void *); /* doc idf function */
void (*d_norm_fct)(void *, void *); /* doc normalization function */
char *name;
int *id;
/**/
- int gocc;
+ zint gocc;
int locc;
double tf;
double idf;
static void idf_tfidf(void *rsi, void *dsi) {
RS rs=(RS)rsi;
DS ds=(DS)dsi;
- int num_docs, gocc;
+ zint num_docs, gocc;
int i, veclen;
double idf;
/* normal tfidf weight */
if (gocc==0)
idf=0.0;
else
- idf=blog(num_docs/gocc);
+ idf=blog((double) (num_docs/gocc));
ds->terms[i].idf=idf;
}
return;
static void idf_prob(void *rsi, void *dsi) {
RS rs=(RS)rsi;
DS ds=(DS)dsi;
- int num_docs, gocc;
+ zint num_docs, gocc;
int i, veclen;
double idf;
/* probabilistic formulation */
if (gocc==0)
idf=0.0;
else
- idf=blog((num_docs-gocc)/gocc);
+ idf=blog((double) ((num_docs-gocc)/gocc));
ds->terms[i].idf=idf;
}
return;
static void idf_squared(void *rsi, void *dsi) {
RS rs=(RS)rsi;
DS ds=(DS)dsi;
- int num_docs, gocc;
+ zint num_docs, gocc;
int i, veclen;
double idf;
/* idf ^ 2 */
* each result set. The returned handle is a "set handle" and
* will be used in each of the handlers below.
*/
-static void *zv_begin(struct zebra_register *reg, void *class_handle, RSET rset)
+static void *zv_begin(struct zebra_register *reg, void *class_handle,
+ RSET rset, NMEM nmem)
{
struct rs_info *rs=(struct rs_info *)xmalloc(sizeof(*rs));
struct rank_class_info *ci=(struct rank_class_info *)class_handle;
int i;
- int veclen, gocc;
+ int veclen;
+ zint gocc;
/**/
yaz_log(LOG_DEBUG, "zv_begin");
- veclen=rset->no_rset_terms; /* smaller vector here */
+ veclen= 0 ; /* rset->no_rset_terms;*/ /* smaller vector here */
+ /* FIXME - Now that we don't have term lists in rsets, what do */
+ /* we do here ??? */
zv_init(rs, ci->rscheme);
+ rs->nmem=nmem;
rs->veclen=veclen;
prn_rs(rs);
/* yaz_log(LOG_DEBUG, "zv_begin_init"); */
for (i = 0; i < rs->veclen; i++)
{
- gocc=rset->rset_terms[i]->nn;
+ gocc= 0; /* rset->rset_terms[i]->nn; */ /* FIXME ??? */
/* yaz_log(LOG_DEBUG, "zv_begin_init i=%d gocc=%d", i, gocc); */
rs->qdoc->terms[i].gocc=gocc;
rs->qdoc->terms[i].locc=1; /* assume query has no duplicate terms */
* score should be between 0 and 1000. If score cannot be obtained
* -1 should be returned.
*/
-static int zv_calc (void *rsi, int sysno)
+static int zv_calc (void *rsi, zint sysno)
{
int i, veclen;
int score=0;
(*rs->d_norm_fct)(rs, rs->rdoc);
dscore=rs->sim_fct(rs->qdoc, rs->rdoc);
}
- score = dscore * 1000;
- yaz_log (LOG_LOG, "sysno=%d score=%d", sysno, score);
+ score = (int) dscore * 1000;
+ yaz_log (LOG_LOG, "sysno=" ZINT_FORMAT " score=%d", sysno, score);
if (score > 1000) /* should not happen */
score = 1000;
- return score;
+ return (int) score;
}
/*
struct rank_control *rankzv_class = &rank_control_vsm;
+#endif /* SKIPTHIS */
/* EOF */