com.sun.labs.minion.retrieval
Class Proximity

java.lang.Object
  extended by com.sun.labs.minion.retrieval.QueryElement
      extended by com.sun.labs.minion.retrieval.Operator
          extended by com.sun.labs.minion.retrieval.Proximity
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
Near, Passage

public abstract class Proximity
extends Operator

An abstract class for all proximity operators. This class includes the methods common to all such operators.


Field Summary
protected  float gapPenalty
          The penalty to assign for a gap in a passage, per word.
protected static java.lang.String logTag
           
protected  int maxMissing
          The maximum number of terms that may be missing from a qualifying passage.
protected  int maxWindow
          The maximum window size for a qualifying passage.
protected  int minWindow
          The minimum window size for a qualifying passage.
protected  boolean[] ocTerms
          Which of the terms in the query were generated by ONECHAR operators?
protected  float oooPenalty
          The additionaly penalty to assign to a gap between terms that are out of order in the passage.
protected  QueryElement[] orderedOps
          The operands in the order in which they appear in the query.
protected  boolean storePassages
          Whether we need to store passages or no.
protected  DictTerm[] terms
          The dictionary terms from the query, in the order given in the query.
 
Fields inherited from class com.sun.labs.minion.retrieval.Operator
operands
 
Fields inherited from class com.sun.labs.minion.retrieval.QueryElement
estSize, fieldMultipliers, inOrder, keepPositions, order, part, qc, qs, searchFieldNames, searchFields, strictEval, wc, wf
 
Constructor Summary
Proximity(java.util.List operands)
          Builds a proximity operator from a list of operands.
 
Method Summary
protected  void arrayCopy(int[] src, int srcPos, int[] dst, int dstPos, int len)
           
protected  float calcPenalty(int[] posns)
          Calculates the penalty produced by a set of positions from a document.
protected  float checkPositions(ScoredGroup ag, int field, int[][] columns, int[] lens, boolean[] ocColumn, float[][] termPens)
          Finds qualifying passages in the given positions.
protected  ArrayGroup evalTerms(ArrayGroup candidates, java.util.List terms)
          Evaluates a set of terms against the current constraints, returning the results.
protected static java.lang.String printCols(int[][] columns, int[] lens)
           
protected  void setGap(float p)
          Sets the gap penalty.
protected  void setOOO(float p)
          Sets the out-of-order penalty.
protected  void setStorePassages(boolean b)
          Sets the flag indicating whether we should store passages when doing retrieval.
protected  void setWindow(int w)
          Sets the maximum window.
 
Methods inherited from class com.sun.labs.minion.retrieval.Operator
addSearchFieldName, getOperands, getQueryTerms, setOperands, setPartition, setQueryConfig, setWeightingComponents, setWeightingFunction, toString, toString, toStringMod
 
Methods inherited from class com.sun.labs.minion.retrieval.QueryElement
calculateEstimatedSize, compareTo, dump, estimateSize, eval, getInOrder, getOrder, getQueryStats, getQueryTerms, getSearchFieldNames, setInOrder, setOrder, setQueryStats, setSearchFields
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxMissing

protected int maxMissing
The maximum number of terms that may be missing from a qualifying passage.


minWindow

protected int minWindow
The minimum window size for a qualifying passage.


maxWindow

protected int maxWindow
The maximum window size for a qualifying passage.


gapPenalty

protected float gapPenalty
The penalty to assign for a gap in a passage, per word.


oooPenalty

protected float oooPenalty
The additionaly penalty to assign to a gap between terms that are out of order in the passage.


orderedOps

protected QueryElement[] orderedOps
The operands in the order in which they appear in the query.


terms

protected DictTerm[] terms
The dictionary terms from the query, in the order given in the query.


ocTerms

protected boolean[] ocTerms
Which of the terms in the query were generated by ONECHAR operators?


storePassages

protected boolean storePassages
Whether we need to store passages or no.


logTag

protected static java.lang.String logTag
Constructor Detail

Proximity

public Proximity(java.util.List operands)
Builds a proximity operator from a list of operands.

Method Detail

setOOO

protected void setOOO(float p)
Sets the out-of-order penalty.


setGap

protected void setGap(float p)
Sets the gap penalty.


setWindow

protected void setWindow(int w)
Sets the maximum window.


setStorePassages

protected void setStorePassages(boolean b)
Sets the flag indicating whether we should store passages when doing retrieval.


evalTerms

protected ArrayGroup evalTerms(ArrayGroup candidates,
                               java.util.List terms)
Evaluates a set of terms against the current constraints, returning the results.

Parameters:
candidates - A candidate set of documents, generated by one of the subclasses.
terms - The terms for which we wish to compute the proximity constraints. The list must contain instances of DictTerm.

calcPenalty

protected float calcPenalty(int[] posns)
Calculates the penalty produced by a set of positions from a document. This penalty includes any gap or out-of-order penalty. Inherent term penalties should be calculated separately and added to the return value of this method.

Parameters:
posns - The set of positions for which we wish to calculate the penalty. Missing terms may be indicated by values less than zero.
Returns:
The penalty associated with the given word positions.

checkPositions

protected float checkPositions(ScoredGroup ag,
                               int field,
                               int[][] columns,
                               int[] lens,
                               boolean[] ocColumn,
                               float[][] termPens)
Finds qualifying passages in the given positions.

Parameters:
ag - The ScoredGroup where we'll add our passages.
field - The ID of the field that we're currently processing.
columns - The word positions for each column, in order.
lens - The lengths of the columns.
ocColumn - If the ith element is true then the ith column was generated by a onchar operator.
termPens - The penalties inherent in the terms. Float.MIN_VALUE is returned.

printCols

protected static java.lang.String printCols(int[][] columns,
                                            int[] lens)

arrayCopy

protected void arrayCopy(int[] src,
                         int srcPos,
                         int[] dst,
                         int dstPos,
                         int len)