com.wcohen.ss
Class CombinedStringDistanceLearner

java.lang.Object
  extended by com.wcohen.ss.CombinedStringDistanceLearner
All Implemented Interfaces:
StringDistanceLearner
Direct Known Subclasses:
AdaptiveStringDistanceLearner, AveragedStringDistanceLearner

public abstract class CombinedStringDistanceLearner
extends java.lang.Object
implements StringDistanceLearner

Abstract StringDistanceLearner class which combines results of a number of inner distance metrics, learned by a number of inner distance learners.


Nested Class Summary
protected  class CombinedStringDistanceLearner.CombinedStringDistance
          Abstract class for combining innerDistances's
protected  class CombinedStringDistanceLearner.JthDistanceInstanceIterator
          Iterate over the j-th field of MultiStringWrapper's in a DistanceInstance of MultiStringWrapper's
protected  class CombinedStringDistanceLearner.JthStringWrapperValueIterator
          Iterate over the j-th field of MultiStringWrapper
protected  class CombinedStringDistanceLearner.MyDistanceInstance
           
protected  class CombinedStringDistanceLearner.MyMultiDistanceInstance
           
 
Field Summary
protected  java.lang.String delim
           
protected  StringDistanceLearner[] innerLearners
           
 
Constructor Summary
CombinedStringDistanceLearner()
           
CombinedStringDistanceLearner(StringDistanceLearner[] innerLearners, java.lang.String delim)
           
 
Method Summary
 void addExample(DistanceInstance answeredQuery)
          Pass new labels to the sublearners.
protected  CombinedStringDistanceLearner.MyMultiDistanceInstance asMultiDistanceInstance(DistanceInstance di)
           
protected  java.util.List<CombinedStringDistanceLearner.MyMultiDistanceInstance> asMultiDistanceInstanceList(DistanceInstanceIterator i)
           
protected  MultiStringWrapper asMultiStringWrapper(StringWrapper w)
           
protected  java.util.List<MultiStringWrapper> asMultiStringWrapperList(StringWrapperIterator i)
           
protected abstract  void comboAddExample(DistanceInstance di)
          Pass a labeled example to the score-combination learner.
protected abstract  boolean comboHasNextQuery()
          Poll the routine that learns to combine inner distance scores to see if it wants to make more queries.
protected abstract  DistanceInstance comboNextQuery()
          Get the next query from the score-combination learner.
protected abstract  void comboSetDistanceInstancePool(java.util.Iterator i)
          Set up a pool of (possibly unlabeled) instance distances, for the learner to make queries from.
protected abstract  void comboSetStringWrapperPool(java.util.Iterator i)
          Pass an iterator over unlabeled string wrappers to the score-combination learner, just in case that's useful.
abstract  StringDistance getDistance()
          Get the final string distance, which will be based on the distances learned by the inner learners, as well as the combination scheme learned by comboSetAnswer, comboTrain, and etc.
protected  StringDistance[] getInnerDistances()
          Get an array of trained inner distances.
 boolean hasNextQuery()
          See if someone has a query
 DistanceInstance nextQuery()
          Get a next query from one of the sublearners
 DistanceInstanceIterator prepare(DistanceInstanceIterator it)
          Prepare data for the learners.
 StringWrapperIterator prepare(StringWrapperIterator it)
          Prepare data for the sublearners.
 void setDistanceInstancePool(DistanceInstanceIterator it)
          Pass the training data along to the inner learners.
 void setStringWrapperPool(StringWrapperIterator it)
          Pass the training data along to the inner learners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

innerLearners

protected StringDistanceLearner[] innerLearners

delim

protected java.lang.String delim
Constructor Detail

CombinedStringDistanceLearner

public CombinedStringDistanceLearner()

CombinedStringDistanceLearner

public CombinedStringDistanceLearner(StringDistanceLearner[] innerLearners,
                                     java.lang.String delim)
Method Detail

comboSetStringWrapperPool

protected abstract void comboSetStringWrapperPool(java.util.Iterator i)
Pass an iterator over unlabeled string wrappers to the score-combination learner, just in case that's useful.


comboSetDistanceInstancePool

protected abstract void comboSetDistanceInstancePool(java.util.Iterator i)
Set up a pool of (possibly unlabeled) instance distances, for the learner to make queries from.


comboHasNextQuery

protected abstract boolean comboHasNextQuery()
Poll the routine that learns to combine inner distance scores to see if it wants to make more queries.


comboNextQuery

protected abstract DistanceInstance comboNextQuery()
Get the next query from the score-combination learner.


comboAddExample

protected abstract void comboAddExample(DistanceInstance di)
Pass a labeled example to the score-combination learner.


getDistance

public abstract StringDistance getDistance()
Get the final string distance, which will be based on the distances learned by the inner learners, as well as the combination scheme learned by comboSetAnswer, comboTrain, and etc.

Specified by:
getDistance in interface StringDistanceLearner

setStringWrapperPool

public void setStringWrapperPool(StringWrapperIterator it)
Pass the training data along to the inner learners.

Specified by:
setStringWrapperPool in interface StringDistanceLearner

setDistanceInstancePool

public void setDistanceInstancePool(DistanceInstanceIterator it)
Pass the training data along to the inner learners.

Specified by:
setDistanceInstancePool in interface StringDistanceLearner

hasNextQuery

public boolean hasNextQuery()
See if someone has a query

Specified by:
hasNextQuery in interface StringDistanceLearner

nextQuery

public DistanceInstance nextQuery()
Get a next query from one of the sublearners

Specified by:
nextQuery in interface StringDistanceLearner

addExample

public void addExample(DistanceInstance answeredQuery)
Pass new labels to the sublearners.

Specified by:
addExample in interface StringDistanceLearner

prepare

public StringWrapperIterator prepare(StringWrapperIterator it)
Prepare data for the sublearners.

Specified by:
prepare in interface StringDistanceLearner

prepare

public DistanceInstanceIterator prepare(DistanceInstanceIterator it)
Prepare data for the learners.

Specified by:
prepare in interface StringDistanceLearner

asMultiStringWrapperList

protected java.util.List<MultiStringWrapper> asMultiStringWrapperList(StringWrapperIterator i)

asMultiStringWrapper

protected MultiStringWrapper asMultiStringWrapper(StringWrapper w)

asMultiDistanceInstanceList

protected java.util.List<CombinedStringDistanceLearner.MyMultiDistanceInstance> asMultiDistanceInstanceList(DistanceInstanceIterator i)

asMultiDistanceInstance

protected CombinedStringDistanceLearner.MyMultiDistanceInstance asMultiDistanceInstance(DistanceInstance di)

getInnerDistances

protected StringDistance[] getInnerDistances()
Get an array of trained inner distances.