}
}
- 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;