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;
}