de.fu_berlin.ties.context
Class PriorRecognitions

java.lang.Object
  extended by de.fu_berlin.ties.context.PriorRecognitions

public class PriorRecognitions
extends Object

A buffer of prior Recognitions that should be considered in the context representation. The buffer adjusts its size automatically, discarding the least recently added recognitions when enough recognitions are stored.

Allows to cache feature vectors representing recognitions (caching should only be used for sealed recognitions because otherwise the cached features might get out-of-date).

Instances of this class and the nested class PriorRecognitions.Pair are not thread-safe.

Version:
$Revision: 1.8 $, $Date: 2006/10/21 16:04:03 $, $Author: siefkes $
Author:
Christian Siefkes

Nested Class Summary
static class PriorRecognitions.Pair
          An inner class wrapping a recognition and optionally a feature vector representing the recognition.
 
Constructor Summary
PriorRecognitions(int size)
          Creates a new instance.
 
Method Summary
 void add(Recognition recognition)
          Adds the given recognition to this buffer, discarding the least recently added recognition if appropriate.
 Iterator iterator()
          Returns an iterator over the elements stored in this instance.
 Recognition removeLast()
          Removes the most recently inserted recognition from this buffer.
 int size()
          Returns the number of recognitions stored in the buffer.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PriorRecognitions

public PriorRecognitions(int size)
Creates a new instance.

Parameters:
size - the number of prior recognitions to store; if 0 this is just a dummy instance that throws away any recognitions that are added
Method Detail

add

public void add(Recognition recognition)
Adds the given recognition to this buffer, discarding the least recently added recognition if appropriate.

Parameters:
recognition - the recognition to add

iterator

public Iterator iterator()
Returns an iterator over the elements stored in this instance. Note that the objects referred by the iterator will be PriorRecognitions.Pairs (not Recognitions). These pairs can be used to access the recognition and to retrieve and store feature vectors representing the recognition. Feature vectors should be cached only for sealed recognitions because otherwise the cached features might get out-of-date.

Returns:
an iterator over the stored PriorRecognitions.Pairs

removeLast

public Recognition removeLast()
Removes the most recently inserted recognition from this buffer.

Returns:
the removed recognition; or null if this container is empty

size

public int size()
Returns the number of recognitions stored in the buffer.

Returns:
the number of recognitions stored

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.