lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r1363714 - in /lucene/dev/branches/LUCENE-2878/lucene: core/src/java/org/apache/lucene/search/positions/ core/src/test/org/apache/lucene/search/positions/ highlighter/src/test/org/apache/lucene/search/highlight/positions/
Date Fri, 20 Jul 2012 10:48:04 GMT
Author: simonw
Date: Fri Jul 20 10:48:03 2012
New Revision: 1363714

URL: http://svn.apache.org/viewvc?rev=1363714&view=rev
Log:
LUCENE-2878: fix minimization bug in ConjunctionInterval

Modified:
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/ConjunctionIntervalIterator.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueue.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueAnd.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueOr.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestBasicIntervals.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestConjunctionIntervalIterator.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestDisjunctionIntervalIterator.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestPositionsAndOffsets.java
    lucene/dev/branches/LUCENE-2878/lucene/highlighter/src/test/org/apache/lucene/search/highlight/positions/IntervalHighlighterTest.java

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/ConjunctionIntervalIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/ConjunctionIntervalIterator.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/ConjunctionIntervalIterator.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/ConjunctionIntervalIterator.java
Fri Jul 20 10:48:03 2012
@@ -90,10 +90,7 @@ public final class ConjunctionIntervalIt
       }
       rightExtremeBegin = queue.rightExtremeBegin;
       advance();
-      if (queue.size() < nrMustMatch) {
-        break;
-      }
-    } while (queue.topContainsQueueInterval());
+    } while (queue.size() >= nrMustMatch && queue.currentCandidate.end == queue.rightExtreme);
     return queue.currentCandidate; // TODO support payloads
   }
   

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueue.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueue.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueue.java
Fri Jul 20 10:48:03 2012
@@ -36,8 +36,6 @@ abstract class IntervalQueue extends Pri
     currentCandidate.offsetEnd = -1;
   }
 
-  abstract public boolean topContainsQueueInterval();
-
   abstract public void updateCurrentCandidate();
 
   public IntervalQueue(int size) {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueAnd.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueAnd.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueAnd.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueAnd.java
Fri Jul 20 10:48:03 2012
@@ -46,12 +46,6 @@ final class IntervalQueueAnd extends Int
       rightExtremeBegin = interval.begin;
     }
   }
-  
-  public boolean topContainsQueueInterval() {
-    Interval interval = top().interval;
-    return interval.begin < currentCandidate.begin
-        && currentCandidate.end < rightExtreme;
-  }
  
   public void updateCurrentCandidate() {
     final IntervalRef top = top();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueOr.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueOr.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueOr.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/positions/IntervalQueueOr.java
Fri Jul 20 10:48:03 2012
@@ -25,12 +25,6 @@ final class IntervalQueueOr extends Inte
     super(size);
   }
   
-  public boolean topContainsQueueInterval() {
-    Interval interval = top().interval;
-    return interval.begin <= currentCandidate.begin
-        && currentCandidate.end <= interval.end;
-  }
-
   public void updateCurrentCandidate() {
     currentCandidate.copy(top().interval);
   }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestBasicIntervals.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestBasicIntervals.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestBasicIntervals.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestBasicIntervals.java
Fri Jul 20 10:48:03 2012
@@ -293,12 +293,7 @@ public class TestBasicIntervals extends 
       IntervalIterator iterator = scorer.positions();
       assertEquals(4, advanceIter(iterator, 4));
       Interval interval = iterator.next();
-      assertNotNull("Does not have next and it should", interval);
-      assertEquals("doc", 4, iterator.docID());
-      assertEquals("start", 0, interval.begin);
-      assertEquals("end", 2, interval.end);
-      
-      interval = iterator.next();
+
       assertNotNull("Does not have next and it should", interval);
       // unordered spans can be subsets
       assertEquals("doc", 4, iterator.docID());
@@ -306,11 +301,7 @@ public class TestBasicIntervals extends 
       assertEquals("end", 2, interval.end);
       
       advanceIter(iterator, 5);
-      interval = iterator.next();
-      assertNotNull("Does not have next and it should", interval);
-      assertEquals("doc", 5, iterator.docID());
-      assertEquals("start", 0, interval.begin);
-      assertEquals("end", 3, interval.end);
+
 
       interval = iterator.next();
       assertNotNull("Does not have next and it should", interval);
@@ -319,12 +310,7 @@ public class TestBasicIntervals extends 
       assertEquals("end", 3, interval.end);
       
       advanceIter(iterator, 8); // (u2 xx (u1 u2))
-      interval = iterator.next();
-      assertNotNull("Does not have next and it should", interval);
-      assertEquals("doc", 8, iterator.docID());
-      assertEquals("start", 0, interval.begin);
-      assertEquals("end", 3, interval.end);
-      
+
       interval = iterator.next();
       assertNotNull("Does not have next and it should", interval);
       assertEquals("doc", 8, iterator.docID());
@@ -338,12 +324,6 @@ public class TestBasicIntervals extends 
       assertEquals("start", 0, interval.begin);
       assertEquals("end", 1, interval.end);
       
-      // this on is tricky since the two terms are overlapping - need to find a solution
for this ie. dedicated query?
-//      interval = iterator.next(); 
-//      assertNotNull("Does not have next and it should", interval);
-//      assertEquals("doc", 9, iterator.docID());
-//      assertEquals("start", 0, interval.begin);
-//      assertEquals("end", 3, interval.end);
       interval = iterator.next();
       assertNull("Has next and it shouldn't", interval);
       

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestConjunctionIntervalIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestConjunctionIntervalIterator.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestConjunctionIntervalIterator.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestConjunctionIntervalIterator.java
Fri Jul 20 10:48:03 2012
@@ -108,11 +108,11 @@ public class TestConjunctionIntervalIter
         IntervalIterator positions = scorer.positions();
         assertEquals(0, positions.scorerAdvanced(nextDoc));
         Interval interval = null;
-        int[] start = new int[] {0, 1, 2, 3, 4, 6, 7, 31, 32, 33};
-        int[] end = new int[] {2, 3, 4, 33, 33, 33, 33, 33, 34, 35};
+        int[] start = new int[] {0, 1, 2, 31, 32, 33};
+        int[] end = new int[] {2, 3, 4, 33, 34, 35};
         // {start}term{end} - end is pos+1 
-        // {0}Pease {1}porridge {2}hot!{0} {3}Pease{1} {4}porridge{2} cold! {5}Pease {6}porridge
in the pot nine days old! Some like it hot, some"
-        // like it cold, Some like it in the pot nine days old! {7}Pease {8}porridge {9}hot!{3,4,5,6,7}
Pease{8} porridge{9} cold!",
+        // {0}Pease {1}porridge {2}hot!{0} Pease{1} porridge{2} cold! Pease porridge in the
pot nine days old! Some like it hot, some"
+        // like it cold, Some like it in the pot nine days old! {3}Pease {4}porridge {5}hot!{3}
Pease{4} porridge{5} cold!",
         for (int j = 0; j < end.length; j++) {
           interval = positions.next();
           assertNotNull("" + j, interval);
@@ -127,11 +127,11 @@ public class TestConjunctionIntervalIter
         IntervalIterator positions = scorer.positions();
         assertEquals(1, positions.scorerAdvanced(nextDoc));
         Interval interval = null;
-        int[] start = new int[] {0, 1, 3, 4, 5, 6, 7, 31, 32, 34 };
-        int[] end = new int[] {5, 5, 5, 6, 7, 36, 36, 36, 36, 36 };
+        int[] start = new int[] {3, 4, 5, 34 };
+        int[] end = new int[] {5, 6, 7, 36 };
         // {start}term{end} - end is pos+1
-        // {0}Pease {1}porridge cold! {2}Pease {3}porridge {4}hot!{0, 1, 2, 3} {5}Pease {4,
6}porridge in the pot nine days old! Some like it cold, some
-        // like it hot, Some like it in the pot nine days old! {7}Pease {8}porridge cold!
{9}Pease porridge hot{5, 6, 7, 8, 9}!
+        // {0}Pease {1}porridge cold! {0}Pease {1}porridge {2}hot!{0} Pease{1} porridge{2}
in the pot nine days old! Some like it cold, some
+        // like it hot, Some like it in the pot nine days old! Pease porridge cold! {4}Pease
porridge hot{4}!
         for (int j = 0; j < end.length; j++) {
           interval = positions.next();
           assertNotNull(interval);

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestDisjunctionIntervalIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestDisjunctionIntervalIterator.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestDisjunctionIntervalIterator.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestDisjunctionIntervalIterator.java
Fri Jul 20 10:48:03 2012
@@ -166,14 +166,11 @@ public class TestDisjunctionIntervalIter
         IntervalIterator positions = scorer.positions();
         assertEquals(0, positions.scorerAdvanced(nextDoc));
         Interval interval = null;
-        int[] start = new int[] { 0, 1, 2, 3, 4, 6, 7, 31, 32, 33 };
-        int[] end = new int[] { 2, 3, 4, 33, 33, 33, 33, 33, 34, 35 };
-        // {start}term{end} - end is pos+1
-        // {0}Pease {1}porridge {2}hot!{0} {3}Pease{1} {4}porridge{2} cold!
-        // {5}Pease {6}porridge in the pot nine days old! Some like it hot,
-        // some"
-        // like it cold, Some like it in the pot nine days old! {7}Pease
-        // {8}porridge {9}hot!{3,4,5,6,7} Pease{8} porridge{9} cold!",
+        int[] start = new int[] { 0, 1, 2, 31, 32, 33 };
+        int[] end = new int[] { 2, 3, 4, 33, 34, 35 };
+     // {start}term{end} - end is pos+1 
+        // {0}Pease {1}porridge {2}hot!{0} Pease{1} porridge{2} cold! Pease porridge in the
pot nine days old! Some like it hot, some"
+        // like it cold, Some like it in the pot nine days old! {3}Pease {4}porridge {5}hot!{3}
Pease{4} porridge{5} cold!",
         for (int j = 0; j < end.length; j++) {
           interval = positions.next();
           assertNotNull("" + j, interval);
@@ -188,14 +185,11 @@ public class TestDisjunctionIntervalIter
         IntervalIterator positions = scorer.positions();
         assertEquals(1, positions.scorerAdvanced(nextDoc));
         Interval interval = null;
-        int[] start = new int[] { 0, 1, 3, 4, 5, 6, 7, 31, 32, 34 };
-        int[] end = new int[] { 5, 5, 5, 6, 7, 36, 36, 36, 36, 36 };
+        int[] start = new int[] {  3, 4, 5, 34 };
+        int[] end = new int[] { 5, 6, 7, 36 };
         // {start}term{end} - end is pos+1
-        // {0}Pease {1}porridge cold! {2}Pease {3}porridge {4}hot!{0, 1, 2, 3}
-        // {5}Pease {4, 6}porridge in the pot nine days old! Some like it cold,
-        // some
-        // like it hot, Some like it in the pot nine days old! {7}Pease
-        // {8}porridge cold! {9}Pease porridge hot{5, 6, 7, 8, 9}!
+        // {0}Pease {1}porridge cold! {0}Pease {1}porridge {2}hot!{0} Pease{1} porridge{2}
in the pot nine days old! Some like it cold, some
+        // like it hot, Some like it in the pot nine days old! Pease porridge cold! {4}Pease
porridge hot{4}!
         for (int j = 0; j < end.length; j++) {
           interval = positions.next();
           assertNotNull(interval);

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestPositionsAndOffsets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestPositionsAndOffsets.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestPositionsAndOffsets.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/positions/TestPositionsAndOffsets.java
Fri Jul 20 10:48:03 2012
@@ -134,8 +134,8 @@ public class TestPositionsAndOffsets ext
         BooleanClause.Occur.MUST));
     query.add(new BooleanClause(new TermQuery(new Term("field", "nine")),
         BooleanClause.Occur.MUST));
-    int[] startOffsetsConj = new int[] {6, 26, 47, 67, 143};
-    int[] endOffsetsConj = new int[] {71, 71, 71, 172, 172};
+    int[] startOffsetsConj = new int[] {47,143};
+    int[] endOffsetsConj = new int[] {71, 172};
     testQuery(query, new int[][] {startOffsetsConj, endOffsetsConj});
   }
    

Modified: lucene/dev/branches/LUCENE-2878/lucene/highlighter/src/test/org/apache/lucene/search/highlight/positions/IntervalHighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/highlighter/src/test/org/apache/lucene/search/highlight/positions/IntervalHighlighterTest.java?rev=1363714&r1=1363713&r2=1363714&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/highlighter/src/test/org/apache/lucene/search/highlight/positions/IntervalHighlighterTest.java
(original)
+++ lucene/dev/branches/LUCENE-2878/lucene/highlighter/src/test/org/apache/lucene/search/highlight/positions/IntervalHighlighterTest.java
Fri Jul 20 10:48:03 2012
@@ -465,10 +465,10 @@ public class IntervalHighlighterTest ext
     assertSloppyPhrase( "A X A", null, 1, "X", "A", "A");
 
     assertSloppyPhrase( "A X B A", "<B>A</B> <B>X</B> B <B>A</B>",
2, "X", "A", "A");
-    assertSloppyPhrase( "A A X A X B A X B B A A X B A A", "A <B>A</B> <B>X</B>
<B>A</B> X B <B>A</B> <B>X</B> B B <B>A</B>
<B>A</B> <B>X</B> B <B>A</B> <B>A</B>", 2,
"X", "A", "A");
-    assertSloppyPhrase( "A A X A X B A X B B A A X B A A", "A <B>A</B> <B>X</B>
<B>A</B> X B <B>A</B> <B>X</B> B B <B>A</B>
<B>A</B> <B>X</B> B <B>A</B> <B>A</B>", 2,
"X", "A", "A");
+    assertSloppyPhrase( "A A X A X B A X B B A A X B A A", "A <B>A</B> <B>X</B>
<B>A</B> <B>X</B> B <B>A</B> <B>X</B> B B
<B>A</B> <B>A</B> <B>X</B> B <B>A</B> <B>A</B>",
2, "X", "A", "A");
+    assertSloppyPhrase( "A A X A X B A X B B A A X B A A", "A <B>A</B> <B>X</B>
<B>A</B> <B>X</B> B <B>A</B> <B>X</B> B B
<B>A</B> <B>A</B> <B>X</B> B <B>A</B> <B>A</B>",
2, "X", "A", "A");
 
-    assertSloppyPhrase( "A A X A X B A", "A <B>A</B> <B>X</B> <B>A</B>
X B <B>A</B>", 2, "X", "A", "A");
+    assertSloppyPhrase( "A A X A X B A", "A <B>A</B> <B>X</B> <B>A</B>
<B>X</B> B <B>A</B>", 2, "X", "A", "A");
     assertSloppyPhrase( "A A Y A X B A", "A A Y <B>A</B> <B>X</B>
B <B>A</B>", 2, "X", "A", "A");
     assertSloppyPhrase( "A A Y A X B A A", "A A Y <B>A</B> <B>X</B>
B <B>A</B> <B>A</B>", 2, "X", "A", "A");
     assertSloppyPhrase( "A A X A Y B A", null , 1, "X", "A", "A");



Mime
View raw message