@Override public ExampleSet apply(ExampleSet exampleSet) throws OperatorException { // recall: difference = minuend - subtrahend // but the subtrahend is last on the ioobjects stack, so pop first ExampleSet subtrahendSet = subtrahendInput.getData(ExampleSet.class); ExampleSet minuendSet = exampleSet; subtrahendSet.remapIds(); minuendSet.remapIds(); Attribute minuendId = minuendSet.getAttributes().getId(); Attribute subtrahendId = subtrahendSet.getAttributes().getId(); // sanity checks if ((minuendId == null) || (subtrahendId == null)) { throw new UserError(this, 129); } if (minuendId.getValueType() != subtrahendId.getValueType()) { throw new UserError( this, 120, new Object[] { subtrahendId.getName(), Ontology.VALUE_TYPE_NAMES[subtrahendId.getValueType()], Ontology.VALUE_TYPE_NAMES[minuendId.getValueType()] }); } List<Integer> indices = new LinkedList<>(); { int i = 0; for (Example example : minuendSet) { double id = example.getValue(minuendId); Example subtrahendExample = null; if (minuendId.isNominal()) { subtrahendExample = subtrahendSet.getExampleFromId( subtrahendId.getMapping().getIndex(minuendId.getMapping().mapIndex((int) id))); } else { subtrahendExample = subtrahendSet.getExampleFromId(id); } if (subtrahendExample == null) { indices.add(i); } i++; } } int[] indexArray = new int[indices.size()]; for (int i = 0; i < indices.size(); i++) { indexArray[i] = indices.get(i); } ExampleSet minusSet = new MappedExampleSet(minuendSet, indexArray); return minusSet; }