Ejemplo n.º 1
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -D
   *  Turns on output of debugging information.</pre>
   *
   * <pre> -N &lt;double&gt;
   *  The number of attributes to randomly select.
   *  If &lt; 1 then percentage, &gt;= 1 absolute number.
   *  (default: 0.5)</pre>
   *
   * <pre> -S &lt;int&gt;
   *  The seed value.
   *  (default: 1)</pre>
   *
   * <!-- options-end -->
   *
   * @param options the list of options as an array of strings
   * @throws Exception if an option is not supported
   */
  public void setOptions(String[] options) throws Exception {
    String tmpStr;

    tmpStr = Utils.getOption("N", options);
    if (tmpStr.length() != 0) setNumAttributes(Double.parseDouble(tmpStr));
    else setNumAttributes(0.5);

    tmpStr = Utils.getOption("S", options);
    if (tmpStr.length() != 0) setSeed(Integer.parseInt(tmpStr));
    else setSeed(1);

    super.setOptions(options);
  }
Ejemplo n.º 2
0
  /**
   * Parses the options for this object.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -D
   *  Turns on output of debugging information.</pre>
   *
   * <pre> -R &lt;index1,index2-index4,...&gt;
   *  Specify list of string attributes to convert to words.
   *  (default: select all relational attributes)</pre>
   *
   * <pre> -V
   *  Inverts the matching sense of the selection.</pre>
   *
   * <pre> -S &lt;CASE|NON-CASE&gt;
   *  Determines the type of sorting:
   *  CASE = Case-sensitive
   *  NON-CASE = Case-insensitive
   *  (default: CASE)</pre>
   *
   * <!-- options-end -->
   *
   * @param options the options to use
   * @throws Exception if setting of options fails
   */
  public void setOptions(String[] options) throws Exception {
    String tmpStr;

    tmpStr = Utils.getOption('R', options);
    if (tmpStr.length() != 0) setAttributeIndices(tmpStr);
    else setAttributeIndices("first-last");

    setInvertSelection(Utils.getFlag('V', options));

    tmpStr = Utils.getOption('S', options);
    if (tmpStr.length() != 0) setSortType(new SelectedTag(tmpStr, TAGS_SORTTYPE));
    else setSortType(new SelectedTag(SORT_CASESENSITIVE, TAGS_SORTTYPE));

    super.setOptions(options);
  }
Ejemplo n.º 3
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre>
   * -D
   *  Turns on output of debugging information.
   * </pre>
   *
   * <pre>
   * -min &lt;double&gt;
   *  The minimum threshold. (default -Double.MAX_VALUE)
   * </pre>
   *
   * <pre>
   * -min-default &lt;double&gt;
   *  The replacement for values smaller than the minimum threshold.
   *  (default -Double.MAX_VALUE)
   * </pre>
   *
   * <pre>
   * -max &lt;double&gt;
   *  The maximum threshold. (default Double.MAX_VALUE)
   * </pre>
   *
   * <pre>
   * -max-default &lt;double&gt;
   *  The replacement for values larger than the maximum threshold.
   *  (default Double.MAX_VALUE)
   * </pre>
   *
   * <pre>
   * -closeto &lt;double&gt;
   *  The number values are checked for closeness. (default 0)
   * </pre>
   *
   * <pre>
   * -closeto-default &lt;double&gt;
   *  The replacement for values that are close to '-closeto'.
   *  (default 0)
   * </pre>
   *
   * <pre>
   * -closeto-tolerance &lt;double&gt;
   *  The tolerance below which numbers are considered being close to
   *  to each other. (default 1E-6)
   * </pre>
   *
   * <pre>
   * -decimals &lt;int&gt;
   *  The number of decimals to round to, -1 means no rounding at all.
   *  (default -1)
   * </pre>
   *
   * <pre>
   * -R &lt;col1,col2,...&gt;
   *  The list of columns to cleanse, e.g., first-last or first-3,5-last.
   *  (default first-last)
   * </pre>
   *
   * <pre>
   * -V
   *  Inverts the matching sense.
   * </pre>
   *
   * <pre>
   * -include-class
   *  Whether to include the class in the cleansing.
   *  The class column will always be skipped, if this flag is not
   *  present. (default no)
   * </pre>
   *
   * <!-- options-end -->
   *
   * @param options the list of options as an array of strings
   * @throws Exception if an option is not supported
   */
  @Override
  public void setOptions(String[] options) throws Exception {

    String tmpStr = Utils.getOption("min", options);
    if (tmpStr.length() != 0) {
      setMinThreshold(Double.parseDouble(tmpStr));
    } else {
      setMinThreshold(-Double.MAX_VALUE);
    }

    tmpStr = Utils.getOption("min-default", options);
    if (tmpStr.length() != 0) {
      setMinDefault(Double.parseDouble(tmpStr));
    } else {
      setMinDefault(-Double.MAX_VALUE);
    }

    tmpStr = Utils.getOption("max", options);
    if (tmpStr.length() != 0) {
      setMaxThreshold(Double.parseDouble(tmpStr));
    } else {
      setMaxThreshold(Double.MAX_VALUE);
    }

    tmpStr = Utils.getOption("max-default", options);
    if (tmpStr.length() != 0) {
      setMaxDefault(Double.parseDouble(tmpStr));
    } else {
      setMaxDefault(Double.MAX_VALUE);
    }

    tmpStr = Utils.getOption("closeto", options);
    if (tmpStr.length() != 0) {
      setCloseTo(Double.parseDouble(tmpStr));
    } else {
      setCloseTo(0);
    }

    tmpStr = Utils.getOption("closeto-default", options);
    if (tmpStr.length() != 0) {
      setCloseToDefault(Double.parseDouble(tmpStr));
    } else {
      setCloseToDefault(0);
    }

    tmpStr = Utils.getOption("closeto-tolerance", options);
    if (tmpStr.length() != 0) {
      setCloseToTolerance(Double.parseDouble(tmpStr));
    } else {
      setCloseToTolerance(1E-6);
    }

    tmpStr = Utils.getOption("R", options);
    if (tmpStr.length() != 0) {
      setAttributeIndices(tmpStr);
    } else {
      setAttributeIndices("first-last");
    }

    setInvertSelection(Utils.getFlag("V", options));

    setIncludeClass(Utils.getFlag("include-class", options));

    tmpStr = Utils.getOption("decimals", options);
    if (tmpStr.length() != 0) {
      setDecimals(Integer.parseInt(tmpStr));
    } else {
      setDecimals(-1);
    }

    super.setOptions(options);

    Utils.checkForRemainingOptions(options);
  }