From d2eeebeeae413abd5b189e38b5e81fa0516e0752 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 13 Oct 2009 15:55:46 +0200 Subject: [PATCH] Deal with relevance values round-off case --- src/relevance.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/relevance.c b/src/relevance.c index f2a58e7..262d517 100644 --- a/src/relevance.c +++ b/src/relevance.c @@ -313,7 +313,7 @@ void relevance_prepare_read(struct relevance *rel, struct reclist *reclist) while (1) { int t; - float relevance = 0; + int relevance = 0; struct record_cluster *rec = reclist_read_record(reclist); if (!rec) break; @@ -323,9 +323,9 @@ void relevance_prepare_read(struct relevance *rel, struct reclist *reclist) if (!rec->term_frequency_vec[0]) break; termfreq = (float) rec->term_frequency_vec[t] / rec->term_frequency_vec[0]; - relevance += termfreq * idfvec[t]; + relevance += 100000 * (termfreq * idfvec[t] + 0.0000005); } - rec->relevance = (int) (relevance * 100000); + rec->relevance = relevance; } reclist_rewind(reclist); xfree(idfvec); -- 1.7.10.4