Package weka.gui.beans
Class SubstringLabelerRules.SubstringLabelerMatchRule
java.lang.Object
weka.gui.beans.SubstringLabelerRules.SubstringLabelerMatchRule
- All Implemented Interfaces:
Serializable
- Enclosing class:
- SubstringLabelerRules
public static class SubstringLabelerRules.SubstringLabelerMatchRule
extends Object
implements Serializable
Inner class encapsulating the logic for matching
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Separator for parts of the match specification -
Constructor Summary
ConstructorDescriptionConstructorSubstringLabelerMatchRule
(String setup) ConstructorSubstringLabelerMatchRule
(String match, boolean regex, boolean ignoreCase, String selectedAtts) Constructor -
Method Summary
Modifier and TypeMethodDescriptionApply this rule to the supplied instanceGet the attributes to apply the rule toboolean
Get whether to ignore case when matchinggetLabel()
Get the label to assign if this rule matches, or empty string if binary flag attribute is being created.getMatch()
Get the string/regex to use for matchingboolean
getRegex()
Get whether this is a regular expression match or notvoid
init
(Environment env, Instances structure) Initialize this match rule by substituting any environment variables in the attributes, match and label strings.void
Set the attributes to apply the rule tovoid
setIgnoreCase
(boolean ignore) Set whether to ignore case when matchingvoid
Set the label to assign if this rule matches, or empty string if binary flag attribute is being created.void
Set the string/regex to use for matchingvoid
setRegex
(boolean regex) Set whether this is a regular expression match or nottoString()
Return a textual description of this match ruleGet the internal representation of this rule
-
Field Details
-
MATCH_PART_SEPARATOR
Separator for parts of the match specification- See Also:
-
-
Constructor Details
-
SubstringLabelerMatchRule
public SubstringLabelerMatchRule()Constructor -
SubstringLabelerMatchRule
Constructor- Parameters:
setup
- an internally encoded representation of all the match information for this rule
-
SubstringLabelerMatchRule
public SubstringLabelerMatchRule(String match, boolean regex, boolean ignoreCase, String selectedAtts) Constructor- Parameters:
match
- the match stringregex
- true if this is a regular expression matchignoreCase
- true if case is to be ignoredselectedAtts
- the attributes to apply the rule to
-
-
Method Details
-
setMatch
Set the string/regex to use for matching- Parameters:
match
- the match string
-
getMatch
Get the string/regex to use for matching- Returns:
- the match string
-
setLabel
Set the label to assign if this rule matches, or empty string if binary flag attribute is being created.- Parameters:
label
- the label string or empty string
-
getLabel
Get the label to assign if this rule matches, or empty string if binary flag attribute is being created.- Returns:
- the label string or empty string
-
setRegex
public void setRegex(boolean regex) Set whether this is a regular expression match or not- Parameters:
regex
- true if this is a regular expression match
-
getRegex
public boolean getRegex()Get whether this is a regular expression match or not- Returns:
- true if this is a regular expression match
-
setIgnoreCase
public void setIgnoreCase(boolean ignore) Set whether to ignore case when matching- Parameters:
ignore
- true if case is to be ignored
-
getIgnoreCase
public boolean getIgnoreCase()Get whether to ignore case when matching- Returns:
- true if case is to be ignored
-
setAttsToApplyTo
Set the attributes to apply the rule to- Parameters:
a
- the attributes to apply the rule to.
-
getAttsToApplyTo
Get the attributes to apply the rule to- Returns:
- the attributes to apply the rule to.
-
init
Initialize this match rule by substituting any environment variables in the attributes, match and label strings. Sets up the attribute indices to apply to and validates that the selected attributes are all String attributes- Parameters:
env
- the environment variablesstructure
- the structure of the incoming instances
-
apply
Apply this rule to the supplied instance- Parameters:
inst
- the instance to apply to- Returns:
- the label (or empty string) if this rule matches (empty string is used to indicate a match in the case that a binary flag attribute is being created), or null if the rule doesn't match.
-
toString
Return a textual description of this match rule -
toStringInternal
Get the internal representation of this rule- Returns:
- a string formatted in the internal representation
-