X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=src%2Frelevance.c;h=a33891765e30ec89add8a488fb9dd7a78ce77e5d;hb=0818e0450b743e626ef22adb9491831d547beffa;hp=1a9f4d7415e251e057de0fd0ffb59f3d50cf691a;hpb=e107b0011a295ccc61502d6e5ea79d9125a3fbb4;p=pazpar2-moved-to-github.git diff --git a/src/relevance.c b/src/relevance.c index 1a9f4d7..a338917 100644 --- a/src/relevance.c +++ b/src/relevance.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2008 Index Data + Copyright (C) 2006-2009 Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -17,14 +17,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - #if HAVE_CONFIG_H -#include +#include #endif +#include +#include + #include "relevance.h" #include "pazpar2.h" @@ -284,31 +283,6 @@ void relevance_donerecord(struct relevance *r, struct record_cluster *cluster) r->doc_frequency_vec[0]++; } -#ifdef GAGA -#ifdef FLOAT_REL -static int comp(const void *p1, const void *p2) -{ - float res; - struct record **r1 = (struct record **) p1; - struct record **r2 = (struct record **) p2; - res = (*r2)->relevance - (*r1)->relevance; - if (res > 0) - return 1; - else if (res < 0) - return -1; - else - return 0; -} -#else -static int comp(const void *p1, const void *p2) -{ - struct record_cluster **r1 = (struct record_cluster **) p1; - struct record_cluster **r2 = (struct record_cluster **) p2; - return (*r2)->relevance - (*r1)->relevance; -} -#endif -#endif - // Prepare for a relevance-sorted read void relevance_prepare_read(struct relevance *rel, struct reclist *reclist) { @@ -334,10 +308,10 @@ void relevance_prepare_read(struct relevance *rel, struct reclist *reclist) } } // Calculate relevance for each document - for (i = 0; i < reclist->num_records; i++) + for (i = 0; i < reclist_get_num_records(reclist); i++) { int t; - struct record_cluster *rec = reclist->flatlist[i]; + struct record_cluster *rec = reclist_get_cluster(reclist, i); float relevance; relevance = 0; for (t = 1; t < rel->vec_len; t++) @@ -350,17 +324,16 @@ void relevance_prepare_read(struct relevance *rel, struct reclist *reclist) } rec->relevance = (int) (relevance * 100000); } -#ifdef GAGA - qsort(reclist->flatlist, reclist->num_records, sizeof(struct record*), comp); -#endif - reclist->pointer = 0; + reclist_rewind(reclist); xfree(idfvec); } /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +