gov.sandia.cognition.text.term.vector.weighter
Class CompositeLocalGlobalTermWeighter

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.text.term.vector.weighter.CompositeLocalGlobalTermWeighter
All Implemented Interfaces:
Evaluator<Vector,Vector>, CloneableSerializable, Serializable, Cloneable

public class CompositeLocalGlobalTermWeighter
extends AbstractCloneableSerializable
implements Evaluator<Vector,Vector>

Composes together local and global term weighters along with a normalizer. Used for creating a full term weighting scheme, for example TF-IDF or LogEntropy. It multiplies the local weighted terms by the global weighted terms and then passes the information to the normalizer.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
protected  GlobalTermWeighter globalWeighter
          The weighting scheme for the global weights.
protected  LocalTermWeighter localWeighter
          The weighting scheme for the local weights.
protected  TermWeightNormalizer normalizer
          The weight normalizer.
 
Constructor Summary
CompositeLocalGlobalTermWeighter()
          Creates a new CompositeLocalGlobalTermWeighter.
CompositeLocalGlobalTermWeighter(LocalTermWeighter localWeighter, GlobalTermWeighter globalWeighter, TermWeightNormalizer normalizer)
          Creates a new CompositeLocalGlobalTermWeighter with the given weighting schemes.
 
Method Summary
 CompositeLocalGlobalTermWeighter clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 Vector evaluate(Vector document)
          Evaluates the function on the given input and returns the output.
 GlobalTermWeighter getGlobalWeighter()
          Gets the weighting scheme for the global weights.
 LocalTermWeighter getLocalWeighter()
          Gets the weighting scheme for the local weights.
 TermWeightNormalizer getNormalizer()
          Gets the weight normalizer.
 void setGlobalWeighter(GlobalTermWeighter globalWeighter)
          Sets the weighting scheme for the global weights.
 void setLocalWeighter(LocalTermWeighter localWeighter)
          Sets the weighting scheme for the local weights.
 void setNormalizer(TermWeightNormalizer normalizer)
          Sets the weight normalizer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localWeighter

protected LocalTermWeighter localWeighter
The weighting scheme for the local weights. Null means no local weights.


globalWeighter

protected GlobalTermWeighter globalWeighter
The weighting scheme for the global weights. Null means no global weights.


normalizer

protected TermWeightNormalizer normalizer
The weight normalizer.

Constructor Detail

CompositeLocalGlobalTermWeighter

public CompositeLocalGlobalTermWeighter()
Creates a new CompositeLocalGlobalTermWeighter. All of the weightings default to null.


CompositeLocalGlobalTermWeighter

public CompositeLocalGlobalTermWeighter(LocalTermWeighter localWeighter,
                                        GlobalTermWeighter globalWeighter,
                                        TermWeightNormalizer normalizer)
Creates a new CompositeLocalGlobalTermWeighter with the given weighting schemes.

Parameters:
localWeighter - The weighting scheme for local weights. Null means that the input values are not changed.
globalWeighter - The weighting scheme for the global weights. Null means that no global weights are used.
normalizer - The normalization scheme for the weights. Null means that no normalization is used.
Method Detail

clone

public CompositeLocalGlobalTermWeighter clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

evaluate

public Vector evaluate(Vector document)
Description copied from interface: Evaluator
Evaluates the function on the given input and returns the output.

Specified by:
evaluate in interface Evaluator<Vector,Vector>
Parameters:
document - The input to evaluate.
Returns:
The output produced by evaluating the input.

getLocalWeighter

public LocalTermWeighter getLocalWeighter()
Gets the weighting scheme for the local weights.

Returns:
The weighting scheme for the local weights. Null means no local weights.

setLocalWeighter

public void setLocalWeighter(LocalTermWeighter localWeighter)
Sets the weighting scheme for the local weights.

Parameters:
localWeighter - The weighting scheme for the local weights. Null means no local weights.

getGlobalWeighter

public GlobalTermWeighter getGlobalWeighter()
Gets the weighting scheme for the global weights.

Returns:
The weighting scheme for the global weights. Null means no global weights.

setGlobalWeighter

public void setGlobalWeighter(GlobalTermWeighter globalWeighter)
Sets the weighting scheme for the global weights.

Parameters:
globalWeighter - The weighting scheme for the global weights. Null means no global weights.

getNormalizer

public TermWeightNormalizer getNormalizer()
Gets the weight normalizer.

Returns:
The weight normalizer. Null means no normalizer.

setNormalizer

public void setNormalizer(TermWeightNormalizer normalizer)
Sets the weight normalizer.

Parameters:
normalizer - The weight normalizer. Null means no normalizer.