/** * Compare the target segments to the 'otherSegments', and update the classifier by sum_x * [delta*x], for each example x corresponding to a target segment that's not in otherSegments. */ private int compareSegmentsAndIncrement( ExampleSchema schema, Segmentation segments, Segmentation otherSegments, Hyperplane[] accum, double delta, CandidateSegmentGroup g) { int errors = 0; // first, work out the name of the previous class for each segment Map<Segment, String> map = previousClassMap(segments, schema); Map<Segment, String> otherMap = previousClassMap(otherSegments, schema); String[] history = new String[1]; for (Iterator<Segment> j = segments.iterator(); j.hasNext(); ) { Segmentation.Segment seg = j.next(); String previousClass = map.get(seg); if (seg.lo >= 0 && (!otherSegments.contains(seg) || !otherMap.get(seg).equals(previousClass))) { errors++; history[0] = previousClass; Instance instance = new InstanceFromSequence(g.getSubsequenceExample(seg.lo, seg.hi), history); if (DEBUG) log.debug( "class " + schema.getClassName(seg.y) + " update " + delta + " for: " + instance.getSource()); accum[seg.y].increment(instance, delta); } } return errors; }