Changeset 7b606608302021d361c250f0cb83e6c92a50d294
- Timestamp:
- 04/28/08 13:06:54 (8 months ago)
- Author:
- David Balmain <dbalmain@…>
- Parents:
- 2f5dc9c8dce95e8e8ac5d32256e9c9ff16052fc8
- Children:
- 88af924cc987bc50098df966cc16b84e4213a7fe
- git-committer:
- David Balmain <dbalmain@gmail.com> / 2008-04-28T13:06:54Z+1000
- Message:
-
Fixed a bug in Searcher#get_weight
* also improved test coverage for PhraseQuery
- Location:
- c
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r8f4fd0
|
r7b6066
|
|
| 908 | 908 | #define term_hash frt_term_hash |
| 909 | 909 | #define term_new frt_term_new |
| 910 | | #define term_set_new frt_term_set_new |
| 911 | 910 | #define tf_new_i frt_tf_new_i |
| 912 | 911 | #define thread_exit frt_thread_exit |
-
|
r950230
|
r7b6066
|
|
| 11 | 11 | * |
| 12 | 12 | ****************************************************************************/ |
| 13 | | |
| 14 | | #define frt_term_set_new() \ |
| 15 | | frt_hs_new((hash_ft)&frt_term_hash, (eq_ft)&frt_term_eq, (free_ft)&frt_term_destroy) |
| 16 | 13 | |
| 17 | 14 | typedef struct FrtTerm |
-
|
r2f5dc9
|
r7b6066
|
|
| 565 | 565 | tps[i] = mtdpe_new(ir, field_num, terms, t_cnt); |
| 566 | 566 | } |
| 567 | | if (tps[i] == NULL) { |
| 568 | | /* free everything we just created and return NULL */ |
| 569 | | int j; |
| 570 | | for (j = 0; j < i; j++) { |
| 571 | | tps[i]->close(tps[i]); |
| 572 | | } |
| 573 | | free(tps); |
| 574 | | return NULL; |
| 575 | | } |
| | 567 | /* neither mtdpe_new nor ir->term_positions should return NULL */ |
| | 568 | assert(NULL != tps[i]); |
| 576 | 569 | } |
| 577 | 570 | |
-
|
r0c11a5
|
r7b6066
|
|
| 1398 | 1398 | static Similarity *cdfsea_get_similarity(Searcher *self) |
| 1399 | 1399 | { |
| 1400 | | (void)self; |
| 1401 | | RAISE(UNSUPPORTED_ERROR, UNSUPPORTED_ERROR_MSG); |
| 1402 | | return NULL; |
| | 1400 | return self->similarity; |
| 1403 | 1401 | } |
| 1404 | 1402 | |
| … |
… |
|
| 1416 | 1414 | CDFSEA(self)->max_doc = max_doc; |
| 1417 | 1415 | |
| | 1416 | self->similarity = sim_create_default(); |
| 1418 | 1417 | self->doc_freq = &cdfsea_doc_freq; |
| 1419 | 1418 | self->get_doc = &cdfsea_get_doc; |
| … |
… |
|
| 1515 | 1514 | static Weight *msea_create_weight(Searcher *self, Query *query) |
| 1516 | 1515 | { |
| 1517 | | Jx |
| 1518 | 1516 | int i, *doc_freqs; |
| 1519 | 1517 | Searcher *cdfsea; |
| 1520 | 1518 | Weight *w; |
| 1521 | | Hash *df_map = h_new((hash_ft)&term_hash, (eq_ft)&term_eq, |
| 1522 | | (free_ft)NULL, free); |
| | 1519 | Hash *df_map = h_new((hash_ft)&term_hash, |
| | 1520 | (eq_ft)&term_eq, |
| | 1521 | (free_ft)term_destroy, |
| | 1522 | free); |
| 1523 | 1523 | Query *rewritten_query = self->rewrite(self, query); |
| 1524 | | HashSet *terms = term_set_new(); |
| | 1524 | /* terms get copied directly to df_map so no need to free here */ |
| | 1525 | HashSet *terms = frt_hs_new((hash_ft)&frt_term_hash, |
| | 1526 | (eq_ft)&frt_term_eq, |
| | 1527 | (free_ft)NULL); |
| 1525 | 1528 | HashSetEntry *hse; |
| 1526 | 1529 | |
-
|
r8f4fd0
|
r7b6066
|
|
| 517 | 517 | Query *q; |
| 518 | 518 | Query *phq = phq_new(field); |
| | 519 | Weight *w; |
| | 520 | char *t, e[100]; |
| 519 | 521 | check_to_s(tc, phq, field, "\"\""); |
| 520 | 522 | check_to_s(tc, phq, NULL, "field:\"\""); |
| 521 | 523 | |
| | 524 | |
| 522 | 525 | phq_add_term(phq, "quick", 1); |
| 523 | 526 | phq_add_term(phq, "brown", 1); |
| … |
… |
|
| 529 | 532 | phq_set_slop(phq, 4); |
| 530 | 533 | check_hits(tc, searcher, phq, "1, 16, 17", 17); |
| | 534 | |
| | 535 | /* test PhraseWeight.to_s */ |
| | 536 | w = searcher->create_weight(searcher, phq); |
| | 537 | sprintf(e, "PhraseWeight(%f)", w->value); |
| | 538 | t = w->to_s(w); Asnequal(e, t, 17); free(t); |
| | 539 | phq->boost = 10.5f; |
| | 540 | sprintf(e, "PhraseWeight(%f)", w->value); |
| | 541 | t = w->to_s(w); Asnequal(e, t, 17); free(t); |
| | 542 | w->destroy(w); |
| | 543 | |
| 531 | 544 | q_deref(phq); |
| 532 | 545 | |