/** * Applies a predicate on a table's row. * @param table an obvious table * @param rowId row index * @return true if it applies */ public boolean apply(Table table, int rowId) { WrapToPrefTuple tuple = new WrapToPrefTuple(new TupleImpl(table, rowId)); return prefPred.getBoolean(tuple); }
@Override public Tuple getTuple(int arg0) { if (this.isValidRow(arg0)) { Object[] values = new Object[table.getSchema().getColumnCount()]; for (int i = 0; i < table.getSchema().getColumnCount(); i++) { values[i] = table.getValue(arg0, i); } return new WrapToPrefTuple(new TupleImpl(table.getSchema(), values), arg0); } else { return null; } }
public ObviousWekaInstances(Table table, String name, FastVector attInfo, int cap) { super(name, attInfo, cap); this.table = table; IntIterator iter = this.table.rowIterator(); while(iter.hasNext()) { m_Instances.addElement(new ObviousWekaInstance( new TupleImpl(table, iter.nextInt()), this)); } for (int i = 0; i < table.getSchema().getColumnCount(); i++) { m_Attributes.addElement(attribute(i)); } }
@Override public Tuple addTuple(Tuple arg0) { Object[] values = new Object[table.getSchema().getColumnCount()]; obvious.data.Tuple obviousTuple = new TupleImpl(table.getSchema(), values); int r = table.addRow(obviousTuple); return this.getTuple(r); }
@Override public void add(Instance instance) { double[] values = instance.toDoubleArray(); Object[] obvValues = new Object[table.getSchema().getColumnCount()]; for (int i = 0; i < table.getSchema().getColumnCount(); i++) { Attribute att = instance.attribute(i); Class<?> c = table.getSchema().getColumnType(i); if(att.isString() && ObviousWekaUtils.isString(c)) { obvValues[i] = instance.attribute(i).value(i); } else if (att.isNumeric() && ObviousWekaUtils.isNumeric(c)) { obvValues[i] = instance.value(att); } else if (att.isDate() && ObviousWekaUtils.isDate(c)) { obvValues[i] = new Date((long) values[i]); } else { obvValues[i] = null; } } Tuple tuple = new TupleImpl(table.getSchema(), obvValues); m_Instances.addElement(new ObviousWekaInstance(tuple, this)); table.addRow(tuple); }