Package org.maltparserx.core.options.option

Examples of org.maltparserx.core.options.option.Option


    oldFlags.put("llo", "lo"); oldFlags.put("lso", "lo");
    oldFlags.put("lli", "li"); oldFlags.put("lsi", "li");
    oldFlags.put("llx", "lx"); oldFlags.put("lsx", "lx");
    oldFlags.put("llv", "lv"); oldFlags.put("lsv", "lv");
    while (i < args.length) {
      Option option = null;
      String value = null;
      /* Recognizes
       * --optiongroup-optionname=value
       * --optionname=value
       * --optiongroup-optionname (unary option)
       * --optionname (unary option)
       */
      if (args[i].startsWith("--")) {
        if (args[i].length() == 2) {
          throw new OptionException("The argument contains only '--', please check the user guide to see the correct format. ");
        }
        String optionstring;
        String optiongroup;
        String optionname;
        int indexEqualSign = args[i].indexOf('=');
        if (indexEqualSign != -1) {
          value = args[i].substring(indexEqualSign+1);
          optionstring = args[i].substring(2, indexEqualSign);
        } else {
          value = null;
          optionstring = args[i].substring(2);
        }
        int indexMinusSign = optionstring.indexOf('-');
        if (indexMinusSign != -1) {
          optionname = optionstring.substring(indexMinusSign+1);
          optiongroup = optionstring.substring(0, indexMinusSign);       
        } else {
          optiongroup = null;
          optionname = optionstring;
        }
       
        option = optionDescriptions.getOption(optiongroup, optionname);
        if (option instanceof UnaryOption) {
          value = "used";
        }
        i++;
      }
      /* Recognizes
       * -optionflag value
       * -optionflag (unary option)
       */
      else if (args[i].startsWith("-")) {
        if (args[i].length() < 2) {
          throw new OptionException("Wrong use of option flag '"+args[i]+"', please check the user guide to see the correct format. ");
        }
        String flag = "";
        if (oldFlags.containsKey(args[i].substring(1))) {
          flag = oldFlags.get(args[i].substring(1));
        } else {
          flag = args[i].substring(1);
        }
       
        // Error message if the old flag '-r' (root handling) is used
        if (args[i].substring(1).equals("r")) {
          throw new OptionException("The flag -r (root_handling) is replaced with two flags -nr (allow_root) and -ne (allow_reduce) since MaltParser 1.7. Read more about these changes in the user guide.");
        }
       
          option = optionDescriptions.getOption(flag);

        if (option instanceof UnaryOption) {
          value = "used";
        } else {
          i++;
          if (args.length > i) {
            value = args[i];
          } else {
            throw new OptionException("Could not find the corresponding value for -"+option.getFlag()+". ");
          }
        }
        i++;
      } else {
        throw new OptionException("The option should starts with a minus sign (-), error at argument '"+args[i]+"'");
      }
      Object optionvalue = option.getValueObject(value);
      optionValues.addOptionValue(OptionContainer.COMMANDLINE, containerIndex, option, optionvalue);
    }
    return true;
  }
View Full Code Here


             
              if (optionname == null) {
                throw new OptionException("The option name is missing. ");
              }

              Option option = optionDescriptions.getOption(groupname, optionname);

              if (option instanceof UnaryOption) {
          value = "used";
        }
              if (value == null) {
                throw new OptionException("The option value is missing. ");
              }
              Object ovalue = option.getValueObject(value);
              optionValues.addOptionValue(OptionContainer.OPTIONFILE, containerIndex, option, ovalue);
            }
        }
  }
View Full Code Here

TOP

Related Classes of org.maltparserx.core.options.option.Option

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.