use of de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS_ADV in project dkpro-tc by dkpro.
the class AdjectiveEndingFeatureExtractor method extract.
@Override
public Set<Feature> extract(JCas jcas, TextClassificationTarget aTarget) {
double able = 0;
double al = 0;
double ful = 0;
double ible = 0;
double ic = 0;
double ive = 0;
double less = 0;
double ous = 0;
double ly = 0;
int n = 0;
for (POS_ADJ adj : JCasUtil.selectCovered(jcas, POS_ADJ.class, aTarget)) {
n++;
String text = adj.getCoveredText().toLowerCase();
if (text.endsWith("able")) {
able++;
} else if (text.endsWith("al")) {
al++;
} else if (text.endsWith("ful")) {
ful++;
} else if (text.endsWith("ible")) {
ible++;
} else if (text.endsWith("ic")) {
ic++;
} else if (text.endsWith("ive")) {
ive++;
} else if (text.endsWith("less")) {
less++;
} else if (text.endsWith("ous")) {
ous++;
}
}
int m = 0;
for (POS_ADV adv : JCasUtil.select(jcas, POS_ADV.class)) {
m++;
String text = adv.getCoveredText().toLowerCase();
if (text.endsWith("ly")) {
ly++;
}
}
Set<Feature> featSet = new HashSet<Feature>();
featSet.add(new Feature(ADJ_ENDING1, n > 0 ? able * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADJ_ENDING2, n > 0 ? al * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADJ_ENDING3, n > 0 ? ful * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADJ_ENDING4, n > 0 ? ible * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADJ_ENDING5, n > 0 ? less * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADJ_ENDING6, n > 0 ? ous * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADJ_ENDING7, n > 0 ? ive * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADJ_ENDING8, n > 0 ? ic * 100 / n : 0, n == 0, FeatureType.NUMERIC));
featSet.add(new Feature(ADV_ENDING9, m > 0 ? ly * 100 / m : 0, n == 0, FeatureType.NUMERIC));
return featSet;
}