public class CogxelVectorConverter extends DefaultVectorFactoryContainer implements CogxelConverter<Vector>
vectorFactory
Constructor and Description |
---|
CogxelVectorConverter()
Creates a new, empty instance of VectorCogxelMap.
|
CogxelVectorConverter(CogxelVectorConverter other)
Creates a new copy of the given CogxelVectorConverter.
|
CogxelVectorConverter(java.lang.Iterable<SemanticLabel> labels)
Creates a new CogxelVectorConverter from the given labels.
|
CogxelVectorConverter(java.lang.Iterable<SemanticLabel> labels,
SemanticIdentifierMap semanticIdentifierMap)
Creates a new CogxelVectorConverter from the given SemanticIdentifierMap
and SemanticLabels.
|
CogxelVectorConverter(java.lang.Iterable<SemanticLabel> labels,
SemanticIdentifierMap semanticIdentifierMap,
VectorFactory<?> vectorFactory,
CogxelFactory cogxelFactory)
Creates a new CogxelVectorConverter.
|
CogxelVectorConverter(SemanticLabel... labels)
Creates a new CogxelVectorConverter from the given labels.
|
CogxelVectorConverter(SemanticLabel[] labels,
SemanticIdentifierMap semanticIdentifierMap)
Creates a new CogxelVectorConverter from the given SemanticIdentifierMap
and SemanticLabels.
|
CogxelVectorConverter(SemanticLabel[] labels,
SemanticIdentifierMap semanticIdentifierMap,
VectorFactory<?> vectorFactory,
CogxelFactory cogxelFactory)
Creates a new CogxelVectorConverter
|
Modifier and Type | Method and Description |
---|---|
void |
addLabel(SemanticLabel label)
Adds the given SemanticLabel to the list of labels used by the
converter.
|
void |
addLabels(java.lang.Iterable<SemanticLabel> labels)
Adds all of the given labels to the converter.
|
void |
addLabels(SemanticLabel[] labels)
Adds all of the given labels to the converter.
|
protected void |
addLabelToIdentifierCache(SemanticLabel label)
Adds the given label to the cache of SemanticIdentifiers.
|
protected void |
buildIdentifierCache()
Rebuilds the cache of SemanticIdentifier objects.
|
CogxelVectorConverter |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
Vector |
createEmptyVector()
Creates an empty Vector for the converter, of the proper dimensionality.
|
boolean |
equals(CogxelVectorConverter other)
Returns true if the two converters have the same labels.
|
boolean |
equals(java.lang.Object other) |
protected int |
findIndexForIdentifier(SemanticIdentifier identifier)
Finds the vector index for the given SemanticIdentifier.
|
Vector |
fromCogxels(CogxelState cogxels)
Converts from a CogxelState object to an object of type DataType.
|
CogxelFactory |
getCogxelFactory()
Gets the CogxelFactory used to create the Cogxels used by the converter.
|
int |
getDimensionality()
Gets the dimensionality of the Vector created by the converter.
|
protected java.util.ArrayList<SemanticIdentifier> |
getIdentifiers()
Gets the list of cached SemanticIdentifiers.
|
protected java.util.HashMap<SemanticIdentifier,java.lang.Integer> |
getIdentifierToIndexMap()
Gets the cached mapping of SemanticIdentifier to vector index.
|
java.util.ArrayList<SemanticLabel> |
getLabels()
Gets the labels used by the converter, each one corresponding to one
dimension in the converted Vector.
|
SemanticIdentifierMap |
getSemanticIdentifierMap()
Gets the SemanticIdentifierMap used by this converter.
|
int |
hashCode() |
void |
setCogxelFactory(CogxelFactory cogxelFactory)
Gets the CogxelFactory used to create the Cogxels used by the converter.
|
protected void |
setIdentifiers(java.util.ArrayList<SemanticIdentifier> identifiers)
Sets the list of cached SemanticIdentifiers.
|
protected void |
setIdentifierToIndexMap(java.util.HashMap<SemanticIdentifier,java.lang.Integer> identifierToIndexMap)
Sets the cached mapping of SemanticIdentifier to vector index.
|
void |
setLabels(java.util.ArrayList<SemanticLabel> labels)
Sets the labels to be used by the converter, each one corresponding to
one dimension in the converted Vector.
|
void |
setSemanticIdentifierMap(SemanticIdentifierMap semanticIdentifierMap)
Sets the SemanticIdentifierMap that the converter is to use.
|
void |
toCogxels(Vector data,
CogxelState cogxels)
Converts from an object of type DataType to an updated CogxelState.
|
getVectorFactory, setVectorFactory
public CogxelVectorConverter()
public CogxelVectorConverter(SemanticLabel... labels)
labels
- The labels to use.public CogxelVectorConverter(java.lang.Iterable<SemanticLabel> labels)
labels
- The labels to use.public CogxelVectorConverter(SemanticLabel[] labels, SemanticIdentifierMap semanticIdentifierMap)
labels
- The labels to use.semanticIdentifierMap
- The SemanticIdentifierMap to use.public CogxelVectorConverter(java.lang.Iterable<SemanticLabel> labels, SemanticIdentifierMap semanticIdentifierMap)
labels
- The labels to use.semanticIdentifierMap
- The SemanticIdentifierMap to use.public CogxelVectorConverter(SemanticLabel[] labels, SemanticIdentifierMap semanticIdentifierMap, VectorFactory<?> vectorFactory, CogxelFactory cogxelFactory)
labels
- The labels to use.semanticIdentifierMap
- The SemanticIdentifierMap to use.vectorFactory
- The VectorFactory to use.cogxelFactory
- The CogxelFactory to use.public CogxelVectorConverter(java.lang.Iterable<SemanticLabel> labels, SemanticIdentifierMap semanticIdentifierMap, VectorFactory<?> vectorFactory, CogxelFactory cogxelFactory)
labels
- The labels to use.semanticIdentifierMap
- The SemanticIdentifierMap to use.vectorFactory
- The VectorFactory to use.cogxelFactory
- The CogxelFactory to use.public CogxelVectorConverter(CogxelVectorConverter other)
other
- The CogxeLVectorConverter to copy.public CogxelVectorConverter clone()
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.clone
in interface CogxelConverter<Vector>
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public void addLabel(SemanticLabel label)
label
- The label to add.public void addLabels(java.lang.Iterable<SemanticLabel> labels)
labels
- The labels to add to the converter.public void addLabels(SemanticLabel[] labels)
labels
- The labels to add to the converter.protected void buildIdentifierCache()
protected void addLabelToIdentifierCache(SemanticLabel label)
label
- The label to add.public Vector fromCogxels(CogxelState cogxels)
fromCogxels
in interface CogxelConverter<Vector>
cogxels
- The CogxelState to convert to DataType.public void toCogxels(Vector data, CogxelState cogxels)
toCogxels
in interface CogxelConverter<Vector>
data
- The object to convert into the CogxelState.cogxels
- The CogxelState to update with the converted data.protected int findIndexForIdentifier(SemanticIdentifier identifier)
identifier
- The SemanticIdentifier to find the integer index for.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- public boolean equals(CogxelVectorConverter other)
other
- Another CogxelVectorConverter.public int hashCode()
hashCode
in class java.lang.Object
public Vector createEmptyVector()
public int getDimensionality()
public SemanticIdentifierMap getSemanticIdentifierMap()
getSemanticIdentifierMap
in interface CogxelConverter<Vector>
public void setSemanticIdentifierMap(SemanticIdentifierMap semanticIdentifierMap)
setSemanticIdentifierMap
in interface CogxelConverter<Vector>
semanticIdentifierMap
- The SemanticIdentifierMap the converter is
to use.public java.util.ArrayList<SemanticLabel> getLabels()
public void setLabels(java.util.ArrayList<SemanticLabel> labels)
labels
- The labels to be used by the converter.protected java.util.ArrayList<SemanticIdentifier> getIdentifiers()
protected void setIdentifiers(java.util.ArrayList<SemanticIdentifier> identifiers)
identifiers
- The list of cached SemanticIdentifiers.protected java.util.HashMap<SemanticIdentifier,java.lang.Integer> getIdentifierToIndexMap()
protected void setIdentifierToIndexMap(java.util.HashMap<SemanticIdentifier,java.lang.Integer> identifierToIndexMap)
identifierToIndexMap
- The cached mapping of SemanticIdentifier
to vector index.public CogxelFactory getCogxelFactory()
public void setCogxelFactory(CogxelFactory cogxelFactory)
cogxelFactory
- The CogxelFactory used to create the Cogxels used
by the converter.