* @param arguments an array of arguments with the type returned by getParameterTypes()
* @throws MaltChainedException
*/
public void initialize(Object[] arguments) throws MaltChainedException {
if (arguments.length != 3) {
throw new SyntaxGraphException("Could not initialize NumOfFeature: number of arguments are not correct. ");
}
// Checks that the two arguments are address functions
if (!(arguments[0] instanceof AddressFunction)) {
throw new SyntaxGraphException("Could not initialize NumOfFeature: the first argument is not an address function. ");
}
if (!(arguments[1] instanceof java.lang.String)) {
throw new SyntaxGraphException("Could not initialize NumOfFeature: the second argument (relation) is not a string. ");
}
if (!(arguments[2] instanceof java.lang.String)) {
throw new SyntaxGraphException("Could not initialize NumOfFeature: the third argument (normalization) is not a string. ");
}
setAddressFunction((AddressFunction)arguments[0]);
setNumOfRelation((String)arguments[1]);
normalizationString = (String)arguments[2];
// Creates a symbol table called "NUMOF" using one null value
setSymbolTable(tableHandler.addSymbolTable("NUMOF"+normalizationString, ColumnDescription.INPUT, "one"));
String[] items = normalizationString.split("\\|");
if (items.length <= 0 || !items[0].equals("0")) {
throw new SyntaxGraphException("Could not initialize NumOfFeature ("+this+"): the third argument (normalization) must contain a list of integer values separated with | and the first element must be 0.");
}
int tmp = -1;
for (int i = 0; i < items.length; i++) {
int v;
try {
v = Integer.parseInt(items[i]);
} catch (NumberFormatException e) {
throw new SyntaxGraphException("Could not initialize NumOfFeature ("+this+"): the third argument (normalization) must contain a sorted list of integer values separated with |", e);
}
normalization.put(v, ">="+v);
table.addSymbol(">="+v);
if (tmp != -1 && tmp >= v) {
throw new SyntaxGraphException("Could not initialize NumOfFeature ("+this+"): the third argument (normalization) must contain a sorted list of integer values separated with |");
}
tmp = v;
}
}