From 3cf135bd903f218baf45989defcfc54cf3a4f663 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Wed, 4 Dec 2013 15:35:46 +0100 Subject: [PATCH] Small fixes: sort order, plot right robinscore --- src/relevance.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/relevance.c b/src/relevance.c index b403048..97e9ce7 100644 --- a/src/relevance.c +++ b/src/relevance.c @@ -426,9 +426,9 @@ static int sort_float(const void *x, const void *y) const float *fx = x; const float *fy = y; //yaz_log(YLOG_LOG,"sorting %f and %f", *fx, *fy); // ### - if ( *fx > *fy ) - return 1; if ( *fx < *fy ) + return 1; + if ( *fx > *fy ) return -1; return 0; // do not return *fx-*fy, it is often too close to zero. } @@ -526,7 +526,7 @@ void relevance_prepare_read(struct relevance *rel, struct reclist *reclist, // Calculate a round-robin score robinscore = -(bestrecord->position * n_clients + norm->num) ; wrbuf_printf(w,"round-robin score: pos=%d client=%d ncl=%d tfscore=%d score=%d\n", - bestrecord->position, norm->num, nclust, tfrel, relevance ); + bestrecord->position, norm->num, nclust, tfrel, robinscore ); yaz_log(YLOG_LOG,"round-robin score: pos=%d client=%d ncl=%d score=%d", bestrecord->position, norm->num, nclust, relevance ); @@ -562,8 +562,9 @@ void relevance_prepare_read(struct relevance *rel, struct reclist *reclist, { // have more than one record for (record = rec->records; record; record = record->next, i++) { - scores[i] = atof( getfield(record,"score") ); - yaz_log(YLOG_LOG,"mergescore %d: %f", i, scores[i] ); + const char *scorefld = getfield(record,"score"); + scores[i] = atof( scorefld ); + yaz_log(YLOG_LOG,"mergescore %d: %s", i, scorefld ); wrbuf_printf(w,"mergeplot %d %f x\n", clusternumber, 10000*scores[i] ); } qsort(scores, nclust, sizeof(float), sort_float ); -- 1.7.10.4