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
Extracts a value from a single field to be placed in an
Example
's metadata field.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
For olcut.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.protected
SimpleFieldExtractor
(String fieldName, String metadataName) Constructs a simple field extractor with the supplied field name and metadata field name. -
Method Summary
Modifier and TypeMethodDescriptionReturns Optional which is filled if extraction succeeded.extractField
(String fieldValue) Extracts the field value, or returnsOptional.empty()
if it failed to parse.Gets the field name this extractor operates on.Gets the metadata key name.void
Used by the OLCUT configuration system, and should not be called by external code.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.tribuo.data.columnar.FieldExtractor
getValueType
Methods inherited from interface com.oracle.labs.mlrg.olcut.provenance.Provenancable
getProvenance
-
Field Details
-
fieldName
-
metadataName
@Config(description="The metadata key to emit, defaults to field name if unpopulated") protected String metadataName
-
-
Constructor Details
-
SimpleFieldExtractor
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
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 interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
getFieldName
Gets the field name this extractor operates on.- Returns:
- The field name.
-
getMetadataName
Gets the metadata key name. This is the key into which this value will be written in anExample
if it is given toRowProcessor
.Defaults to the field name.
- Specified by:
getMetadataName
in interfaceFieldExtractor<T>
- Returns:
- The metadata key name.
-
extractField
Extracts the field value, or returnsOptional.empty()
if it failed to parse.- Parameters:
fieldValue
- The field value to read.- Returns:
- The extracted value.
-
extract
Description copied from interface:FieldExtractor
Returns Optional which is filled if extraction succeeded.- Specified by:
extract
in interfaceFieldExtractor<T>
- Parameters:
row
- The raw row from which to extract a value- Returns:
- A value.
-
toString
-