public class Util
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Util.NullPrintStream
Utility to class to make a void print stream.
|
static class |
Util.ProcessKillerShutdownHook |
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
argMapToString(java.util.Map<java.lang.String,java.lang.String> argMap)
Returns a string containing the arguments sorted by their name and joined together.
|
static java.util.List<java.util.List<java.lang.String>> |
cartesianProduct(java.util.List<java.util.List<java.lang.String>> sets)
Have a list of list of strings and need the Cartesian product? Look no further!
|
static void |
copyFile(java.io.File sourceFile,
java.io.File destFile) |
static weka.core.Instances |
createDummyInstances(int numInstances,
int numClasses,
int numUsefulNumeric,
int numUsefulCategorical,
int numRandomNumeric,
int numRandomCategorical,
int randomCategoricalSize,
int seed)
Makes a simple real valued dataset of a given size, with the class determined by index
|
static java.lang.String |
expandEnvironmentVariable(java.lang.String var)
Tries to evaluate the environment variable into something useful.
|
static java.lang.String |
expandPath(java.lang.String path)
Tries to resolve any relative paths/symlinks on a given path.
|
static java.io.File |
findExecutableOnPath(java.lang.String executableName)
Tries to find the given executable on the path.
|
static java.lang.String |
getAbsoluteClasspath() |
static java.lang.String |
getAutoWekaDistributionPath() |
static java.lang.String |
getJavaExecutable()
Tries to get the full path to the Java Executable that we're running.
|
static void |
initializeFile(java.lang.String aLogPath)
Initializes an empty file at the given path if it doesn't already exist.
|
static java.lang.String |
joinStrings(java.lang.String delim,
java.util.Collection<java.lang.String> strs)
Joins a collection of strings together separated by a delim in the
middle.
|
static java.lang.String |
joinStrings(java.lang.String delim,
java.lang.String... strs)
Joins a list of strings together separated by a delim in the middle.
|
static weka.core.Instances |
loadDataSource(java.io.InputStream stream) |
static void |
makePath(java.lang.String basePath)
Makes folders along the specified path.
|
static void |
parseCommandLineProperties(java.util.Properties props,
java.util.List<java.lang.String> cmdLineArgs)
Looks for command line arguments of the form -prop PROPERTYSTRING and adds them to the given properties object
|
static void |
parseCommandLineProperties(java.util.Properties props,
java.lang.String[] cmdLineArgs)
Looks for command line arguments of the form -prop PROPERTYSTRING and adds them to the given properties object
|
static void |
parsePropertyString(java.util.Properties props,
java.lang.String propStr)
Given a property string (var1=val1:var2=val2:....) convert it to a property object.
|
static java.util.Properties |
parsePropertyString(java.lang.String propStr)
Given a property string (var1=val1:var2=val2:....) convert it to a property object.
|
static java.lang.String |
propertiesToString(java.util.Properties props)
Converts a Properties object to a property string, escaping ':' as needed
|
static java.util.List<java.lang.String> |
quoteStrings(java.util.Collection<java.lang.String> oldStrs)
Looks for any strings that have spaces in them, and surrounds them with quotes.
|
static java.lang.String |
removeExtension(java.lang.String s)
Removes the extension from a file name string.
|
static java.util.Map<java.lang.String,java.lang.String> |
removeHidden(java.util.Map<java.lang.String,java.lang.String> inputMap)
Removes any arguments in the inputMap that happen to have a HIDDEN in their name.
|
static java.util.List<java.lang.String> |
splitNestedString(java.lang.String params,
java.lang.String delimStr,
int numLeft,
int numRight)
Splits a string, returning the string separated by the delimiter, with only the numLeft and numRight taken from the appropriate sides.
|
static java.util.List<java.lang.String> |
splitQuotedString(java.lang.String str)
Splits a string based on spaces, grouping atoms if they are inside non escaped double quotes.
|
public static java.util.Properties parsePropertyString(java.lang.String propStr)
propStr
- The property string.public static void parsePropertyString(java.util.Properties props, java.lang.String propStr)
props
- The properties object.propStr
- The property string.public static java.lang.String propertiesToString(java.util.Properties props)
props
- The properties object.public static void parseCommandLineProperties(java.util.Properties props, java.lang.String[] cmdLineArgs)
props
- The properties object.cmdLineArgs
- The arguments.public static void parseCommandLineProperties(java.util.Properties props, java.util.List<java.lang.String> cmdLineArgs)
props
- The properties object.cmdLineArgs
- The arguments.public static void initializeFile(java.lang.String aLogPath)
aLogPath
- The path to the file.public static void makePath(java.lang.String basePath)
basePath
- The path.public static java.lang.String getAbsoluteClasspath()
public static java.lang.String getJavaExecutable()
public static java.io.File findExecutableOnPath(java.lang.String executableName)
executableName
- The executable to look for.public static java.lang.String expandEnvironmentVariable(java.lang.String var)
var
- The environment variable to expand.public static java.lang.String expandPath(java.lang.String path)
path
- Th path to expand.public static java.util.List<java.util.List<java.lang.String>> cartesianProduct(java.util.List<java.util.List<java.lang.String>> sets)
sets
- The list of list of strings to compute the Cartesian product
for.public static java.lang.String argMapToString(java.util.Map<java.lang.String,java.lang.String> argMap)
argMap
- The map of arguments.public static java.util.Map<java.lang.String,java.lang.String> removeHidden(java.util.Map<java.lang.String,java.lang.String> inputMap)
inputMap
- The input map of arguments.public static java.lang.String removeExtension(java.lang.String s)
s
- The file name string.public static java.lang.String joinStrings(java.lang.String delim, java.lang.String... strs)
delim
- The delimiter used to join the strings.strs
- The strings to join.public static java.lang.String joinStrings(java.lang.String delim, java.util.Collection<java.lang.String> strs)
delim
- The delimiter used to join the strings.strs
- The strings to join.public static java.util.List<java.lang.String> quoteStrings(java.util.Collection<java.lang.String> oldStrs)
oldStrs
- The strings with spaces to escape.public static java.util.List<java.lang.String> splitNestedString(java.lang.String params, java.lang.String delimStr, int numLeft, int numRight)
params
- The string to split.delimStr
- The delimiter to split at.numLeft
- Characters to the left to take.numRight
- Characters to the right to take.public static weka.core.Instances createDummyInstances(int numInstances, int numClasses, int numUsefulNumeric, int numUsefulCategorical, int numRandomNumeric, int numRandomCategorical, int randomCategoricalSize, int seed)
numInstances
- The number of instances.numClasses
- The number of classes.numUsefulNumeric
- The number of correlated numeric attributes.numUsefulCategorical
- The number of correlated categoric
attributes.numRandomNumeric
- The number of uncorrelated numeric attributes.numRandomCategorical
- The number of uncorrelated categoric
attributes.randomCategoricalSize
- The number of categories in the uncorrelated
categoric attributes.seed
- The random seed.public static java.lang.String getAutoWekaDistributionPath()
public static java.util.List<java.lang.String> splitQuotedString(java.lang.String str)
str
- The string to split.public static weka.core.Instances loadDataSource(java.io.InputStream stream) throws java.lang.Exception
java.lang.Exception
public static void copyFile(java.io.File sourceFile, java.io.File destFile)