Put local variables footer in all c, h files.
[idzebra-moved-to-github.git] / util / snippet.c
index c7222dd..3bc028e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: snippet.c,v 1.1 2005-06-07 11:36:43 adam Exp $
+/* $Id: snippet.c,v 1.6 2006-05-10 08:13:46 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -90,24 +90,28 @@ zebra_snippets *zebra_snippets_window(zebra_snippets *doc, zebra_snippets *hit,
     int ord = -1;
 
     zebra_snippets *result = zebra_snippets_create();
+    if (window_size == 0)
+       window_size = 1000000;
 
     while(1)
     {
        int window_start;
+       int first_seq_no_best_window = 0;
+       int 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)
@@ -132,20 +136,21 @@ 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=%d", first_seq_no_best_window);
+       yaz_log(YLOG_DEBUG, "last_seq_no_best_window=%d", 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)
                        
@@ -154,10 +159,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
+ */
+