/** * Main method for testing this class. * * @param args should contain arguments to the filter: use -h for help */ public static void main(String[] args) { runFilter(new AddExpression(), args); } }
/** * Main method for testing this class. * * @param args should contain arguments to the filter: use -h for help */ public static void main(String[] args) { runFilter(new AddExpression(), args); } }
/** Creates a default AddExpression */ public Filter getFilter() { return new AddExpression(); }
/** Creates a default AddExpression */ public Filter getFilter() { return new AddExpression(); }
public static Expression parseString(String s) { if (s.length() == 0) return null; else { /*ADDITION*/ if (s.charAt(0) == '+') { Expression left = parseString(s.substring(1)); Expression right = parseString(s.substring(left.length() +1)); //where length should return expressions length return new AddExpression( left, right ); } /*LITERALS*/ else { int i=0; while (i < s.length() && s.charAt(i) != ' ') { // find the end of the number i++; } return new IntExpression(s.substring(0, i)); } } }
/** Creates a specialized AddExpression */ public Filter getFilter(String expr) { AddExpression af = new AddExpression(); af.setExpression(expr); return af; }
/** Creates a specialized AddExpression */ public Filter getFilter(String expr) { AddExpression af = new AddExpression(); af.setExpression(expr); return af; }
/** * Initializes the format for the dataset produced. Must be called before the * generateExample or generateExamples methods are used. Re-initializes the * random number generator with the given seed. * * @return the format for the dataset * @throws Exception if the generating of the format failed * @see #getSeed() */ @Override public Instances defineDataFormat() throws Exception { ArrayList<Attribute> atts; // initialize input format atts = new ArrayList<Attribute>(); atts.add(new Attribute("x")); m_RawData = new Instances(getRelationNameToUse(), atts, 0); m_Filter = new AddExpression(); m_Filter.setName("y"); m_Filter.setExpression(getExpression()); m_Filter.setInputFormat(m_RawData); return super.defineDataFormat(); }
/** * Initializes the format for the dataset produced. Must be called before the * generateExample or generateExamples methods are used. Re-initializes the * random number generator with the given seed. * * @return the format for the dataset * @throws Exception if the generating of the format failed * @see #getSeed() */ @Override public Instances defineDataFormat() throws Exception { ArrayList<Attribute> atts; // initialize input format atts = new ArrayList<Attribute>(); atts.add(new Attribute("x")); m_RawData = new Instances(getRelationNameToUse(), atts, 0); m_Filter = new AddExpression(); m_Filter.setName("y"); m_Filter.setExpression(getExpression()); m_Filter.setInputFormat(m_RawData); return super.defineDataFormat(); }
/** Creates a configured MultiFilter */ public Filter getConfiguredFilter() { MultiFilter result = new MultiFilter(); Filter[] filters = new Filter[2]; filters[0] = new Add(); ((Add) filters[0]).setAttributeIndex("last"); filters[1] = new AddExpression(); ((AddExpression) filters[1]).setExpression("a3+a6"); result.setFilters(filters); return result; }
/** Creates a configured MultiFilter */ public Filter getConfiguredFilter() { MultiFilter result = new MultiFilter(); Filter[] filters = new Filter[2]; filters[0] = new Add(); ((Add) filters[0]).setAttributeIndex("last"); filters[1] = new AddExpression(); ((AddExpression) filters[1]).setExpression("a3+a6"); result.setFilters(filters); return result; }