use of org.dkpro.tc.features.syntax.PronounRatioFeatureExtractor in project dkpro-tc by dkpro.
the class PronounRatioTest method posContextFeatureExtractorTest.
@Test
public void posContextFeatureExtractorTest() throws Exception {
AnalysisEngineDescription desc = createEngineDescription(createEngineDescription(BreakIteratorSegmenter.class), createEngineDescription(OpenNlpPosTagger.class, OpenNlpPosTagger.PARAM_LANGUAGE, "en"));
AnalysisEngine engine = createEngine(desc);
JCas jcas = engine.newJCas();
jcas.setDocumentLanguage("en");
jcas.setDocumentText("He is no tester. I am a tester.");
engine.process(jcas);
TextClassificationTarget aTarget = new TextClassificationTarget(jcas, 0, jcas.getDocumentText().length());
aTarget.addToIndexes();
PronounRatioFeatureExtractor extractor = new PronounRatioFeatureExtractor();
List<Feature> features = new ArrayList<Feature>(extractor.extract(jcas, aTarget));
Assert.assertEquals(7, features.size());
for (Feature feature : features) {
if (feature.getName().equals(FN_HE_RATIO)) {
assertFeature(FN_HE_RATIO, 0.5, feature);
} else if (feature.getName().equals(FN_WE_RATIO)) {
assertFeature(FN_WE_RATIO, 0.0, feature);
}
}
}
Aggregations