moj.ri.weighting
Class WeightingScheme

java.lang.Object
  extended by moj.ri.weighting.WeightingScheme
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ConstantWS, MangesWS, MartinsWS, PermutatingWS, RosellsWS

public abstract class WeightingScheme
extends java.lang.Object
implements java.io.Serializable

Calculates the weighting of the context label.
All subclasses of WeightingScheme must provide methods for calculating the weights for left and right context windows according to the desired algorithm (for example using distance to context label). If there is a need to be able to serialize the RandomIndex, all subclasses of WeightingScheme must declare their own serialVersionUID.

Version:
2007-Sept-12
Author:
Martin Hassel
See Also:
Serialized Form

Constructor Summary
WeightingScheme()
           
 
Method Summary
abstract  float[] applyLeftWeighting(RandomLabel focusLabel, int distance, RandomLabel leftContextLabel)
          Adds the weighted context label (in the left context) to the focus label's context label and returns it.
abstract  float[] applyRightWeighting(RandomLabel focusLabel, int distance, RandomLabel rightContextLabel)
          Adds the weighted context label (in the right context) to the focus label's context label and returns it.
 void setIndex(RandomIndex index)
          The RandomIndex the WeightingScheme is used for so that extending schemes can use information kept by the index, e.g.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeightingScheme

public WeightingScheme()
Method Detail

setIndex

public void setIndex(RandomIndex index)
The RandomIndex the WeightingScheme is used for so that extending schemes can use information kept by the index, e.g. the number of words or documents indexed so far.

Parameters:
index - a RandomIndex, typically the one the WeightingScheme is used for

applyLeftWeighting

public abstract float[] applyLeftWeighting(RandomLabel focusLabel,
                                           int distance,
                                           RandomLabel leftContextLabel)
Adds the weighted context label (in the left context) to the focus label's context label and returns it. Application writers must its own methods in a subclass to calculate the weights according to specific algorithms.

Parameters:
focusLabel - RandomLabel in focus, i.e. the focus word whose context vector should be modified with the weighted RandomLabel in left context.
distance - leftward distance to the focus word (RandomLabel).
leftContextLabel - RandomLabel in left context at distance from the focus word, which can be used together with distance to calculate the weight.
Returns:
the context of the focus word modified according to the weighting scheme.

applyRightWeighting

public abstract float[] applyRightWeighting(RandomLabel focusLabel,
                                            int distance,
                                            RandomLabel rightContextLabel)
Adds the weighted context label (in the right context) to the focus label's context label and returns it. Application writers must its own methods in a subclass to calculate the weights according to specific algorithms.

Parameters:
focusLabel - RandomLabel in focus, i.e. the focus word whose context vector should be modified with the weighted RandomLabel in right context.
distance - rightward distance to the focus word (RandomLabel).
rightContextLabel - RandomLabel in right context at distance from the focus word, which can be used together with distance to calculate the weight.
Returns:
the context of the focus word modified according to the weighting scheme.