X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fsnippet.c;h=6d45a01a91d8e36dd26dee68dd2e8ef2a6b0beec;hb=d64c82cd05145e97c4edef0434c383a29c95c8fe;hp=bca55efb239d934f82a012ca576307e54ac7a331;hpb=5498d6d66ab0f3639b6d4517cad14f2ba25b7553;p=idzebra-moved-to-github.git diff --git a/util/snippet.c b/util/snippet.c index bca55ef..6d45a01 100644 --- a/util/snippet.c +++ b/util/snippet.c @@ -1,5 +1,5 @@ -/* $Id: snippet.c,v 1.2 2005-06-07 13:10:52 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: snippet.c,v 1.12 2007-01-15 15:10:26 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include @@ -31,7 +31,7 @@ struct zebra_snippets { zebra_snippet_word *tail; }; -zebra_snippets *zebra_snippets_create() +zebra_snippets *zebra_snippets_create(void) { NMEM nmem = nmem_create(); zebra_snippets *l = nmem_malloc(nmem, sizeof(*l)); @@ -95,28 +95,30 @@ zebra_snippets *zebra_snippets_window(zebra_snippets *doc, zebra_snippets *hit, while(1) { - int window_start; + zint window_start; + zint first_seq_no_best_window = 0; + zint last_seq_no_best_window = 0; + int number_best_window = 0; zebra_snippet_word *hit_w, *doc_w; int min_ord = 0; /* not set yet */ + for (hit_w = zebra_snippets_list(hit); hit_w; hit_w = hit_w->next) if (hit_w->ord > ord && (min_ord == 0 || hit_w->ord < min_ord)) + { min_ord = hit_w->ord; + } if (min_ord == 0) break; ord = min_ord; - int first_seq_no_best_window = 0; - int last_seq_no_best_window = 0; - int number_best_window = 0; - for (hit_w = zebra_snippets_list(hit); hit_w; hit_w = hit_w->next) { if (hit_w->ord == ord) { zebra_snippet_word *look_w = hit_w; int number_this = 0; - int seq_no_last = 0; + zint seq_no_last = 0; while (look_w && look_w->seqno < hit_w->seqno + window_size) { if (look_w->ord == ord) @@ -134,20 +136,23 @@ zebra_snippets *zebra_snippets_window(zebra_snippets *doc, zebra_snippets *hit, } } } - yaz_log(YLOG_LOG, "ord=%d", ord); - yaz_log(YLOG_LOG, "first_seq_no_best_window=%d", first_seq_no_best_window); - yaz_log(YLOG_LOG, "last_seq_no_best_window=%d", last_seq_no_best_window); - yaz_log(YLOG_LOG, "number_best_window=%d", number_best_window); + yaz_log(YLOG_DEBUG, "ord=%d", ord); + yaz_log(YLOG_DEBUG, "first_seq_no_best_window=" ZINT_FORMAT, + first_seq_no_best_window); + yaz_log(YLOG_DEBUG, "last_seq_no_best_window=" ZINT_FORMAT, + last_seq_no_best_window); + yaz_log(YLOG_DEBUG, "number_best_window=%d", number_best_window); window_start = (first_seq_no_best_window + last_seq_no_best_window - window_size) / 2; for (doc_w = zebra_snippets_list(doc); doc_w; doc_w = doc_w->next) - if (doc_w->ord == ord + if (doc_w->ord == ord && doc_w->seqno >= window_start && doc_w->seqno < window_start + window_size) { int match = 0; - for (hit_w = zebra_snippets_list(hit); hit_w; hit_w = hit_w->next) + for (hit_w = zebra_snippets_list(hit); hit_w; + hit_w = hit_w->next) { if (hit_w->ord == ord && hit_w->seqno == doc_w->seqno) @@ -156,10 +161,18 @@ zebra_snippets *zebra_snippets_window(zebra_snippets *doc, zebra_snippets *hit, break; } } - zebra_snippets_append_match(result, doc_w->seqno, ord, - doc_w->term, match); + zebra_snippets_append_match(result, doc_w->seqno, + ord, doc_w->term, match); } } return result; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +