You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by ot...@apache.org on 2004/02/02 14:27:52 UTC

cvs commit: jakarta-lucene/src/java/org/apache/lucene/search/spans NearSpans.java SpanFirstQuery.java SpanNearQuery.java SpanNotQuery.java SpanOrQuery.java SpanQuery.java SpanQueue.java SpanScorer.java SpanTermQuery.java SpanWeight.java Spans.java

otis        2004/02/02 05:27:52

  Modified:    src/java/org/apache/lucene/search/spans NearSpans.java
                        SpanFirstQuery.java SpanNearQuery.java
                        SpanNotQuery.java SpanOrQuery.java SpanQuery.java
                        SpanQueue.java SpanScorer.java SpanTermQuery.java
                        SpanWeight.java Spans.java
  Log:
  - Added ASL 2.0
  
  Revision  Changes    Path
  1.2       +27 -11    jakarta-lucene/src/java/org/apache/lucene/search/spans/NearSpans.java
  
  Index: NearSpans.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/NearSpans.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NearSpans.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ NearSpans.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.List;
  @@ -10,7 +26,7 @@
   
   class NearSpans implements Spans {
     private SpanNearQuery query;
  -                                                  
  +
     private List ordered = new ArrayList();         // spans in query order
     private int slop;                               // from query
     private boolean inOrder;                        // from query
  @@ -34,9 +50,9 @@
       private Spans spans;
       private SpansCell next;
       private int length = -1;
  -          
  +
       public SpansCell(Spans spans) { this.spans = spans; }
  -          
  +
       public boolean next() throws IOException {
         if (length != -1)                           // subtract old length
           totalLength -= length;
  @@ -94,7 +110,7 @@
         ordered.add(cell);                          // add to ordered
       }
     }
  -        
  +
     public boolean next() throws IOException {
       if (firstTime) {
         initList(true);
  @@ -104,17 +120,17 @@
         more = last.next();                         // trigger scan
         queueStale = true;
       }
  -          
  +
       while (more) {
   
         if (listStale) {                            // maintain list
           queueToList();
           listStale = false;
         }
  -      
  +
         // skip to doc w/ all clauses
   
  -      while (more && first.doc() < last.doc()) { 
  +      while (more && first.doc() < last.doc()) {
           more = first.skipTo(last.doc());          // skip first upto last
           firstToLast();                            // and move it to the end
           queueStale = true;
  @@ -125,7 +141,7 @@
         // found doc w/ all clauses
   
         if (queueStale) {                           // maintain the queue
  -        listToQueue();                    
  +        listToQueue();
           queueStale = false;
         }
   
  @@ -134,7 +150,7 @@
             && (!inOrder || matchIsOrdered())) {    // check order
           return true;
         }
  -      
  +
         more = min().next();                        // trigger further scanning
   
         if (more) {
  @@ -169,7 +185,7 @@
         }
         return next();                              // no, scan
       }
  -    
  +
       return false;
     }
   
  @@ -221,7 +237,7 @@
         queue.put(cell);                      // build queue from list
       }
     }
  -        
  +
     private boolean matchIsOrdered() {
       int lastStart = -1;
       for (int i = 0; i < ordered.size(); i++) {
  
  
  
  1.2       +17 -1     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java
  
  Index: SpanFirstQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanFirstQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanFirstQuery.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanFirstQuery.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.Collection;
  @@ -56,7 +72,7 @@
   
             if (spans.end() <= end)                 // there is a match
               return true;
  -          
  +
             return next();                          // scan to next match
           }
   
  
  
  
  1.2       +17 -1     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
  
  Index: SpanNearQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanNearQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanNearQuery.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanNearQuery.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.Collection;
  @@ -37,7 +53,7 @@
         }
         this.clauses.add(clause);
       }
  -    
  +
       this.slop = slop;
       this.inOrder = inOrder;
     }
  
  
  
  1.2       +21 -5     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
  
  Index: SpanNotQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanNotQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanNotQuery.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanNotQuery.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.Collection;
  @@ -55,10 +71,10 @@
               moreInclude = includeSpans.next();
   
             while (moreInclude && moreExclude) {
  -            
  +
               if (includeSpans.doc() > excludeSpans.doc()) // skip exclude
                 moreExclude = excludeSpans.skipTo(includeSpans.doc());
  -            
  +
               while (moreExclude                    // while exclude is before
                      && includeSpans.doc() == excludeSpans.doc()
                      && excludeSpans.end() <= includeSpans.start()) {
  @@ -69,9 +85,9 @@
                   || includeSpans.doc() != excludeSpans.doc()
                   || includeSpans.end() <= excludeSpans.start())
                 break;                              // we found a match
  -            
  +
               moreInclude = includeSpans.next();    // intersected: keep scanning
  -          }            
  +          }
             return moreInclude;
           }
   
  @@ -96,7 +112,7 @@
                   || includeSpans.doc() != excludeSpans.doc()
                   || includeSpans.end() <= excludeSpans.start())
               return true;                          // we found a match
  -          
  +
             return next();                          // scan to next match
           }
   
  
  
  
  1.2       +18 -2     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
  
  Index: SpanOrQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanOrQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanOrQuery.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanOrQuery.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.List;
  @@ -73,10 +89,10 @@
           {
             Iterator i = clauses.iterator();
             while (i.hasNext()) {                   // initialize all
  -            all.add(((SpanQuery)i.next()).getSpans(reader)); 
  +            all.add(((SpanQuery)i.next()).getSpans(reader));
             }
           }
  -        
  +
           private boolean firstTime = true;
   
           public boolean next() throws IOException {
  
  
  
  1.2       +16 -0     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanQuery.java
  
  Index: SpanQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanQuery.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanQuery.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.Collection;
  
  
  
  1.2       +16 -0     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanQueue.java
  
  Index: SpanQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanQueue.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanQueue.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanQueue.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import org.apache.lucene.util.PriorityQueue;
   
   class SpanQueue extends PriorityQueue {
  
  
  
  1.2       +16 -0     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanScorer.java
  
  Index: SpanScorer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanScorer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanScorer.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanScorer.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import org.apache.lucene.index.IndexReader;
  
  
  
  1.2       +17 -1     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
  
  Index: SpanTermQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanTermQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanTermQuery.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanTermQuery.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.Collection;
  @@ -42,7 +58,7 @@
           private int freq;
           private int count;
           private int position;
  -        
  +
           public boolean next() throws IOException {
             if (count == freq) {
               if (!positions.next())
  
  
  
  1.2       +22 -6     jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanWeight.java
  
  Index: SpanWeight.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/SpanWeight.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpanWeight.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ SpanWeight.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   import java.util.Iterator;
  @@ -43,7 +59,7 @@
     public void normalize(float queryNorm) {
       this.queryNorm = queryNorm;
       queryWeight *= queryNorm;                     // normalize query weight
  -    value = queryWeight * idf;                    // idf for document 
  +    value = queryWeight * idf;                    // idf for document
     }
   
     public Scorer scorer(IndexReader reader) throws IOException {
  @@ -74,7 +90,7 @@
   
       Explanation idfExpl =
         new Explanation(idf, "idf(" + field + ": " + docFreqs + ")");
  -      
  +
       // explain query weight
       Explanation queryExpl = new Explanation();
       queryExpl.setDescription("queryWeight(" + getQuery() + "), product of:");
  @@ -83,16 +99,16 @@
       if (getQuery().getBoost() != 1.0f)
         queryExpl.addDetail(boostExpl);
       queryExpl.addDetail(idfExpl);
  -      
  +
       Explanation queryNormExpl = new Explanation(queryNorm,"queryNorm");
       queryExpl.addDetail(queryNormExpl);
  -      
  +
       queryExpl.setValue(boostExpl.getValue() *
                          idfExpl.getValue() *
                          queryNormExpl.getValue());
   
       result.addDetail(queryExpl);
  -     
  +
       // explain field weight
       Explanation fieldExpl = new Explanation();
       fieldExpl.setDescription("fieldWeight("+field+":"+query.toString(field)+
  @@ -113,7 +129,7 @@
       fieldExpl.setValue(tfExpl.getValue() *
                          idfExpl.getValue() *
                          fieldNormExpl.getValue());
  -      
  +
       result.addDetail(fieldExpl);
   
       // combine them
  
  
  
  1.2       +17 -1     jakarta-lucene/src/java/org/apache/lucene/search/spans/Spans.java
  
  Index: Spans.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/spans/Spans.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Spans.java	30 Jan 2004 22:10:00 -0000	1.1
  +++ Spans.java	2 Feb 2004 13:27:52 -0000	1.2
  @@ -1,5 +1,21 @@
   package org.apache.lucene.search.spans;
   
  +/**
  + * Copyright 2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.IOException;
   
   /** Expert: an enumeration of span matches.  Used to implement span searching.
  @@ -10,7 +26,7 @@
     /** Move to the next match, returning true iff any such exists. */
     boolean next() throws IOException;
   
  -  /** Skips to the first match beyond the current whose document number is
  +  /** Skips to the first match beyond the current, whose document number is
      * greater than or equal to <i>target</i>. <p>Returns true iff there is such
      * a match.  <p>Behaves as if written: <pre>
      *   boolean skipTo(int target) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org