de.dfki.mycbr.core.retrieval
Class RetrievalEngine

java.lang.Object
  extended by de.dfki.mycbr.core.retrieval.RetrievalEngine
Direct Known Subclasses:
SequentialRetrieval

public abstract class RetrievalEngine
extends java.lang.Object

Retrieval methods retrieve the most similar cases to a query from a given case base. There can be more efficient methods for retrieving k cases than retrieving all cases and then return only k. Implements Strategy Pattern.

Author:
myCBR Team

Constructor Summary
RetrievalEngine()
           
 
Method Summary
 Instance getCurrentCase()
           
abstract  java.util.List<Pair<Instance,Similarity>> retrieve(ICaseBase cb, Instance q)
           
abstract  java.util.List<Pair<Instance,Similarity>> retrieveK(ICaseBase cb, Instance q, int k)
           
abstract  java.util.List<Pair<Instance,Similarity>> retrieveKSorted(ICaseBase cb, Instance q, int k)
           
abstract  java.util.List<Pair<Instance,Similarity>> retrieveSorted(ICaseBase cb, Instance q)
           
 void setCurrentCase(Instance c)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetrievalEngine

public RetrievalEngine()
Method Detail

retrieve

public abstract java.util.List<Pair<Instance,Similarity>> retrieve(ICaseBase cb,
                                                                   Instance q)
                                                            throws java.lang.Exception
Parameters:
cb - the case base this retrieval should be run on
q - the current query
Returns:
list of retrieval results including pairs of case and similarity
Throws:
java.lang.Exception - if something goes wrong during similarity computations

retrieveSorted

public abstract java.util.List<Pair<Instance,Similarity>> retrieveSorted(ICaseBase cb,
                                                                         Instance q)
                                                                  throws java.lang.Exception
Parameters:
cb - the case base this retrieval should be run on
q - the current query
Returns:
list of pairs of case and similarity sorted with respect to the similarities in descending order
Throws:
java.lang.Exception - if something goes wrong during similarity computations

retrieveK

public abstract java.util.List<Pair<Instance,Similarity>> retrieveK(ICaseBase cb,
                                                                    Instance q,
                                                                    int k)
                                                             throws java.lang.Exception
Parameters:
cb - the case base this retrieval should be run on
q - the current query
k - the number of cases to be returned
Returns:
list of k pairs of case and similarity (if there are enough)
Throws:
java.lang.Exception - if something goes wrong during similarity computations

retrieveKSorted

public abstract java.util.List<Pair<Instance,Similarity>> retrieveKSorted(ICaseBase cb,
                                                                          Instance q,
                                                                          int k)
                                                                   throws java.lang.Exception
Parameters:
cb - the case base this retrieval should be run on
q - the current query
k - the number of cases to be returned
Returns:
list of k pairs of case and similarity (if there are enough) sorted with respect to the similarities in descending order
Throws:
java.lang.Exception - if something goes wrong during similarity computations

setCurrentCase

public final void setCurrentCase(Instance c)
Parameters:
c - the new current case

getCurrentCase

public final Instance getCurrentCase()
Returns:
the current case