use of org.dkpro.tc.api.features.PairFeatureExtractor in project dkpro-tc by dkpro.
the class InstanceExtractor method getSingleInstancePair.
private Instance getSingleInstancePair(Instance instance, JCas jcas) throws TextClassificationException {
try {
int jcasId = JCasUtil.selectSingle(jcas, JCasId.class).getId();
if (addInstanceId) {
instance.addFeature(InstanceIdFeature.retrieve(jcas));
}
for (FeatureExtractorResource_ImplBase featExt : featureExtractors) {
if (!(featExt instanceof PairFeatureExtractor)) {
throw new TextClassificationException("Using non-pair FE in pair mode: " + featExt.getResourceName());
}
JCas view1 = jcas.getView(Constants.PART_ONE);
JCas view2 = jcas.getView(Constants.PART_TWO);
instance.setOutcomes(getOutcomes(jcas, null));
instance.setWeight(getWeight(jcas, null));
instance.setJcasId(jcasId);
instance.addFeatures(((PairFeatureExtractor) featExt).extract(view1, view2));
}
} catch (CASException e) {
throw new TextClassificationException(e);
}
return instance;
}
use of org.dkpro.tc.api.features.PairFeatureExtractor 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