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 classScriptedClassifierUtils.ExpandPlaceholdersObserverExpands placeholders when traversing properties.static classScriptedClassifierUtils.InitObserverObserver that initializes for prediction.
-
Constructor Summary
Constructors Constructor Description ScriptedClassifierUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdetermineUniqueID(adams.gui.core.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.protected static voidexpand(Object obj, String[] placeholders, String[] values)Expands the placeholders in the object.static <T extends adams.gui.core.AbstractAdvancedScript>
Texpand(T script, adams.flow.core.Actor context)Expands flow variables and placeholders in the script.protected static ScriptedClassifierexpand(ScriptedClassifier cls, PropertyDescriptor desc, String[] placeholders, String[] values)Updates the placeholders with the specified values for the given property.static ScriptedClassifierexpand(ScriptedClassifier cls, String[] placeholders, String[] values)Replaces the placeholder with the specified value in anyAbstractAdvancedScriptorAbstractBaseStringproperty of the classifier.static ScriptedClassifierexpand(ScriptedClassifier cls, String placeholder, String value)Replaces the placeholder with the specified value in anyAbstractAdvancedScriptorAbstractBaseStringproperty of the classifier.static intinitPrediction(Object obj, adams.flow.core.Actor context)Initializes any ScriptedClassifier within the specified object.
-
-
-
Method Detail
-
initPrediction
public static int initPrediction(Object obj, adams.flow.core.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(adams.gui.core.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 adams.gui.core.AbstractAdvancedScript> T expand(T script, adams.flow.core.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 void expand(Object obj, String[] placeholders, String[] values) throws Exception
Expands the placeholders in the object.- Parameters:
obj- the object to expandplaceholders- the placeholders to replacevalues- the replacement values- Throws:
Exception- if updating fails
-
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 anyAbstractAdvancedScriptorAbstractBaseStringproperty 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 anyAbstractAdvancedScriptorAbstractBaseStringproperty 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
-
-