package pl.edu.icm.cermine.metadata.zoneclassification.features;

import pl.edu.icm.cermine.structure.model.BxPage;
import pl.edu.icm.cermine.structure.model.BxZone;
import pl.edu.icm.cermine.tools.classification.features.FeatureCalculator;

public class PreviousZoneFeature extends FeatureCalculator<BxZone, BxPage>
{
	private static String featureName = "PreviousZoneFeature";
	
	@Override
	public String getFeatureName() {
		return featureName;
	}

	@Override
	public double calculateFeatureValue(BxZone object, BxPage context) {
		for(BxZone zone: context.getZones()) {
			if(zone == object) {
				if(zone.hasPrev()) {
					return (double) zone.getPrev().getLabel().ordinal();
				} else
					return -1.0;
			}
		}
		return -1.0;
	}
}

@@ -532,82 +532,17 @@
 %7B%0A%09%09
-for(BxZone zone: context.getZones()) %7B%0A%09%09%09if(zone == object) %7B%0A%09%09%09%09if(zone
+if(object
 .has
@@ -550,26 +550,24 @@
 rev()) %7B%0A%09%09%09
-%09
-%09
 return (doub
@@ -570,20 +570,22 @@
 double) 
-zone
+object
 .getPrev
@@ -613,18 +613,16 @@
 ();%0A
-%09%09
 %09%09%7D else
 %0A%09%09%09
@@ -617,19 +617,19 @@
 %09%09%7D else
-%0A%09%09
+ %7B%0A
 %09%09%09retur
@@ -642,29 +642,9 @@
 ;%0A%09%09
-%09%7D%0A%09%09%7D%0A%09%09return -1.0;
+%7D
 %0A%09%7D%0A

change feature calculator implementation