Search in sources :

Example 1 with NumberOfHashTags

use of org.dkpro.tc.features.twitter.NumberOfHashTags in project dkpro-tc by dkpro.

the class NumberOfHashTagsTest method numberOfHashTagsFeatureExtractorTest.

@Test
public void numberOfHashTagsFeatureExtractorTest() throws Exception {
    AnalysisEngineDescription desc = createEngineDescription(NoOpAnnotator.class);
    AnalysisEngine engine = createEngine(desc);
    JCas jcas = engine.newJCas();
    jcas.setDocumentLanguage("en");
    jcas.setDocumentText("This is a very #emotional tweet ;-) #icouldcry #ILoveHashTags");
    engine.process(jcas);
    TextClassificationTarget aTarget = new TextClassificationTarget(jcas, 0, jcas.getDocumentText().length());
    aTarget.addToIndexes();
    NumberOfHashTags extractor = new NumberOfHashTags();
    List<Feature> features = new ArrayList<Feature>(extractor.extract(jcas, aTarget));
    Assert.assertEquals(1, features.size());
    for (Feature feature : features) {
        assertFeature(NumberOfHashTags.class.getSimpleName(), 3, feature);
    }
}
Also used : AnalysisEngineDescription(org.apache.uima.analysis_engine.AnalysisEngineDescription) TextClassificationTarget(org.dkpro.tc.api.type.TextClassificationTarget) ArrayList(java.util.ArrayList) JCas(org.apache.uima.jcas.JCas) NumberOfHashTags(org.dkpro.tc.features.twitter.NumberOfHashTags) 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

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 NumberOfHashTags (org.dkpro.tc.features.twitter.NumberOfHashTags)1 FeatureTestUtil.assertFeature (org.dkpro.tc.testing.FeatureTestUtil.assertFeature)1 Test (org.junit.Test)1