com.aliasi.features
Class LengthNormFeatureExtractor<E>

java.lang.Object
  extended by com.aliasi.features.FeatureExtractorFilter<E>
      extended by com.aliasi.features.LengthNormFeatureExtractor<E>
Type Parameters:
E - The type of object whose features are extracted
All Implemented Interfaces:
FeatureExtractor<E>, Serializable

public class LengthNormFeatureExtractor<E>
extends FeatureExtractorFilter<E>
implements Serializable

A LengthNormFeatureExtractor converts feature vectors produced by a contained extractor into unit length vectors.

Length is defined as the (Euclidean or L2) distance from the origin, which is given by:

 length(map) = sqrt(&Sigma{v in map.values()} v * v)
If the length is non-zero, a new map is created in which all values are divided by the length, so that the returned value has unit length (length = 1). If the length is zero, the feature vector extracted by the contained feature extractor is returned as is.

Serialization

A length-norm feature extractor is serializable if its contained base extractor is serializable.

Since:
Lingpipe3.8
Version:
3.8
Author:
Bob Carpenter
See Also:
Serialized Form

Constructor Summary
LengthNormFeatureExtractor(FeatureExtractor<? super E> extractor)
          Construct a length-normalized feature extractor from the specified extractor.
 
Method Summary
 Map<String,? extends Number> features(E in)
          Return a length-normalized feature version of the feature vector returned by the contained vector.
 
Methods inherited from class com.aliasi.features.FeatureExtractorFilter
baseExtractor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LengthNormFeatureExtractor

public LengthNormFeatureExtractor(FeatureExtractor<? super E> extractor)
Construct a length-normalized feature extractor from the specified extractor.

Parameters:
extractor - Base feature extractor.
Method Detail

features

public Map<String,? extends Number> features(E in)
Return a length-normalized feature version of the feature vector returned by the contained vector.

Specified by:
features in interface FeatureExtractor<E>
Overrides:
features in class FeatureExtractorFilter<E>
Parameters:
in - Input to be converted to a feature vector.
Returns:
The length-normalized feature vector.