From: Adam Dickmeiss Date: Wed, 4 Nov 2009 11:48:12 +0000 (+0100) Subject: Deal with empty fields for ranking X-Git-Tag: v1.2.3~2^2~8 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=6a3be08c0fb5c7ad1f14168435b3de51028945d2;p=pazpar2-moved-to-github.git Deal with empty fields for ranking Avoid division by length=0 in relevance_countwords. --- diff --git a/src/relevance.c b/src/relevance.c index 072a894..c88676e 100644 --- a/src/relevance.c +++ b/src/relevance.c @@ -114,7 +114,8 @@ void relevance_countwords(struct relevance *r, struct record_cluster *cluster, for (i = 1; i < r->vec_len; i++) { - cluster->term_frequency_vecf[i] += (double) mult[i] / length; + if (length > 0) /* only add if non-empty */ + cluster->term_frequency_vecf[i] += (double) mult[i] / length; cluster->term_frequency_vec[i] += mult[i]; } diff --git a/test/test_http_18.res b/test/test_http_18.res index eb81bff..77b4469 100644 --- a/test/test_http_18.res +++ b/test/test_http_18.res @@ -8,15 +8,15 @@ 3 -OIL/GAS DRILLING -This database contains information on oil and gas drilling such as well name, operator, driller, location, depth, copies of logs run, permits, samples (cuttings, core), completion records -OIL/GAS DRILLING -This database contains information on oil and gas drilling such as well name, operator, driller, location, depth, copies of logs run, permits, samples (cuttings, core), completion records -1907-PRESENT +BIBLIOGRAPHY OF MAINE GEOLOGY +This data base is a computer based bibliography of marine geology. It allows searching by topic and geographic location, similar to GEOREF. It is currently under development to replace the printed Bibliography of Marine Geology +BIBLIOGRAPHY OF MAINE GEOLOGY +This data base is a computer based bibliography of marine geology. It allows searching by topic and geographic location, similar to GEOREF. It is currently under development to replace the printed Bibliography of Marine Geology +1692-PRESENT test-usersetting-2 data: -0 -title oil gas drilling author medium book +9416 +title bibliography of maine geology author medium book @@ -27,19 +27,19 @@ 1972-1978 test-usersetting-2 data: --2147483648 +0 title groundwater resource maps county series author medium book -BIBLIOGRAPHY OF MAINE GEOLOGY -This data base is a computer based bibliography of marine geology. It allows searching by topic and geographic location, similar to GEOREF. It is currently under development to replace the printed Bibliography of Marine Geology -BIBLIOGRAPHY OF MAINE GEOLOGY -This data base is a computer based bibliography of marine geology. It allows searching by topic and geographic location, similar to GEOREF. It is currently under development to replace the printed Bibliography of Marine Geology -1692-PRESENT +OIL/GAS DRILLING +This database contains information on oil and gas drilling such as well name, operator, driller, location, depth, copies of logs run, permits, samples (cuttings, core), completion records +OIL/GAS DRILLING +This database contains information on oil and gas drilling such as well name, operator, driller, location, depth, copies of logs run, permits, samples (cuttings, core), completion records +1907-PRESENT test-usersetting-2 data: -9416 -title bibliography of maine geology author medium book +0 +title oil gas drilling author medium book