Search in sources :

Example 1 with DiffNrOfTokensPairFeatureExtractor

use of org.dkpro.tc.features.pair.core.length.DiffNrOfTokensPairFeatureExtractor in project dkpro-tc by dkpro.

the class DiffNrOfTokensPairFeatureExtractorTest method testExtract.

@Test
public void testExtract() throws ResourceInitializationException, AnalysisEngineProcessException, TextClassificationException {
    AnalysisEngineDescription desc = createEngineDescription(BreakIteratorSegmenter.class);
    AnalysisEngine engine = createEngine(desc);
    JCas jcas1 = engine.newJCas();
    jcas1.setDocumentLanguage("en");
    jcas1.setDocumentText("This is the text of view 1. And some more.");
    engine.process(jcas1);
    JCas jcas2 = engine.newJCas();
    jcas2.setDocumentLanguage("en");
    jcas2.setDocumentText("This is the text of view 2.");
    engine.process(jcas2);
    DiffNrOfTokensPairFeatureExtractor extractor = new DiffNrOfTokensPairFeatureExtractor();
    Set<Feature> features = extractor.extract(jcas1, jcas2);
    assertEquals(1, features.size());
    for (Feature feature : features) {
        assertFeature("DiffNrOfTokens", 4, feature);
    }
}
Also used : DiffNrOfTokensPairFeatureExtractor(org.dkpro.tc.features.pair.core.length.DiffNrOfTokensPairFeatureExtractor) AnalysisEngineDescription(org.apache.uima.analysis_engine.AnalysisEngineDescription) JCas(org.apache.uima.jcas.JCas) 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

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 DiffNrOfTokensPairFeatureExtractor (org.dkpro.tc.features.pair.core.length.DiffNrOfTokensPairFeatureExtractor)1 FeatureTestUtil.assertFeature (org.dkpro.tc.testing.FeatureTestUtil.assertFeature)1 Test (org.junit.Test)1