public class SubstringLabelerRules extends java.lang.Object implements EnvironmentHandler, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
SubstringLabelerRules.SubstringLabelerMatchRule
Inner class encapsulating the logic for matching
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MATCH_RULE_SEPARATOR
Separator for match rules in the internal representation
|
Constructor and Description |
---|
SubstringLabelerRules(java.lang.String matchDetails,
java.lang.String newAttName,
boolean consumeNonMatching,
boolean nominalBinary,
Instances inputStructure,
java.lang.String statusMessagePrefix,
Logger log,
Environment env)
Constructor
|
SubstringLabelerRules(java.lang.String matchDetails,
java.lang.String newAttName,
Instances inputStructure)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getConsumeNonMatching()
Get whether to consume non matching instances.
|
Instances |
getInputStructure()
Get the input structure
|
java.lang.String |
getNewAttributeName()
Get the name to use for the new attribute that is added
|
boolean |
getNominalBinary()
Get whether to create a nominal binary attribute in the case when the user
has not supplied an explicit label to use for each rule.
|
Instances |
getOutputStructure()
Get the output structure
|
Instance |
makeOutputInstance(Instance inputI,
boolean batch)
Process and input instance and return an output instance
|
static java.util.List<SubstringLabelerRules.SubstringLabelerMatchRule> |
matchRulesFromInternal(java.lang.String matchDetails,
Instances inputStructure,
java.lang.String statusMessagePrefix,
Logger log,
Environment env)
Get a list of match rules from an internally encoded match specification
|
void |
setConsumeNonMatching(boolean n)
Set whether to consume non matching instances.
|
void |
setEnvironment(Environment env)
Set environment variables to use.
|
void |
setNewAttributeName(java.lang.String newName)
Set the name to use for the new attribute that is added
|
void |
setNominalBinary(boolean n)
Set whether to create a nominal binary attribute in the case when the user
has not supplied an explicit label to use for each rule.
|
public static final java.lang.String MATCH_RULE_SEPARATOR
public SubstringLabelerRules(java.lang.String matchDetails, java.lang.String newAttName, boolean consumeNonMatching, boolean nominalBinary, Instances inputStructure, java.lang.String statusMessagePrefix, Logger log, Environment env) throws java.lang.Exception
matchDetails
- the internally encoded match details stringnewAttName
- the name of the new attribute that will be the labelconsumeNonMatching
- true if non-matching instances should be consumednominalBinary
- true if, in the case where no user labels have been
supplied, the new attribute should be a nominal binary one rather
than numericinputStructure
- the incoming instances structurestatusMessagePrefix
- an optional status message prefix string for
logginglog
- the log to use (may be null)env
- environment variablesjava.lang.Exception
public SubstringLabelerRules(java.lang.String matchDetails, java.lang.String newAttName, Instances inputStructure) throws java.lang.Exception
matchDetails
- the internally encoded match details string.newAttName
- the name of the new attribute that will be the labelinputStructure
- the incoming instances structurejava.lang.Exception
public void setConsumeNonMatching(boolean n)
n
- true then non-matching instances will be consumed (and only
matching, and thus labelled, instances will be output)public boolean getConsumeNonMatching()
public void setNominalBinary(boolean n)
n
- true if a binary indicator attribute should be nominal rather than
numericpublic boolean getNominalBinary()
public Instances getOutputStructure()
public Instances getInputStructure()
public void setNewAttributeName(java.lang.String newName)
newName
- the name to usepublic java.lang.String getNewAttributeName()
public void setEnvironment(Environment env)
EnvironmentHandler
setEnvironment
in interface EnvironmentHandler
env
- the environment variables to
usepublic static java.util.List<SubstringLabelerRules.SubstringLabelerMatchRule> matchRulesFromInternal(java.lang.String matchDetails, Instances inputStructure, java.lang.String statusMessagePrefix, Logger log, Environment env)
matchDetails
- the internally encoded specification of the match rulesinputStructure
- the input instances structurestatusMessagePrefix
- an optional status message prefix for logginglog
- the log to useenv
- environment variablespublic Instance makeOutputInstance(Instance inputI, boolean batch) throws java.lang.Exception
inputI
- the incoming instancebatch
- whether this is being processed as part of a batch of
instancesjava.lang.Exception
- if the output structure has not yet been determined