Class DateFieldProcessor

java.lang.Object
org.tribuo.data.columnar.processors.field.DateFieldProcessor
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, FieldProcessor

public final class DateFieldProcessor extends Object implements FieldProcessor
Processes a column that contains a date value. The features are named based on the column name and the feature type extracted.

This class uses LocalDate

Returns an empty list if the date failed to parse or was empty.

  • Constructor Details

    • DateFieldProcessor

      public DateFieldProcessor(String fieldName, EnumSet<DateFieldProcessor.DateFeatureType> featureTypes, String dateFormat)
      Constructs a field processor which parses a date from the specified field name using the supplied format string then extracts date features according to the supplied EnumSet.

      Defaults to Locale.US.

      Throws IllegalArgumentException if the date format is invalid.

      Parameters:
      fieldName - The field name to read.
      featureTypes - The features to extract.
      dateFormat - The date format to use.
    • DateFieldProcessor

      public DateFieldProcessor(String fieldName, EnumSet<DateFieldProcessor.DateFeatureType> featureTypes, String dateFormat, String localeLanguage, String localeCountry)
      Constructs a field processor which parses a date from the specified field name using the supplied format string then extracts date features according to the supplied EnumSet.

      Throws IllegalArgumentException if the date format is invalid.

      Parameters:
      fieldName - The field name to read.
      featureTypes - The features to extract.
      dateFormat - The date format to use.
      localeLanguage - The Locale language.
      localeCountry - The Locale country.
  • 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()
      Description copied from interface: FieldProcessor
      Gets the field name this FieldProcessor uses.
      Specified by:
      getFieldName in interface FieldProcessor
      Returns:
      The field name.
    • process

      public List<ColumnarFeature> process(String value)
      Description copied from interface: FieldProcessor
      Processes the field value and generates a (possibly empty) list of ColumnarFeatures.
      Specified by:
      process in interface FieldProcessor
      Parameters:
      value - The field value to process.
      Returns:
      A list of ColumnarFeatures.
    • getFeatureType

      public FieldProcessor.GeneratedFeatureType getFeatureType()
      Description copied from interface: FieldProcessor
      Returns the feature type this FieldProcessor generates.
      Specified by:
      getFeatureType in interface FieldProcessor
      Returns:
      The feature type.
    • copy

      public FieldProcessor copy(String newFieldName)
      Description copied from interface: FieldProcessor
      Returns a copy of this FieldProcessor bound to the supplied newFieldName.
      Specified by:
      copy in interface FieldProcessor
      Parameters:
      newFieldName - The new field name for the copy.
      Returns:
      A copy of this FieldProcessor.
    • toString

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

      public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>