com.sun.labs.minion.retrieval
Class DictTerm

java.lang.Object
  extended by com.sun.labs.minion.retrieval.QueryElement
      extended by com.sun.labs.minion.retrieval.QueryTerm
          extended by com.sun.labs.minion.retrieval.DictTerm
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator
Direct Known Subclasses:
MultiDictTerm

public class DictTerm
extends QueryTerm
implements java.util.Comparator

A concrete subclass of QueryTerm that represents a term taken from one of the main dictionaries for a partition. Note that a term can be represented by several actual dictionary entries.

This class implements Comparator so that we can sort the terms based on their frequency.


Field Summary
protected  QueryEntry[] dictEntries
          The list of entries that were pulled from the dictionary for the current partition.
protected  PostingsIteratorFeatures feat
           
protected  java.lang.String[] knowledgeVariants
          The set of morphological variations of the term as computed by the lightweight morphology.
protected static java.lang.String logTag
           
protected  PosPostingsIterator[] pis
          A set of postings iterators for the terms that can be used to get position info for proximity queries or for highlighting.
protected  int[][] posns
          An array that will hold per-field word positions.
protected  java.lang.String[] semanticVariants
          The array of semantic variantions of the term as returned from the taxonomies of all the partitions.
 
Fields inherited from class com.sun.labs.minion.retrieval.QueryTerm
doExpand, doMorph, doStem, doWild, loadPositions, matchCase, val
 
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
DictTerm(java.lang.String val)
          Creates a dictionary term for a given query term.
 
Method Summary
protected  int calculateEstimatedSize()
          Returns the already calculated estimated size.
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two terms by their respective term frequencies.
 boolean equals(java.lang.Object object)
          Compares this comparator with another.
 ArrayGroup eval(ArrayGroup ag)
          Evaluates the term in the current partition.
 java.lang.String getName()
           
 int[][] getPositions(int d)
          Gets the positions for this term in the given document.
 java.util.List getQueryTerms(java.util.Comparator c)
          Returns a list of all the regular terms in this query in the order that they appeared in the query.
 QueryEntry[] getTerms()
           
protected  ArrayGroup intersect(ArrayGroup ag)
          Intersects a strict group with the current term.
protected  ArrayGroup intersect(NegativeGroup ag)
          Intersects a scored group with the current term.
protected  ArrayGroup intersect(ScoredGroup ag)
          Intersects a scored group with the current term.
 void setPartition(DiskPartition part)
          Sets the partition that this term will be operating on.
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String prefix)
           
 
Methods inherited from class com.sun.labs.minion.retrieval.QueryTerm
setDoExpand, setDoMorph, setDoStem, setDoWild, setLoadPositions, setMatchCase, setQueryConfig
 
Methods inherited from class com.sun.labs.minion.retrieval.QueryElement
addSearchFieldName, compareTo, dump, estimateSize, getInOrder, getOrder, getQueryStats, getQueryTerms, getSearchFieldNames, setInOrder, setOrder, setQueryStats, setSearchFields, setWeightingComponents, setWeightingFunction
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

knowledgeVariants

protected java.lang.String[] knowledgeVariants
The set of morphological variations of the term as computed by the lightweight morphology. We only need to compute this once per query term, when the term is instantiated.


semanticVariants

protected java.lang.String[] semanticVariants
The array of semantic variantions of the term as returned from the taxonomies of all the partitions. We only need to compute this once per query term.


dictEntries

protected QueryEntry[] dictEntries
The list of entries that were pulled from the dictionary for the current partition. A single query term may be expanded in various ways to cover several entries in a dictionary.


feat

protected PostingsIteratorFeatures feat

pis

protected PosPostingsIterator[] pis
A set of postings iterators for the terms that can be used to get position info for proximity queries or for highlighting.


posns

protected int[][] posns
An array that will hold per-field word positions. This will be given out when anyone asks for positions.


logTag

protected static java.lang.String logTag
Constructor Detail

DictTerm

public DictTerm(java.lang.String val)
Creates a dictionary term for a given query term. This query term may be expanded in various ways depending on the operators that have been applied to the term.

Parameters:
val - The value from the query.
Method Detail

setPartition

public void setPartition(DiskPartition part)
Sets the partition that this term will be operating on. Does any dictionary lookups required.

Overrides:
setPartition in class QueryElement
Parameters:
part - The partition that we will be evaluating against.

calculateEstimatedSize

protected int calculateEstimatedSize()
Returns the already calculated estimated size.

Specified by:
calculateEstimatedSize in class QueryElement
Returns:
The estimated size of the results set for this element. This is meant to be an as-tight-as-possible estimate of the results set size. It is acceptable to overestimate, but not to underestimate the size of the result set.

eval

public ArrayGroup eval(ArrayGroup ag)
Evaluates the term in the current partition.

Specified by:
eval in class QueryTerm
Parameters:
ag - An array group that we can use to limit the evaluation of the term. If this group is null a new group will be returned. If this group is non-null, then the elements in the group will be used to restrict the documents that we return from the term.
Returns:
A new ArrayGroup containing the results of evaluating the term against the given group. The static type of the returned group depends on the query status parameter.

intersect

protected ArrayGroup intersect(ArrayGroup ag)
Intersects a strict group with the current term. This will try to do the optimal thing.

Parameters:
ag - The group to intersect with.
Returns:
a group representing the intersection of this term with the given group

intersect

protected ArrayGroup intersect(ScoredGroup ag)
Intersects a scored group with the current term. This will try to do the optimal thing.

Parameters:
ag - The group to intersect with.

intersect

protected ArrayGroup intersect(NegativeGroup ag)
Intersects a scored group with the current term. This will try to do the optimal thing.

Parameters:
ag - The group to intersect with.

getPositions

public int[][] getPositions(int d)
Gets the positions for this term in the given document.

Returns:
a two dimensional array of integers. The first dimension is indexed by field ID. The second dimension is the positions for the given field. The first element of each sub-array will contain the number of positions following. We will only return positions for those fields in which we have a stated interest. If there are no such fields defined, then data from all fields will be returned.

equals

public boolean equals(java.lang.Object object)
Compares this comparator with another.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class java.lang.Object
Parameters:
object - an Object to compare against.
Returns:
true if this comparator is the same class as the other, false otherwise.

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two terms by their respective term frequencies.

Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - a term.
o2 - another term.
Returns:
Less than 0, greater than 0, or 0 if o1's term frequency is, respectively, lower than, higher than, or equal to o2's term frequency.

getQueryTerms

public java.util.List getQueryTerms(java.util.Comparator c)
Description copied from class: QueryElement
Returns a list of all the regular terms in this query in the order that they appeared in the query. Field Terms and terms within a not or a hide expression will not be returned.

Specified by:
getQueryTerms in class QueryElement
Parameters:
c - A comparator used to order the terms.

getTerms

public QueryEntry[] getTerms()

getName

public java.lang.String getName()

toString

public java.lang.String toString()
Overrides:
toString in class QueryElement

toString

public java.lang.String toString(java.lang.String prefix)
Overrides:
toString in class QueryTerm