Package org.tribuo
Class FeatureMap
java.lang.Object
org.tribuo.FeatureMap
- All Implemented Interfaces:
Serializable
,Iterable<VariableInfo>
,ProtoSerializable<org.tribuo.protos.core.FeatureDomainProto>
- Direct Known Subclasses:
ImmutableFeatureMap
,MutableFeatureMap
public abstract class FeatureMap
extends Object
implements Serializable, ProtoSerializable<org.tribuo.protos.core.FeatureDomainProto>, Iterable<VariableInfo>
A map from Strings to
VariableInfo
objects storing
information about a feature.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<String,
VariableInfo> Map from the feature names to their info.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs an empty feature map.protected
FeatureMap
(Map<String, ? extends VariableInfo> m) Constructs a feature map wrapping the supplied map.protected
FeatureMap
(FeatureMap map) Constructs a deep copy of the supplied feature map. -
Method Summary
Modifier and TypeMethodDescriptionstatic FeatureMap
deserialize
(org.tribuo.protos.core.FeatureDomainProto proto) Deserializes aFeatureDomainProto
into aFeatureMap
subclass.boolean
domainEquals
(FeatureMap other) Check if this feature map contains the same features as the supplied one.boolean
Gets the variable info associated with that feature name, or null if it's unknown.int
hashCode()
iterator()
keySet()
Returns all the feature names in the domain.int
size()
Returns the number of features in the domain.Same as the toString, but ordered by name, and with newlines.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.tribuo.protos.ProtoSerializable
serialize
-
Field Details
-
m
Map from the feature names to their info.
-
-
Constructor Details
-
FeatureMap
protected FeatureMap()Constructs an empty feature map. -
FeatureMap
Constructs a deep copy of the supplied feature map.- Parameters:
map
- The map to copy.
-
FeatureMap
Constructs a feature map wrapping the supplied map.Note the map is not defensively copied.
- Parameters:
m
- The map to wrap.
-
-
Method Details
-
get
Gets the variable info associated with that feature name, or null if it's unknown.- Parameters:
name
- The feature name.- Returns:
- The variable info or null.
-
size
public int size()Returns the number of features in the domain.- Returns:
- The number of features.
-
toString
-
keySet
Returns all the feature names in the domain.- Returns:
- The feature names.
-
iterator
- Specified by:
iterator
in interfaceIterable<VariableInfo>
-
equals
-
hashCode
public int hashCode() -
toReadableString
Same as the toString, but ordered by name, and with newlines.- Returns:
- A String representation of this FeatureMap.
-
domainEquals
Check if this feature map contains the same features as the supplied one.- Parameters:
other
- The feature map to check.- Returns:
- True if the two feature maps contain the same named features.
-
deserialize
Deserializes aFeatureDomainProto
into aFeatureMap
subclass.- Parameters:
proto
- The proto to deserialize.- Returns:
- The deserialized FeatureMap.
-