From 118a515cfa4c1ee67ede51b8145b20ee21dd5969 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 24 Mar 2009 16:50:49 +0100 Subject: [PATCH] New ranking rank-2 .. Like rank-1 but subtracts staticrank. rank-2 is a combination of rank-1 and static rank.. The staticrank is inverse (lowest value comes first, etc..). rank-2 thus substracts that from score. This allows a system to specify a "base" rank (=staticrank). --- index/rank.h | 1 + index/rank1.c | 28 +++++++++++++++++++++++----- index/zebraapi.c | 1 + test/xslt/snippet.xsl | 2 ++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/index/rank.h b/index/rank.h index cff9646..c86b191 100644 --- a/index/rank.h +++ b/index/rank.h @@ -49,6 +49,7 @@ void zebraRankDestroy (struct zebra_register *reg); /* declaring externally defined rank class structures */ /* remember to install rank classes in zebraapi.c as well!! */ extern struct rank_control *rank_1_class; +extern struct rank_control *rank_2_class; extern struct rank_control *rank_zv_class; extern struct rank_control *rank_static_class; extern struct rank_control *rank_similarity_class; diff --git a/index/rank1.c b/index/rank1.c index b4558ef..48f33ea 100644 --- a/index/rank1.c +++ b/index/rank1.c @@ -186,8 +186,8 @@ static void add(void *set_handle, int seqno, TERMID term) * score should be between 0 and 1000. If score cannot be obtained * -1 should be returned. */ -static int calc(void *set_handle, zint sysno, zint staticrank, - int *stop_flag) +static int calc_1(void *set_handle, zint sysno, zint staticrank, + int *stop_flag) { int i, lo, divisor, score = 0; struct rank_set_info *si = (struct rank_set_info *) set_handle; @@ -214,6 +214,13 @@ static int calc(void *set_handle, zint sysno, zint staticrank, return score; } +static int calc_2(void *set_handle, zint sysno, zint staticrank, + int *stop_flag) +{ + int score = calc_1(set_handle, sysno, staticrank, stop_flag); + return score - staticrank; +} + /* * Pseudo-meta code with sequence of calls as they occur in a * server. Handlers are prefixed by --: @@ -232,17 +239,28 @@ static int calc(void *set_handle, zint sysno, zint staticrank, * server close */ -static struct rank_control rank_control = { +static struct rank_control rank_1_control = { "rank-1", create, destroy, begin, end, - calc, + calc_1, + add, +}; +struct rank_control *rank_1_class = &rank_1_control; + +static struct rank_control rank_2_control = { + "rank-2", + create, + destroy, + begin, + end, + calc_2, add, }; -struct rank_control *rank_1_class = &rank_control; +struct rank_control *rank_2_class = &rank_2_control; /* * Local variables: * c-basic-offset: 4 diff --git a/index/zebraapi.c b/index/zebraapi.c index b4cade1..631aaff 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -407,6 +407,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, /* installing rank classes */ zebraRankInstall(reg, rank_1_class); + zebraRankInstall(reg, rank_2_class); zebraRankInstall(reg, rank_similarity_class); zebraRankInstall(reg, rank_static_class); diff --git a/test/xslt/snippet.xsl b/test/xslt/snippet.xsl index 475c216..67edbb3 100644 --- a/test/xslt/snippet.xsl +++ b/test/xslt/snippet.xsl @@ -5,6 +5,7 @@ + + -- 1.7.10.4