Merge remote-tracking branch 'origin/master' into ranking-h
authorHeikki Levanto <heikki@indexdata.dk>
Wed, 4 Dec 2013 14:38:42 +0000 (15:38 +0100)
committerHeikki Levanto <heikki@indexdata.dk>
Wed, 4 Dec 2013 14:38:42 +0000 (15:38 +0100)
1  2 
src/reclists.c
src/relevance.c
src/relevance.h
src/session.c

diff --cc src/reclists.c
Simple merge
diff --cc src/relevance.c
@@@ -357,41 -318,37 +357,50 @@@ void relevance_destroy(struct relevanc
      }
  }
  
- void relevance_newrec(struct relevance *r, struct record_cluster *rec)
+ void relevance_mergerec(struct relevance *r, struct record_cluster *dst,
+                         const struct record_cluster *src)
  {
-     if (!rec->term_frequency_vec)
-     {
-         int i;
+     int i;
  
-         // term frequency [1,..] . [0] is total length of all fields
-         rec->term_frequency_vec =
-             nmem_malloc(r->nmem,
-                         r->vec_len * sizeof(*rec->term_frequency_vec));
-         for (i = 0; i < r->vec_len; i++)
-             rec->term_frequency_vec[i] = 0;
+     for (i = 0; i < r->vec_len; i++)
+         dst->term_frequency_vec[i] += src->term_frequency_vec[i];
  
-         // term frequency divided by length of field [1,...]
-         rec->term_frequency_vecf =
-             nmem_malloc(r->nmem,
-                         r->vec_len * sizeof(*rec->term_frequency_vecf));
-         for (i = 0; i < r->vec_len; i++)
-             rec->term_frequency_vecf[i] = 0.0;
-     }
+     for (i = 0; i < r->vec_len; i++)
+         dst->term_frequency_vecf[i] += src->term_frequency_vecf[i];
+ }
+ void relevance_newrec(struct relevance *r, struct record_cluster *rec)
+ {
+     int i;
+     // term frequency [1,..] . [0] is total length of all fields
+     rec->term_frequency_vec =
+         nmem_malloc(r->nmem,
+                     r->vec_len * sizeof(*rec->term_frequency_vec));
+     for (i = 0; i < r->vec_len; i++)
+         rec->term_frequency_vec[i] = 0;
+     // term frequency divided by length of field [1,...]
+     rec->term_frequency_vecf =
+         nmem_malloc(r->nmem,
+                     r->vec_len * sizeof(*rec->term_frequency_vecf));
+     for (i = 0; i < r->vec_len; i++)
+         rec->term_frequency_vecf[i] = 0.0;
  }
  
 +static const char *getfield(struct record *bestrecord, const char *tag)
 +{
 +    struct session *se = client_get_session(bestrecord->client);
 +    int md_field_id = conf_service_metadata_field_id(se->service, tag);
 +    struct record_metadata *md = 0;
 +    if (md_field_id <0)
 +        return "";
 +    md = bestrecord->metadata[md_field_id];
 +    if ( md)
 +        return md->data.text.disp;
 +    return "";
 +}
 +
  void relevance_donerecord(struct relevance *r, struct record_cluster *cluster)
  {
      int i;
diff --cc src/relevance.h
Simple merge
diff --cc src/session.c
Simple merge