Class SimpleFieldExtractor<T>

java.lang.Object
org.tribuo.data.columnar.extractors.SimpleFieldExtractor<T>
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, FieldExtractor<T>
Direct Known Subclasses:
DateExtractor, DoubleExtractor, FloatExtractor, IdentityExtractor, IntExtractor, OffsetDateTimeExtractor

public abstract class SimpleFieldExtractor<T> extends Object implements FieldExtractor<T>
Extracts a value from a single field to be placed in an Example's metadata field.
  • Field Details

    • fieldName

      @Config(mandatory=true, description="The field name to read.") protected String fieldName
    • metadataName

      @Config(description="The metadata key to emit, defaults to field name if unpopulated") protected String metadataName
  • Constructor Details

    • SimpleFieldExtractor

      protected SimpleFieldExtractor(String fieldName)
      Constructs a simple field extractor which reads from the supplied field name and writes out to a metadata field with the same name.
      Parameters:
      fieldName - The field name to read from.
    • SimpleFieldExtractor

      protected SimpleFieldExtractor(String fieldName, String metadataName)
      Constructs a simple field extractor with the supplied field name and metadata field name.
      Parameters:
      fieldName - The field name to read.
      metadataName - The metadata field name to write to.
    • SimpleFieldExtractor

      protected SimpleFieldExtractor()
      For olcut.
  • Method Details

    • postConfig

      public void postConfig()
      Used by the OLCUT configuration system, and should not be called by external code.
      Specified by:
      postConfig in interface com.oracle.labs.mlrg.olcut.config.Configurable
    • getFieldName

      public String getFieldName()
      Gets the field name this extractor operates on.
      Returns:
      The field name.
    • getMetadataName

      public String getMetadataName()
      Gets the metadata key name. This is the key into which this value will be written in an Example if it is given to RowProcessor.

      Defaults to the field name.

      Specified by:
      getMetadataName in interface FieldExtractor<T>
      Returns:
      The metadata key name.
    • extractField

      protected abstract Optional<T> extractField(String fieldValue)
      Extracts the field value, or returns Optional.empty() if it failed to parse.
      Parameters:
      fieldValue - The field value to read.
      Returns:
      The extracted value.
    • extract

      public Optional<T> extract(ColumnarIterator.Row row)
      Description copied from interface: FieldExtractor
      Returns Optional which is filled if extraction succeeded.
      Specified by:
      extract in interface FieldExtractor<T>
      Parameters:
      row - The raw row from which to extract a value
      Returns:
      A value.
    • toString

      public String toString()
      Overrides:
      toString in class Object