/** * Create an option specification string for a filter * * @param f the filter * @return the option spec */ protected String getFilterSpec(Filter f) { return f.getClass().getName() + (f instanceof OptionHandler ? " " + Utils.joinOptions(((OptionHandler) f).getOptions()) : ""); }
/** * prints all the options to stdout */ protected static void printOptions(OptionHandler o) { Enumeration<Option> enm = o.listOptions(); System.out.println("Options for " + o.getClass().getName() + ":\n"); while (enm.hasMoreElements()) { Option option = enm.nextElement(); System.out.println(option.synopsis()); System.out.println(option.description()); } }
@Test public void testOptions() throws Exception { if (wrapper instanceof OptionHandler){ OptionHandler optionHandler = ((OptionHandler) wrapper); String[] options = optionHandler.getOptions(); String[] optionsCopy = Arrays.copyOf(options, options.length); optionHandler.setOptions(optionsCopy); String[] optionsAfter = optionHandler.getOptions(); Assert.assertArrayEquals(options, optionsAfter); } }
@Override public void resetLearningImpl() { try { instances = null; String clistring = clustererClasses[wekaAlgorithmOption.getChosenIndex()].getName(); clusterer = (weka.clusterers.AbstractClusterer) ClassOption.cliStringToObject(clistring, weka.clusterers.Clusterer.class, null); String rawOptions = parameterOption.getValue(); String[] options = rawOptions.split(" "); if (clusterer instanceof weka.core.OptionHandler) { ((weka.core.OptionHandler) clusterer).setOptions(options); Utils.checkForRemainingOptions(options); } } catch (Exception e) { e.printStackTrace(); } this.instanceConverter = new SamoaToWekaInstanceConverter(); }
/** * Set the options for this filter * * @param options the options * @throws Exception if a problem occurs */ public void setOptions(String[] options) throws Exception { String filterSpec = Utils.getOption("filter", options); if (!DistributedJobConfig.isEmpty(filterSpec)) { String[] spec = Utils.splitOptions(filterSpec); String filterClass = spec[0]; spec[0] = ""; Filter base = (Filter) Class.forName(filterClass).newInstance(); if (base instanceof OptionHandler) { ((OptionHandler) base).setOptions(spec); } setBaseFilter(base); } }
protected String makeClustererSpec(weka.clusterers.Clusterer clusterer) { String clusterSpec = clusterer.getClass().getCanonicalName(); clusterSpec = clusterSpec.substring(clusterSpec.lastIndexOf('.') + 1, clusterSpec.length()); String opts = " "; if (clusterer instanceof OptionHandler) { opts = Utils.joinOptions(((OptionHandler) clusterer).getOptions()); } return clusterSpec + opts; } }
/** * prints all the options to stdout */ protected static void printOptions(OptionHandler o) { Enumeration<Option> enm = o.listOptions(); System.out.println("Options for " + o.getClass().getName() + ":\n"); while (enm.hasMoreElements()) { Option option = enm.nextElement(); System.out.println(option.synopsis()); System.out.println(option.description()); } }
/** * tests the commandline operation of the saver. */ public void testSaverCommandlineArgs() { String[] options; options = getCommandlineOptions(false); try { ((OptionHandler) m_Saver).setOptions(options); } catch (Exception e) { e.printStackTrace(); fail("Command line test failed ('" + Utils.arrayToString(options) + "'): " + e.toString()); } }
/** * Create an option specification string for a filter * * @param f the filter * @return the option spec */ public static String getFilterSpec(Filter f) { return f.getClass().getName() + (f instanceof OptionHandler ? " " + Utils.joinOptions(((OptionHandler) f).getOptions()) : ""); }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addAll(Collections.list(super.listOptions())); result.add(new Option("\tFull name of the classifier analysed.\n" + "\teg: weka.classifiers.bayes.NaiveBayes\n" + "\t(default weka.classifiers.rules.ZeroR)", "W", 1, "-W")); if ((m_Classifier != null) && (m_Classifier instanceof OptionHandler)) { result.add(new Option("", "", 0, "\nOptions specific to classifier " + m_Classifier.getClass().getName() + ":")); result.addAll(Collections.list(((OptionHandler) m_Classifier) .listOptions())); } return result.elements(); }
/** * tests the commandline operation of the saver. */ public void testSaverCommandlineArgs() { String[] options; options = getCommandlineOptions(false); try { ((OptionHandler) m_Saver).setOptions(options); } catch (Exception e) { e.printStackTrace(); fail("Command line test failed ('" + Utils.arrayToString(options) + "'): " + e.toString()); } }
@Override public String getValueAsCLIString() { if ((this.currentValue == null) && (this.nullString != null)) { return this.nullString; } String result = currentValue.getClass().getName(); if (currentValue instanceof weka.core.OptionHandler) result += " " + Utils.joinOptions(((weka.core.OptionHandler) currentValue).getOptions()); result = result.trim(); return result; }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addAll(Collections.list(super.listOptions())); result.addElement(new Option("\tFull name of the OptionHandler analysed.\n" + "\teg: weka.classifiers.rules.ZeroR\n" + "\t(default weka.classifiers.rules.ZeroR)", "W", 1, "-W")); if (m_OptionHandler != null) { result.addElement(new Option("", "", 0, "\nOptions specific to option handler " + m_OptionHandler.getClass().getName() + ":")); result.addAll(Collections.list(m_OptionHandler.listOptions())); } return result.elements(); }
protected String makeSchemeSpec(Object scheme, int setNum, int maxSetNum) { String name = scheme.getClass().getCanonicalName(); name = name.substring(name.lastIndexOf('.') + 1, name.length()); if (scheme instanceof OptionHandler) { name += " " + Utils.joinOptions(((OptionHandler) scheme).getOptions()); } if (maxSetNum != 1) { name += " (set " + setNum + " of " + maxSetNum + ")"; } return name; }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addElement(new Option("\tFull name of the kernel analysed.\n" + "\teg: weka.classifiers.functions.supportVector.RBFKernel\n" + "\t(default weka.classifiers.functions.supportVector.RBFKernel)", "W", 1, "-W")); result.addAll(Collections.list(super.listOptions())); if ((m_Kernel != null) && (m_Kernel instanceof OptionHandler)) { result.addElement(new Option("", "", 0, "\nOptions specific to kernel " + m_Kernel.getClass().getName() + ":")); result.addAll(Collections.list(((OptionHandler) m_Kernel).listOptions())); } return result.elements(); }
protected String makeClustererSpec(weka.clusterers.Clusterer clusterer) { String clusterSpec = clusterer.getClass().getCanonicalName(); clusterSpec = clusterSpec.substring(clusterSpec.lastIndexOf('.') + 1, clusterSpec.length()); String opts = " "; if (clusterer instanceof OptionHandler) { opts = Utils.joinOptions(((OptionHandler) clusterer).getOptions()); } return clusterSpec + opts; } }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addAll(Collections.list(super.listOptions())); result.add(new Option("\tFull name of the associator analysed.\n" + "\teg: weka.associations.Apriori\n" + "\t(default weka.associations.Apriori)", "W", 1, "-W")); if ((m_Associator != null) && (m_Associator instanceof OptionHandler)) { result.add(new Option("", "", 0, "\nOptions specific to associator " + m_Associator.getClass().getName() + ":")); result.addAll(Collections.list(((OptionHandler) m_Associator) .listOptions())); } return result.elements(); }
protected String makeSchemeSpec(Object scheme, int setNum, int maxSetNum) { String name = scheme.getClass().getCanonicalName(); name = name.substring(name.lastIndexOf('.') + 1, name.length()); if (scheme instanceof OptionHandler) { name += " " + Utils.joinOptions(((OptionHandler) scheme).getOptions()); } if (maxSetNum != 1) { name += " (set " + setNum + " of " + maxSetNum + ")"; } return name; }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addElement(new Option("\tFull name of base associator.\n" + "\t(default: " + defaultAssociatorString() + ")", "W", 1, "-W")); if (m_Associator instanceof OptionHandler) { result.addElement(new Option("", "", 0, "\nOptions specific to associator " + m_Associator.getClass().getName() + ":")); result.addAll(Collections.list(((OptionHandler) m_Associator) .listOptions())); } return result.elements(); }
/** * Returns the commandline of the given object. * * @param obj the object to create the commandline for * @return the commandline */ public String getCommandline(Object obj) { String result; result = obj.getClass().getName(); if (obj instanceof OptionHandler) result += " " + Utils.joinOptions(((OptionHandler) obj).getOptions()); return result.trim(); }