hyspirit.application.retrieval
Class RankedList

java.lang.Object
  extended by hyspirit.application.retrieval.RankedList

public class RankedList
extends java.lang.Object

Interface for ranked result lists. Elements of the lists are of type hyspirit.application.retrieval.ResultItem. The ranked list is always sorted in ascending order of the retrieval weights of its result items.

Author:
Ingo Frommholz <ingo@is.informatik.uni-duisburg.de>

Created on 05-Jun-2005 16:19:29


Constructor Summary
RankedList()
           
 
Method Summary
 void add(ResultItem res)
          Add a new result item to the ranking.
 int elementsLeft()
          Returns the number of elements left in the ranking (i.e. fetchable with getNextElements())
 java.util.List getFirstElements(int number)
          Gets the first elements of the list.
 java.util.List getList()
          Gets the whole ranked list, sorted in ascending order of the retrieval weight of its result item.
 java.util.List getNextElements(int number)
          Gets the next elements of the list.
 java.util.List getRange(int begin, int end)
          Returns a range of the ranked list (including begin and end element).
 boolean hasNext()
          Returns true if there are next elements to fetch, false otherwise
static void main(java.lang.String[] args)
           
 void parseHySpiritResult(java.lang.String hySpiritResult)
          Parses the output of a hy_{pra|prd|fvpd} run and converts it into a ranked list.
 void parseHySpiritResult(java.util.Vector hySpiritResult)
          Parses the output of a hy_{pra|prd|fvpd} run and converts it into a ranked list.
 void reset()
          Resets the internal counter for getNextElements() to 0.
 void setWhitelist(java.util.HashSet<java.lang.String> whitelist)
          A whitelist is a list of URIs you want to see in the ranking.
 int size()
          The number of elements in the ranking
 void sort()
          Sort the ranking.
 void writeTRECResult(java.lang.String filename, java.lang.String queryID, java.lang.String runID, int limit, boolean append, boolean stripQuotationMarks)
          Writes the ranked list into a TREC result file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RankedList

public RankedList()
Method Detail

getList

public java.util.List getList()
Gets the whole ranked list, sorted in ascending order of the retrieval weight of its result item.

Returns:
the ranked list

getNextElements

public java.util.List getNextElements(int number)
Gets the next elements of the list. Returns null if there are no next elements. If less than number elements are left, only these are returned.

Parameters:
number - the number of next elements
Returns:
a subset of the ranked list or null

getFirstElements

public java.util.List getFirstElements(int number)
Gets the first elements of the list. Returns null if there are no next elements. If less than number elements are left, only these are returned.

Parameters:
number - the number of next elements
Returns:
a subset of the ranked list or null

hasNext

public boolean hasNext()
Returns true if there are next elements to fetch, false otherwise

Returns:
true or false

elementsLeft

public int elementsLeft()
Returns the number of elements left in the ranking (i.e. fetchable with getNextElements())

Returns:
the number of elements left

reset

public void reset()
Resets the internal counter for getNextElements() to 0.


size

public int size()
The number of elements in the ranking

Returns:
the size of the ranking

getRange

public java.util.List getRange(int begin,
                               int end)
Returns a range of the ranked list (including begin and end element). If the end index is greater than the index of the last element, all items up to the last element are returned.

Parameters:
begin - the beginning of the range (>= 1)
end - the end of the range
Returns:
a subset of the ranked list or null if there is no element within the given range

add

public void add(ResultItem res)
Add a new result item to the ranking. This invokes the reset() method.

Parameters:
res - the result item to add

sort

public void sort()
Sort the ranking. This method can be invoked explicitely, or is invoked when one of the get methods is called and the current list is not sorted.


parseHySpiritResult

public void parseHySpiritResult(java.lang.String hySpiritResult)
                         throws HyTupleFormatException
Parses the output of a hy_{pra|prd|fvpd} run and converts it into a ranked list. A HySpirit result looks like this: 0.320706 ("http://news.zdnet.com/2100-3513_22-5535433.html") 0.305206 ("http://news.zdnet.com/2100-1009_22-5535228.html")

Parameters:
hySpiritResult - the HySpirit result
Throws:
HyTupleFormatException

parseHySpiritResult

public void parseHySpiritResult(java.util.Vector hySpiritResult)
Parses the output of a hy_{pra|prd|fvpd} run and converts it into a ranked list. A HySpirit result looks like this: 0.320706 ("http://news.zdnet.com/2100-3513_22-5535433.html") 0.305206 ("http://news.zdnet.com/2100-1009_22-5535228.html")

Parameters:
hySpiritResult - the HySpirit result as a Vector

setWhitelist

public void setWhitelist(java.util.HashSet<java.lang.String> whitelist)
A whitelist is a list of URIs you want to see in the ranking. Any item not present in the whitelist will be deleted from the ranking. This is useful for filtering your results and more efficient as a PD join like ?- term(T,D) & document(D) In the above case, you should create a whitelist containing the URIs of all documents, run the query ?- term(T,D) and only documents fulfilling the query will be returned.

Parameters:
whitelist -

writeTRECResult

public void writeTRECResult(java.lang.String filename,
                            java.lang.String queryID,
                            java.lang.String runID,
                            int limit,
                            boolean append,
                            boolean stripQuotationMarks)
                     throws java.io.IOException
Writes the ranked list into a TREC result file

Parameters:
filename - the fiolename of the TREC result file
queryID - the TREC query ID
runID - the TREC run ID
limit - how many resulkt items to write; 0 for unlimited
append - whether to append the result to an existing file
stripQuotationMarks - whether or not to strip quotation marks from result URIs
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)