Package weka.classifiers
Class ScriptedClassifierUtils
- java.lang.Object
-
- weka.classifiers.ScriptedClassifierUtils
-
public class ScriptedClassifierUtils extends Object
Helper class for managing/updating scripts of classifiers that implementScriptedClassifier
.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ScriptedClassifierUtils.InitObserver
Observer that initializes for prediction.
-
Constructor Summary
Constructors Constructor Description ScriptedClassifierUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
determineUniqueID(AbstractAdvancedScript script, String placeholder, boolean prefix, boolean update)
Determines the unique ID (suffix/prefix) to use in the script, if the specified placeholder for the unique ID is present.static <T extends AbstractAdvancedScript>
Texpand(T script, Actor context)
Expands flow variables and placeholders in the script.protected static ScriptedClassifier
expand(ScriptedClassifier cls, PropertyDescriptor desc, String[] placeholders, String[] values)
Updates the placeholders with the specified values for the given property.static ScriptedClassifier
expand(ScriptedClassifier cls, String[] placeholders, String[] values)
Replaces the placeholder with the specified value in anyAbstractAdvancedScript
property of the classifier.static ScriptedClassifier
expand(ScriptedClassifier cls, String placeholder, String value)
Replaces the placeholder with the specified value in anyAbstractAdvancedScript
property of the classifier.static int
initPrediction(Object obj, Actor context)
Initializes any ScriptedClassifier within the specified object.
-
-
-
Method Detail
-
initPrediction
public static int initPrediction(Object obj, Actor context)
Initializes any ScriptedClassifier within the specified object.- Parameters:
obj
- the object to traversecontext
- the context to use for initialization- Returns:
- the number of initializations
-
determineUniqueID
public static String determineUniqueID(AbstractAdvancedScript script, String placeholder, boolean prefix, boolean update)
Determines the unique ID (suffix/prefix) to use in the script, if the specified placeholder for the unique ID is present.- Parameters:
script
- the script to inspect and updateplaceholder
- the placeholder that triggers the unique ID generationprefix
- whether to generate prefix or suffixupdate
- whether to replace the placeholder with the unique ID immediately- Returns:
- the generated unique ID, empty string if not required
-
expand
public static <T extends AbstractAdvancedScript> T expand(T script, Actor context)
Expands flow variables and placeholders in the script.- Parameters:
script
- the script to expandcontext
- the flow context- Returns:
- the expanded script
-
expand
protected static ScriptedClassifier expand(ScriptedClassifier cls, PropertyDescriptor desc, String[] placeholders, String[] values) throws Exception
Updates the placeholders with the specified values for the given property.- Parameters:
cls
- the classifier to updatedesc
- the property to updateplaceholders
- the placeholders to replacevalues
- the replacement values- Returns:
- the updated classifier
- Throws:
Exception
- if updating fails
-
expand
public static ScriptedClassifier expand(ScriptedClassifier cls, String placeholder, String value) throws Exception
Replaces the placeholder with the specified value in anyAbstractAdvancedScript
property of the classifier.- Parameters:
cls
- the classifier to updateplaceholder
- the placeholder to replacevalue
- the replacement value- Returns:
- the updated classifier
- Throws:
Exception
- if introspection or updating of scripts fails
-
expand
public static ScriptedClassifier expand(ScriptedClassifier cls, String[] placeholders, String[] values) throws Exception
Replaces the placeholder with the specified value in anyAbstractAdvancedScript
property of the classifier.- Parameters:
cls
- the classifier to updateplaceholders
- the placeholder to replacevalues
- the replacement value- Returns:
- the updated classifier
- Throws:
Exception
- if introspection or updating of scripts fails
-
-