pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / java / org / apache / lucene / search / payloads / PayloadFunction.java
1 package org.apache.lucene.search.payloads;
2 /**
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements.  See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License.  You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 import java.io.Serializable;
20 import org.apache.lucene.search.Explanation;
21
22 /**
23  * An abstract class that defines a way for Payload*Query instances to transform
24  * the cumulative effects of payload scores for a document.
25  * 
26  * @see org.apache.lucene.search.payloads.PayloadTermQuery for more information
27  * 
28  * @lucene.experimental This class and its derivations are experimental and subject to
29  *               change
30  * 
31  **/
32 public abstract class PayloadFunction implements Serializable {
33
34   /**
35    * Calculate the score up to this point for this doc and field
36    * @param docId The current doc
37    * @param field The field
38    * @param start The start position of the matching Span
39    * @param end The end position of the matching Span
40    * @param numPayloadsSeen The number of payloads seen so far
41    * @param currentScore The current score so far
42    * @param currentPayloadScore The score for the current payload
43    * @return The new current Score
44    *
45    * @see org.apache.lucene.search.spans.Spans
46    */
47   public abstract float currentScore(int docId, String field, int start, int end, int numPayloadsSeen, float currentScore, float currentPayloadScore);
48
49   /**
50    * Calculate the final score for all the payloads seen so far for this doc/field
51    * @param docId The current doc
52    * @param field The current field
53    * @param numPayloadsSeen The total number of payloads seen on this document
54    * @param payloadScore The raw score for those payloads
55    * @return The final score for the payloads
56    */
57   public abstract float docScore(int docId, String field, int numPayloadsSeen, float payloadScore);
58   
59   public Explanation explain(int docId, int numPayloadsSeen, float payloadScore){
60           Explanation result = new Explanation();
61           result.setDescription("Unimpl Payload Function Explain");
62           result.setValue(1);
63           return result;
64   };
65   
66   @Override
67   public abstract int hashCode();
68   
69   @Override
70   public abstract boolean equals(Object o);
71
72 }