DiffNounChunkCharacterLength extends FeatureExtractorResource_ImplBase implements PairFeatureExtractor { @Override public Set<Feature> extract(JCas view1, JCas view2) throws TextClassificationException { return new Feature("DiffNounPhraseCharacterLength", getAverageNounPhraseCharacterLength(view1) - getAverageNounPhraseCharacterLength(view2), FeatureType.NUMERIC).asSet(); }  @Override Set<Feature> extract(JCas view1, JCas view2);  }
@Test public void extractTest1() throws Exception { Chunk chunk1 = new Chunk(jcas1, 0, 4); chunk1.addToIndexes(); Chunk chunk2 = new Chunk(jcas2, 0, 4); chunk2.addToIndexes(); DiffNounChunkCharacterLength extractor = new DiffNounChunkCharacterLength(); Set<Feature> features = extractor.extract(jcas1, jcas2); assertEquals(1, features.size()); for (Feature feature : features) { FeatureTestUtil.assertFeature("DiffNounPhraseCharacterLength", 0.0, feature, 0.0001); } }
@Test public void extractTest2() throws Exception { Chunk chunk1 = new Chunk(jcas1, 0, 4); chunk1.addToIndexes(); Chunk chunk2 = new Chunk(jcas2, 0, 7); chunk2.addToIndexes(); DiffNounChunkCharacterLength extractor = new DiffNounChunkCharacterLength(); Set<Feature> features = extractor.extract(jcas1, jcas2); assertEquals(1, features.size()); for (Feature feature : features) { assertFeature("DiffNounPhraseCharacterLength", -3.0, feature, 0.0001); } }