Package cc.mallet.types
Class AugmentableFeatureVector
- java.lang.Object
-
- cc.mallet.types.SparseVector
-
- cc.mallet.types.FeatureVector
-
- cc.mallet.types.AugmentableFeatureVector
-
- All Implemented Interfaces:
AlphabetCarrying
,ConstantMatrix
,Vector
,java.io.Serializable
public class AugmentableFeatureVector extends FeatureVector implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class cc.mallet.types.SparseVector
hasInfinite, indices, values
-
-
Constructor Summary
Constructors Constructor Description AugmentableFeatureVector(Alphabet dict)
AugmentableFeatureVector(Alphabet dict, boolean binary)
AugmentableFeatureVector(Alphabet dict, double[] values)
AugmentableFeatureVector(Alphabet dict, double[] values, int capacity)
AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity)
AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, boolean copy)
AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, boolean copy, boolean checkIndicesSorted)
AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, int size, boolean copy, boolean checkIndicesSorted, boolean removeDuplicates)
To make a binary vector, pass null for "values"AugmentableFeatureVector(Alphabet dict, int capacity, boolean binary)
AugmentableFeatureVector(Alphabet dict, PropertyList pl, boolean binary)
AugmentableFeatureVector(Alphabet dict, PropertyList pl, boolean binary, boolean growAlphabet)
AugmentableFeatureVector(FeatureSequence fs, boolean binary)
AugmentableFeatureVector(FeatureVector fv)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index)
void
add(int index, double value)
void
add(FeatureVector fv)
Adds all indices that are present in some other feature vector with value 1.0.void
add(FeatureVector fv, java.lang.String prefix)
Adds all features from some other feature vector with weight 1.0.void
add(FeatureVector fv, java.lang.String prefix, boolean binary)
Adds all features from some other feature vector with weight 1.0.void
add(java.lang.Object key, double value)
void
addTo(double[] accumulator)
void
addTo(double[] accumulator, double scale)
ConstantMatrix
cloneMatrix()
CLONINGConstantMatrix
cloneMatrixZeroed()
double
dotProduct(AugmentableFeatureVector v)
double
dotProduct(DenseVector v)
double
dotProduct(SparseVector v)
int
indexAtLocation(int location)
double
infinityNorm()
int
location(int index)
int
numLocations()
double
oneNorm()
void
plusEquals(AugmentableFeatureVector v, double factor)
void
plusEquals(SparseVector v)
void
plusEquals(SparseVector v, double factor)
void
print()
protected void
removeDuplicates(int numDuplicates)
void
setAll(double v)
Sets every present index in the vector to v.void
setValue(int index, double value)
Sets the value at the given index.void
setValueAtLocation(int location, double value)
Sets the value at the given location.int
singleSize()
protected void
sortIndices()
FeatureVector
toFeatureVector()
SparseVector
toSparseVector()
double
twoNorm()
double
value(int index)
double
valueAtLocation(int location)
-
Methods inherited from class cc.mallet.types.FeatureVector
alphabetsMatch, contains, getAlphabet, getAlphabets, getObjectIndices, location, newFeatureVector, toSimpFile, toString, toString, value
-
Methods inherited from class cc.mallet.types.SparseVector
absNorm, arrayCopyFrom, arrayCopyFrom, arrayCopyInto, dotProduct, dotProduct, extendedDotProduct, extendedDotProduct, getDimensions, getIndices, getNumDimensions, getValues, incrementValue, isBinary, isInfinite, isNaN, isNaNOrInfinite, makeBinary, makeNonBinary, map, plusEqualsSparse, plusEqualsSparse, singleIndex, singleToIndices, singleValue, timesEquals, timesEqualsSparse, timesEqualsSparse, timesEqualsSparseZero, value, vectorAdd
-
-
-
-
Constructor Detail
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, int size, boolean copy, boolean checkIndicesSorted, boolean removeDuplicates)
To make a binary vector, pass null for "values"
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, boolean copy, boolean checkIndicesSorted)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, boolean copy)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, int[] indices, double[] values, int capacity)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, double[] values, int capacity)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, double[] values)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, int capacity, boolean binary)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, boolean binary)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict)
-
AugmentableFeatureVector
public AugmentableFeatureVector(FeatureVector fv)
-
AugmentableFeatureVector
public AugmentableFeatureVector(FeatureSequence fs, boolean binary)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, PropertyList pl, boolean binary, boolean growAlphabet)
-
AugmentableFeatureVector
public AugmentableFeatureVector(Alphabet dict, PropertyList pl, boolean binary)
-
-
Method Detail
-
add
public void add(FeatureVector fv)
Adds all indices that are present in some other feature vector with value 1.0. Beware that this may have unintended effects if fv.dictionary != this.dictionary
-
add
public void add(FeatureVector fv, java.lang.String prefix)
Adds all features from some other feature vector with weight 1.0. The names of the added features are generated by adding a prefix to their names in the original feature vector. This does not require that fv.dictionary equal this.dictionary.- Parameters:
fv
- A feature vector to add from. Its feature names must be Strings.prefix
- String to add when generating new feature names
-
add
public void add(FeatureVector fv, java.lang.String prefix, boolean binary)
Adds all features from some other feature vector with weight 1.0. The names of the added features are generated by adding a prefix to their names in the original feature vector. This does not require that fv.dictionary equal this.dictionary.- Parameters:
fv
- A feature vector to add from. Its feature names must be Strings.prefix
- String to add when generating new feature namesbinary
- true if fv is binary
-
add
public void add(int index, double value)
-
add
public void add(java.lang.Object key, double value)
-
add
public void add(int index)
-
numLocations
public final int numLocations()
- Specified by:
numLocations
in interfaceConstantMatrix
- Overrides:
numLocations
in classSparseVector
-
location
public final int location(int index)
- Specified by:
location
in interfaceConstantMatrix
- Overrides:
location
in classSparseVector
-
valueAtLocation
public final double valueAtLocation(int location)
- Specified by:
valueAtLocation
in interfaceConstantMatrix
- Overrides:
valueAtLocation
in classSparseVector
-
indexAtLocation
public final int indexAtLocation(int location)
- Specified by:
indexAtLocation
in interfaceConstantMatrix
- Overrides:
indexAtLocation
in classSparseVector
-
value
public final double value(int index)
- Specified by:
value
in interfaceVector
- Overrides:
value
in classSparseVector
-
addTo
public final void addTo(double[] accumulator, double scale)
- Overrides:
addTo
in classSparseVector
-
addTo
public final void addTo(double[] accumulator)
- Overrides:
addTo
in classSparseVector
-
setValue
public final void setValue(int index, double value)
Description copied from class:SparseVector
Sets the value at the given index.- Overrides:
setValue
in classSparseVector
-
setValueAtLocation
public final void setValueAtLocation(int location, double value)
Description copied from class:SparseVector
Sets the value at the given location.- Overrides:
setValueAtLocation
in classSparseVector
-
cloneMatrix
public ConstantMatrix cloneMatrix()
Description copied from class:SparseVector
CLONING- Specified by:
cloneMatrix
in interfaceConstantMatrix
- Overrides:
cloneMatrix
in classFeatureVector
-
cloneMatrixZeroed
public ConstantMatrix cloneMatrixZeroed()
- Overrides:
cloneMatrixZeroed
in classFeatureVector
-
singleSize
public int singleSize()
- Specified by:
singleSize
in interfaceConstantMatrix
- Overrides:
singleSize
in classSparseVector
-
toSparseVector
public SparseVector toSparseVector()
-
toFeatureVector
public FeatureVector toFeatureVector()
-
dotProduct
public double dotProduct(DenseVector v)
- Overrides:
dotProduct
in classSparseVector
-
dotProduct
public final double dotProduct(SparseVector v)
- Overrides:
dotProduct
in classSparseVector
-
dotProduct
public final double dotProduct(AugmentableFeatureVector v)
-
plusEquals
public void plusEquals(AugmentableFeatureVector v, double factor)
-
plusEquals
public void plusEquals(SparseVector v, double factor)
-
plusEquals
public void plusEquals(SparseVector v)
-
setAll
public void setAll(double v)
Description copied from class:SparseVector
Sets every present index in the vector to v.- Overrides:
setAll
in classSparseVector
-
oneNorm
public double oneNorm()
- Specified by:
oneNorm
in interfaceConstantMatrix
- Overrides:
oneNorm
in classSparseVector
-
twoNorm
public double twoNorm()
- Specified by:
twoNorm
in interfaceConstantMatrix
- Overrides:
twoNorm
in classSparseVector
-
infinityNorm
public double infinityNorm()
- Specified by:
infinityNorm
in interfaceConstantMatrix
- Overrides:
infinityNorm
in classSparseVector
-
print
public void print()
- Specified by:
print
in interfaceConstantMatrix
- Overrides:
print
in classSparseVector
-
sortIndices
protected void sortIndices()
- Overrides:
sortIndices
in classSparseVector
-
removeDuplicates
protected void removeDuplicates(int numDuplicates)
- Overrides:
removeDuplicates
in classSparseVector
-
-