com.fxpal.search
Class RankedList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<DocumentMatch>
              extended by com.fxpal.search.RankedList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<DocumentMatch>, java.util.Collection<DocumentMatch>, java.util.List<DocumentMatch>, java.util.RandomAccess

public class RankedList
extends java.util.ArrayList<DocumentMatch>

Ranked list of DocumentMatch instances corresponding to search results. Extends ArrayList with some utility methods.

Author:
Gene Golovchinsky (c) 2011 FX Palo Alto Laboratory, Inc.
See Also:
Serialized Form

Constructor Summary
RankedList()
          Default constructor.
RankedList(int capacity)
          Constructor that specifies an initial size.
RankedList(java.util.List<DocumentMatch> matches)
          Creates a new instance with the given elements
 
Method Summary
static RankedList fromDocIds(java.lang.Iterable<java.lang.String> ids)
          Creates a new instance of a RankedList that contains one entry for each id in the given list; entries have the same score and are all marked as relevant.
static RankedList fromDocIds(java.lang.String[] ids)
          Creates a new instance of a RankedList that contains one entry for each id in the given list; entries have the same score and are all marked as relevant.
 void normalizeScores(int max, int min)
          Normalizes the scores to the range [max, min].
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

RankedList

public RankedList(java.util.List<DocumentMatch> matches)
Creates a new instance with the given elements

Parameters:
matches - List of DOcumentMatch instances

RankedList

public RankedList()
Default constructor.


RankedList

public RankedList(int capacity)
Constructor that specifies an initial size.

Parameters:
capacity - Initial capacity of the list
Method Detail

fromDocIds

public static RankedList fromDocIds(java.lang.Iterable<java.lang.String> ids)
Creates a new instance of a RankedList that contains one entry for each id in the given list; entries have the same score and are all marked as relevant. This can be used to generate a ranked list for query expansion. Limitation: Internal ids on matches are set to 0 through this method.

Parameters:
ids - Iterable of external ids of relevant documents.
Returns:
RankedList representing relevant documents

fromDocIds

public static RankedList fromDocIds(java.lang.String[] ids)
Creates a new instance of a RankedList that contains one entry for each id in the given list; entries have the same score and are all marked as relevant. This can be used to generate a ranked list for query expansion. Limitation: Internal ids on matches are set to 0 through this method.

Parameters:
ids - Array of String of external ids of relevant documents.
Returns:
RankedList representing relevant documents

normalizeScores

public void normalizeScores(int max,
                            int min)
Normalizes the scores to the range [max, min]. Assumes results are in descending order of score. min should be greater than 0; max should be greater than min; both values should be positive. These constraints are not checked by the code. Raw scores are not modified, and the same RankedList can be renormalized multiple times.

Parameters:
max - New largest value to assign
min - New smallest value to assign