### Question:
MeasureNormalizerAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jCas) throws AnalysisEngineProcessException { Keep[] keeps = select(jCas, Keep.class).toArray(new Keep[0]); for (int i = 0; i < keeps.length; i++) { Keep k = keeps[i]; Annotation a = k.getEnclosedAnnot(); if (a instanceof Measure) { String unit = ((Measure) a).getUnit(); if (unit == null) { if (removeMeasure) { k.removeFromIndexes(jCas); } else { k.setNormalizedText(MEASURE_MASK + ""); } } else { if (unit.isEmpty() && removeMeasure) { k.removeFromIndexes(jCas); } else if (unit.equals(MEASURE_DATE) && removeDates) { k.removeFromIndexes(jCas); } else { k.setNormalizedText(MEASURE_MASK + unit); } } } } }  @Override void process(JCas jCas); static final String MEASURE_MASK; static final String PARAM_REMOVE_SIMPLE_MEASURE; static final String PARAM_REMOVE_DATE_MEASURE; }### Answer:
@Test public void testMeasuresIsCorrectlyParsed() throws Exception { JCas jCas = getTestCas("20%"); Measure m = createAnnot(jCas, Measure.class, 0, 2); m.setUnit("%"); m.setValue(20f); createAnnot(jCas, Keep.class, 0, 2).setEnclosedAnnot(m); PipelineBuilder builder = new JcasPipelineBuilder(jCas); builder.add(MeasureNormalizerAnnotator.class); builder.process(); assertTrue(exists(jCas, Keep.class)); assertEquals(MeasureNormalizerAnnotator.MEASURE_MASK + "%", select(jCas, Keep.class).iterator().next().getNormalizedText()); }
@Test public void testRemoveMeasure_() throws Exception { JCas jCas = getTestCas("20"); Measure m = createAnnot(jCas, Measure.class, 0, 1); m.setValue(20f); m.setUnit(""); createAnnot(jCas, Keep.class, 0, 1).setEnclosedAnnot(m); PipelineBuilder builder = new JcasPipelineBuilder(jCas); builder.add(createEngineDescription(MeasureNormalizerAnnotator.class, "removeSimpleMeasure", true)); builder.process(); Collection<Keep> keeps = select(jCas, Keep.class); assertEquals("Should have no keeps", 0, keeps.size()); }