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 Details

  • Constructor Details

    • FeatureMap

      protected FeatureMap()
      Constructs an empty feature map.
    • FeatureMap

      protected FeatureMap(FeatureMap map)
      Constructs a deep copy of the supplied feature map.
      Parameters:
      map - The map to copy.
    • FeatureMap

      protected FeatureMap(Map<String,? extends VariableInfo> m)
      Constructs a feature map wrapping the supplied map.

      Note the map is not defensively copied.

      Parameters:
      m - The map to wrap.
  • Method Details

    • get

      public VariableInfo get(String name)
      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

      public String toString()
      Overrides:
      toString in class Object
    • keySet

      public Set<String> keySet()
      Returns all the feature names in the domain.
      Returns:
      The feature names.
    • iterator

      public Iterator<VariableInfo> iterator()
      Specified by:
      iterator in interface Iterable<VariableInfo>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toReadableString

      public String toReadableString()
      Same as the toString, but ordered by name, and with newlines.
      Returns:
      A String representation of this FeatureMap.
    • domainEquals

      public boolean domainEquals(FeatureMap other)
      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

      public static FeatureMap deserialize(org.tribuo.protos.core.FeatureDomainProto proto)
      Deserializes a FeatureDomainProto into a FeatureMap subclass.
      Parameters:
      proto - The proto to deserialize.
      Returns:
      The deserialized FeatureMap.