groonga/groonga — pull request #155 by kou (2014-03-04 14:20:30+00:00)
Title: Change the default internal weight to 1 from 0

If the default internal weight is 0, "weight 10" produces "score
11". It is strange.

The following chunks in ii.c may be wrong:

@@ -5705,7 +5705,7 @@ grn_ii_similar_search(grn_ctx *ctx, grn_ii *ii,
while (grn_ii_cursor_next(ctx, c)) {
pos = c->post;
if ((w2 = get_weight(ctx, s, pos->rid, pos->sid, wvm, optarg))) {
- res_add(ctx, s, (grn_rset_posinfo *) pos, *w1 * w2 * (pos->tf + pos->weight), op);
+ res_add(ctx, s, (grn_rset_posinfo *) pos, *w1 * w2 * pos->tf * pos->weight, op);
}
}
}

@@ -5926,6 +5926,7 @@ grn_ii_select(grn_ctx *ctx, grn_ii *ii, const char *string, unsigned int string_
if (max - min <= max_interval) {
if (rep) { pi.pos = min; res_add(ctx, s, &pi, weight, op); }
noccur++;
+ tscore += ti->p->weight; /* FIXME: Is it right? */
if (ti->pos == max + 1) {
break;
}

@@ -5950,14 +5951,14 @@ grn_ii_select(grn_ctx *ctx, grn_ii *ii, const char *string, unsigned int string_
...
- tscore += score;
+ tscore += score / count;
score = 0; count = 0; pos++;
noccur++;
...

@@ -5950,14 +5951,14 @@ grn_ii_select(grn_ctx *ctx, grn_ii *ii, const char *string, unsigned int string_
...
}
}
}
- if (noccur && !rep) { res_add(ctx, s, &pi, (noccur + tscore) * weight, op); }
+ if (noccur && !rep) { res_add(ctx, s, &pi, (noccur * tscore) * weight, op); }