use of de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS_PRON in project dkpro-tc by dkpro.
the class PronounRatioFeatureExtractor method extract.
@Override
public Set<Feature> extract(JCas jcas, TextClassificationTarget aTarget) throws TextClassificationException {
int heCount = 0;
int sheCount = 0;
int iCount = 0;
int weCount = 0;
int theyCount = 0;
int usCount = 0;
int youCount = 0;
int n = 0;
for (POS_PRON pronoun : JCasUtil.selectCovered(jcas, POS_PRON.class, aTarget)) {
n++;
String text = pronoun.getCoveredText().toLowerCase();
if (text.equals("he")) {
heCount++;
} else if (text.equals("she")) {
sheCount++;
} else if (text.equals("i")) {
iCount++;
} else if (text.equals("we")) {
weCount++;
} else if (text.equals("they")) {
theyCount++;
} else if (text.equals("us")) {
usCount++;
} else if (text.equals("you")) {
youCount++;
}
}
Set<Feature> features = new HashSet<Feature>();
if (n > 0) {
features.add(new Feature(FN_HE_RATIO, (double) heCount / n, FeatureType.NUMERIC));
features.add(new Feature(FN_SHE_RATIO, (double) sheCount / n, FeatureType.NUMERIC));
features.add(new Feature(FN_I_RATIO, (double) iCount / n, FeatureType.NUMERIC));
features.add(new Feature(FN_WE_RATIO, (double) weCount / n, FeatureType.NUMERIC));
features.add(new Feature(FN_THEY_RATIO, (double) theyCount / n, FeatureType.NUMERIC));
features.add(new Feature(FN_US_RATIO, (double) usCount / n, FeatureType.NUMERIC));
features.add(new Feature(FN_YOU_RATIO, (double) youCount / n, FeatureType.NUMERIC));
}
return features;
}