Fixed some bugs in index search.
authorviric@llimona
Tue, 07 Aug 2007 00:24:20 +0200
changeset 28 dccb4ae23699
parent 27 c17af5f11cdf
child 29 126fe21e0eeb
Fixed some bugs in index search. 1. Binary Search should not stop at match. There may be more than one match words in the index. 2. The SearchNextPrefixes skiped one each two words.
Makefile
src/jdict/DictIndex.java
--- a/Makefile	Sun Jul 29 23:53:08 2007 +0200
+++ b/Makefile	Tue Aug 07 00:24:20 2007 +0200
@@ -11,7 +11,7 @@
 SRCDIRS=${PRJ}
 PKGADDONS=dicts
 
-# TARJETS
+# TARGETS
 all:
 	@cd src && mkdir -p output ${SRCDIRS} ${PKGADDONS}
 	@echo "==> Building"
--- a/src/jdict/DictIndex.java	Sun Jul 29 23:53:08 2007 +0200
+++ b/src/jdict/DictIndex.java	Tue Aug 07 00:24:20 2007 +0200
@@ -332,14 +332,17 @@
             {
                 int offset = getOffset();
                 int length = getLength();
-                System.out.println("Definition for " + word + " at " +
+                System.out.println("Definition for " + word + "("
+                        + test + ") at " +
                         new Integer(offset).toString() +  " length " +
                         new Integer(length).toString());
                 /*String definition = defs.getDefinition(offset, length);*/
                 Vorto vorto = new Vorto(test, offset, length);
 
                 results.addElement(vorto);
-                readUntilNewLine();
+                System.out.println("Until now: " +
+                        new Integer(results.size()).toString());
+                /* readUntilNewLine(); */
             } else
             {
                 break;
@@ -359,8 +362,10 @@
         String test;
         do
         {
-            System.out.println("Pivoting to " +
+            /*
+             * System.out.println("Pivoting to " +
                     new Integer(pivot).toString());
+                    */
             try {
                 in.seekFromStart(pivot);
             } catch (IOException e)
@@ -373,21 +378,8 @@
             if (test == null)
                 break;
             int comparision = word.compareTo(test);
-            System.out.println("Comparing to " + test);
-            if (comparision == 0)
-            {
-                int offset = getOffset();
-                int length = getLength();
-                System.out.println("Definition for " + word + " at " +
-                        new Integer(offset).toString() +  " length " +
-                        new Integer(length).toString());
-
-                /*String definition = defs.getDefinition(offset, length);*/
-                Vorto vorto = new Vorto(test, offset, length);
-
-                results.addElement(vorto);
-                break;
-            } else if (comparision < 0)
+            /*System.out.println("Comparing to " + test);*/
+            if (comparision <= 0)
             {
                 step = step / 2;
                 pivot = pivot - step;