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 |
|---|---|
protected java.lang.String |
m_attName
The name of the new "label" attribute
|
protected boolean |
m_consumeNonMatching
True if non matching instances should be "consumed" - i.e no output
instance created
|
protected Environment |
m_env
Environment variables
|
protected boolean |
m_hasLabels
True if the rules have user supplied labels
|
protected Instances |
m_inputStructure
The input structure
|
protected java.util.List<SubstringLabelerRules.SubstringLabelerMatchRule> |
m_matchRules
The list of rules
|
protected boolean |
m_nominalBinary
If not multiple labels then should new att be a nominal rather than numeric
binary one?
|
protected Instances |
m_outputStructure
The output structure
|
protected java.lang.String |
m_statusMessagePrefix
An optional prefix for status log messages
|
protected boolean |
m_voteLabels |
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
|
protected void |
makeOutputStructure()
Make the output instances structure
|
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
protected java.util.List<SubstringLabelerRules.SubstringLabelerMatchRule> m_matchRules
protected boolean m_hasLabels
protected boolean m_consumeNonMatching
protected Instances m_inputStructure
protected Instances m_outputStructure
protected java.lang.String m_attName
protected java.lang.String m_statusMessagePrefix
protected boolean m_nominalBinary
protected boolean m_voteLabels
protected transient Environment m_env
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.Exceptionpublic 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.Exceptionpublic 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)
EnvironmentHandlersetEnvironment in interface EnvironmentHandlerenv - 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 variablesprotected void makeOutputStructure()
throws java.lang.Exception
java.lang.Exception - if a problem occurspublic 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