use of org.apache.uima.analysis_engine.AnalysisEngineDescription 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);
}
}
}
use of org.apache.uima.analysis_engine.AnalysisEngineDescription in project dkpro-tc by dkpro.
the class EmoticonRatioTest method emoticonRatioFeatureExtractorTest.
@Test
public void emoticonRatioFeatureExtractorTest() throws Exception {
AnalysisEngineDescription desc = createEngineDescription(NoOpAnnotator.class);
AnalysisEngine engine = createEngine(desc);
TokenBuilder<Token, Sentence> builder = TokenBuilder.create(Token.class, Sentence.class);
JCas jcas = engine.newJCas();
jcas.setDocumentLanguage("en");
builder.buildTokens(jcas, "This is a very emotional tweet ;-)");
POS_EMO emo = new POS_EMO(jcas);
emo.setBegin(31);
emo.setEnd(34);
emo.addToIndexes();
engine.process(jcas);
TextClassificationTarget aTarget = new TextClassificationTarget(jcas, 0, jcas.getDocumentText().length());
aTarget.addToIndexes();
EmoticonRatio extractor = new EmoticonRatio();
List<Feature> features = new ArrayList<Feature>(extractor.extract(jcas, aTarget));
Assert.assertEquals(1, features.size());
for (Feature feature : features) {
assertFeature(EmoticonRatio.class.getSimpleName(), 0.14, feature, 0.01);
}
}
use of org.apache.uima.analysis_engine.AnalysisEngineDescription in project dkpro-tc by dkpro.
the class DiffNounChunkTokenLengthTest method setUp.
@Before
public void setUp() throws ResourceInitializationException, AnalysisEngineProcessException {
AnalysisEngineDescription desc = createEngineDescription(BreakIteratorSegmenter.class);
AnalysisEngine engine = createEngine(desc);
jcas1 = engine.newJCas();
jcas1.setDocumentLanguage("en");
jcas1.setDocumentText("This is the text of view 1");
engine.process(jcas1);
jcas2 = engine.newJCas();
jcas2.setDocumentLanguage("en");
jcas2.setDocumentText("This is the text of view 2");
engine.process(jcas2);
}
use of org.apache.uima.analysis_engine.AnalysisEngineDescription 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);
}
}
use of org.apache.uima.analysis_engine.AnalysisEngineDescription in project dkpro-tc by dkpro.
the class BaselinePairFeatureTest method extractTest.
@Test
public void extractTest() throws Exception {
AnalysisEngineDescription desc = createEngineDescription(BreakIteratorSegmenter.class);
AnalysisEngine engine = createEngine(desc);
PairFeatureExtractor extractor = new AlwaysZeroPairFeatureExtractor();
Set<Feature> features = runExtractor(engine, extractor);
assertEquals(1, features.size());
for (Feature feature : features) {
assertFeature("BaselineFeature", 0, feature);
}
}
Aggregations