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 voidadd(int index)voidadd(int index, double value)voidadd(FeatureVector fv)Adds all indices that are present in some other feature vector with value 1.0.voidadd(FeatureVector fv, java.lang.String prefix)Adds all features from some other feature vector with weight 1.0.voidadd(FeatureVector fv, java.lang.String prefix, boolean binary)Adds all features from some other feature vector with weight 1.0.voidadd(java.lang.Object key, double value)voidaddTo(double[] accumulator)voidaddTo(double[] accumulator, double scale)ConstantMatrixcloneMatrix()CLONINGConstantMatrixcloneMatrixZeroed()doubledotProduct(AugmentableFeatureVector v)doubledotProduct(DenseVector v)doubledotProduct(SparseVector v)intindexAtLocation(int location)doubleinfinityNorm()intlocation(int index)intnumLocations()doubleoneNorm()voidplusEquals(AugmentableFeatureVector v, double factor)voidplusEquals(SparseVector v)voidplusEquals(SparseVector v, double factor)voidprint()protected voidremoveDuplicates(int numDuplicates)voidsetAll(double v)Sets every present index in the vector to v.voidsetValue(int index, double value)Sets the value at the given index.voidsetValueAtLocation(int location, double value)Sets the value at the given location.intsingleSize()protected voidsortIndices()FeatureVectortoFeatureVector()SparseVectortoSparseVector()doubletwoNorm()doublevalue(int index)doublevalueAtLocation(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:
numLocationsin interfaceConstantMatrix- Overrides:
numLocationsin classSparseVector
-
location
public final int location(int index)
- Specified by:
locationin interfaceConstantMatrix- Overrides:
locationin classSparseVector
-
valueAtLocation
public final double valueAtLocation(int location)
- Specified by:
valueAtLocationin interfaceConstantMatrix- Overrides:
valueAtLocationin classSparseVector
-
indexAtLocation
public final int indexAtLocation(int location)
- Specified by:
indexAtLocationin interfaceConstantMatrix- Overrides:
indexAtLocationin classSparseVector
-
value
public final double value(int index)
- Specified by:
valuein interfaceVector- Overrides:
valuein classSparseVector
-
addTo
public final void addTo(double[] accumulator, double scale)- Overrides:
addToin classSparseVector
-
addTo
public final void addTo(double[] accumulator)
- Overrides:
addToin classSparseVector
-
setValue
public final void setValue(int index, double value)Description copied from class:SparseVectorSets the value at the given index.- Overrides:
setValuein classSparseVector
-
setValueAtLocation
public final void setValueAtLocation(int location, double value)Description copied from class:SparseVectorSets the value at the given location.- Overrides:
setValueAtLocationin classSparseVector
-
cloneMatrix
public ConstantMatrix cloneMatrix()
Description copied from class:SparseVectorCLONING- Specified by:
cloneMatrixin interfaceConstantMatrix- Overrides:
cloneMatrixin classFeatureVector
-
cloneMatrixZeroed
public ConstantMatrix cloneMatrixZeroed()
- Overrides:
cloneMatrixZeroedin classFeatureVector
-
singleSize
public int singleSize()
- Specified by:
singleSizein interfaceConstantMatrix- Overrides:
singleSizein classSparseVector
-
toSparseVector
public SparseVector toSparseVector()
-
toFeatureVector
public FeatureVector toFeatureVector()
-
dotProduct
public double dotProduct(DenseVector v)
- Overrides:
dotProductin classSparseVector
-
dotProduct
public final double dotProduct(SparseVector v)
- Overrides:
dotProductin 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:SparseVectorSets every present index in the vector to v.- Overrides:
setAllin classSparseVector
-
oneNorm
public double oneNorm()
- Specified by:
oneNormin interfaceConstantMatrix- Overrides:
oneNormin classSparseVector
-
twoNorm
public double twoNorm()
- Specified by:
twoNormin interfaceConstantMatrix- Overrides:
twoNormin classSparseVector
-
infinityNorm
public double infinityNorm()
- Specified by:
infinityNormin interfaceConstantMatrix- Overrides:
infinityNormin classSparseVector
-
print
public void print()
- Specified by:
printin interfaceConstantMatrix- Overrides:
printin classSparseVector
-
sortIndices
protected void sortIndices()
- Overrides:
sortIndicesin classSparseVector
-
removeDuplicates
protected void removeDuplicates(int numDuplicates)
- Overrides:
removeDuplicatesin classSparseVector
-
-