anl.aida.algo
Class SimilarityCluster<T>

java.lang.Object
  extended by anl.aida.algo.SimilarityCluster<T>
All Implemented Interfaces:
Cluster<T>

public class SimilarityCluster<T>
extends java.lang.Object
implements Cluster<T>

Encapsulates a centroid vector and a collection of items of type T and their similarity (0 to 1) with that centroid vector.


Field Summary
private  java.util.Map<T,anl.aida.util.ObjScore<T>> items
           
private  java.lang.String[] labels
           
private  java.lang.String labelString
           
private  float[] vector
           
 
Constructor Summary
SimilarityCluster(float[] vector, java.lang.String... labels)
          Creates a SimilarityCluster with the specified vector and label.
 
Method Summary
protected  void addItem(T item, float similarity)
           
 float[] getCentroid()
          Gets the vector for the cluster centroid.
 java.lang.String getCentroidLabel()
          Gets the label for this cluster.
 int getItemCount()
          The number of items in this cluster.
 float getSimilarity(T item)
          Gets the similarity score for the specified item with respect to the cluster centroid.
 java.lang.Iterable<anl.aida.util.ObjScore<T>> items()
          Gets an iterable over all the items and score in this cluster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vector

private float[] vector

labelString

private java.lang.String labelString

labels

private java.lang.String[] labels

items

private java.util.Map<T,anl.aida.util.ObjScore<T>> items
Constructor Detail

SimilarityCluster

public SimilarityCluster(float[] vector,
                         java.lang.String... labels)
Creates a SimilarityCluster with the specified vector and label.

Parameters:
vector - the centroids vector
labels - the centroids labels
Method Detail

addItem

protected void addItem(T item,
                       float similarity)

getCentroidLabel

public java.lang.String getCentroidLabel()
Gets the label for this cluster. This can be a list of keywords or a descriptive label, etc.

Specified by:
getCentroidLabel in interface Cluster<T>
Returns:
the label for this cluster

getItemCount

public int getItemCount()
The number of items in this cluster.

Specified by:
getItemCount in interface Cluster<T>
Returns:
the number of items in this cluster

getCentroid

public float[] getCentroid()
Gets the vector for the cluster centroid.

Specified by:
getCentroid in interface Cluster<T>
Returns:
the vector for the cluster centroid

getSimilarity

public float getSimilarity(T item)
Gets the similarity score for the specified item with respect to the cluster centroid.

Specified by:
getSimilarity in interface Cluster<T>
Parameters:
item - the item whose score we want.
Returns:
the similarity score for the specified item with respect to the cluster centroid, or -1 if the item is not found.

items

public java.lang.Iterable<anl.aida.util.ObjScore<T>> items()
Description copied from interface: Cluster
Gets an iterable over all the items and score in this cluster.

Specified by:
items in interface Cluster<T>
Returns:
an iterable over all the items and score in this cluster.