Esempio n. 1
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -delimiters &lt;value&gt;
   *  The delimiters to use
   *  (default ' \r\n\t.,;:'"()?!').</pre>
   *
   * <pre> -max &lt;int&gt;
   *  The max size of the Ngram (default = 3).</pre>
   *
   * <pre> -min &lt;int&gt;
   *  The min size of the Ngram (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 value;

    super.setOptions(options);

    value = Utils.getOption("max", options);
    if (value.length() != 0) setNGramMaxSize(Integer.parseInt(value));
    else setNGramMaxSize(3);

    value = Utils.getOption("min", options);
    if (value.length() != 0) setNGramMinSize(Integer.parseInt(value));
    else setNGramMinSize(1);
  }
Esempio n. 2
0
  /**
   * Sets the OptionHandler's options using the given list. All options will be set (or reset)
   * during this call (i.e. incremental setting of options is not possible).
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -S &lt;sample size&gt;
   *  Set sample size
   *  (default: 4)
   * </pre>
   *
   * <pre> -G &lt;seed&gt;
   *  Set the seed used to generate samples
   *  (default: 0)
   * </pre>
   *
   * <pre> -D
   *  Produce debugging output
   *  (default no debugging output)
   * </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 curropt = Utils.getOption('S', options);
    if (curropt.length() != 0) {
      setSampleSize(Integer.parseInt(curropt));
    } else setSampleSize(4);

    curropt = Utils.getOption('G', options);
    if (curropt.length() != 0) {
      setRandomSeed(Long.parseLong(curropt));
    } else {
      setRandomSeed(0);
    }

    setDebug(Utils.getFlag('D', options));
  }