Search in sources :

Example 1 with ContextualityMeasureFeatureExtractor

use of org.dkpro.tc.features.style.ContextualityMeasureFeatureExtractor in project dkpro-tc by dkpro.

the class ContextualityTest 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("This is a test.");
    engine.process(jcas);
    TextClassificationTarget aTarget = new TextClassificationTarget(jcas, 0, jcas.getDocumentText().length());
    aTarget.addToIndexes();
    ContextualityMeasureFeatureExtractor extractor = new ContextualityMeasureFeatureExtractor();
    List<Feature> features = new ArrayList<Feature>(extractor.extract(jcas, aTarget));
    Assert.assertEquals(8, features.size());
    for (Feature feature : features) {
        if (feature.getName().equals(CONTEXTUALITY_MEASURE_FN)) {
            assertFeature(CONTEXTUALITY_MEASURE_FN, 50.2, feature);
        }
    }
}
Also used : ContextualityMeasureFeatureExtractor(org.dkpro.tc.features.style.ContextualityMeasureFeatureExtractor) BreakIteratorSegmenter(de.tudarmstadt.ukp.dkpro.core.tokit.BreakIteratorSegmenter) AnalysisEngineDescription(org.apache.uima.analysis_engine.AnalysisEngineDescription) TextClassificationTarget(org.dkpro.tc.api.type.TextClassificationTarget) ArrayList(java.util.ArrayList) JCas(org.apache.uima.jcas.JCas) OpenNlpPosTagger(de.tudarmstadt.ukp.dkpro.core.opennlp.OpenNlpPosTagger) FeatureTestUtil.assertFeature(org.dkpro.tc.testing.FeatureTestUtil.assertFeature) Feature(org.dkpro.tc.api.features.Feature) AnalysisEngine(org.apache.uima.analysis_engine.AnalysisEngine) Test(org.junit.Test)

Aggregations

OpenNlpPosTagger (de.tudarmstadt.ukp.dkpro.core.opennlp.OpenNlpPosTagger)1 BreakIteratorSegmenter (de.tudarmstadt.ukp.dkpro.core.tokit.BreakIteratorSegmenter)1 ArrayList (java.util.ArrayList)1 AnalysisEngine (org.apache.uima.analysis_engine.AnalysisEngine)1 AnalysisEngineDescription (org.apache.uima.analysis_engine.AnalysisEngineDescription)1 JCas (org.apache.uima.jcas.JCas)1 Feature (org.dkpro.tc.api.features.Feature)1 TextClassificationTarget (org.dkpro.tc.api.type.TextClassificationTarget)1 ContextualityMeasureFeatureExtractor (org.dkpro.tc.features.style.ContextualityMeasureFeatureExtractor)1 FeatureTestUtil.assertFeature (org.dkpro.tc.testing.FeatureTestUtil.assertFeature)1 Test (org.junit.Test)1