### Question:
EntityPreprocessingTagger implements Tagger { @Override public List<Annotation> getAnnotations(String text) { List<? extends Annotation> annotations = TAGGER.getAnnotations(text); List<Annotation> fixedAnnotations = new ArrayList<>(); Set<String> inSentence = getInSentenceCandidates(text, annotations); inSentence = CollectionHelper.filterSet(inSentence, new Predicate<String>() { @Override public boolean test(String item) { return getLowercaseRatio(item) <= lowercaseThreshold; } }); if (inSentence.isEmpty()) { fixedAnnotations.addAll(annotations); return fixedAnnotations; } for (Annotation annotation : annotations) { String value = annotation.getValue(); if (isWithinSentence(text, annotation)) { fixedAnnotations.add(annotation); continue; } if (inSentence.contains(value)) { LOGGER.trace("Skip '{}', because it appears within a sentence", value); fixedAnnotations.add(annotation); continue; } String[] parts = value.split("\\s"); if (parts.length == 1) { double lcRatio = getLowercaseRatio(value); if (lcRatio > lowercaseThreshold) { LOGGER.debug("Drop '{}' because of lc/uc ratio of {}", value, lcRatio); continue; } } else { LOGGER.trace("Start correcting '{}'", value); int offsetCut = 0; String newValue = value; for (String token : parts) { double lcRatio = getLowercaseRatio(token); if (lcRatio <= lowercaseThreshold) { LOGGER.trace("Stop correcting '{}' at '{}' because of lc/uc ratio of {}", new Object[] {value, newValue, lcRatio}); break; } offsetCut += token.length() + 1; if (offsetCut >= value.length()) { break; } newValue = value.substring(offsetCut); if (inSentence.contains(newValue)) { LOGGER.trace("Stop correcting '{}' as '{}' is contained within sentence", value, newValue); break; } } if (offsetCut >= value.length()) { LOGGER.debug("Drop '{}' completely because of lc/uc ratio", value); continue; } else if (offsetCut > 0) { LOGGER.debug("Correct '{}' to '{}' because of lc/uc ratios", value, newValue); int newStart = annotation.getStartPosition() + offsetCut; fixedAnnotations.add(new ImmutableAnnotation(newStart, newValue, annotation.getTag())); continue; } } fixedAnnotations.add(annotation); } LOGGER.debug("Reduced from {} to {} with case dictionary", annotations.size(), fixedAnnotations.size()); if (longAnnotationSplit > 0) { List<Annotation> additionalAnnotations = getLongAnnotationSplit(fixedAnnotations, longAnnotationSplit); LOGGER.debug("Extracted additional {} annotations by splitting", additionalAnnotations.size()); fixedAnnotations.addAll(additionalAnnotations); } return fixedAnnotations; } EntityPreprocessingTagger(InputStream caseDictionaryStream, double lowercaseThreshold,
            int longAnnotationSplit); @Override List<Annotation> getAnnotations(String text); String correctCapitalization(String value);  }### Answer:
@Test public void testEntityPreprocessor() throws IOException { String text = FileHelper.readFileToString(ResourceHelper.getResourcePath("testText.txt")); List<Annotation> annotations = tagger.getAnnotations(text); assertEquals(41, annotations.size()); assertEquals("Clean Water Act", annotations.get(0).getValue()); assertEquals(31, annotations.get(0).getStartPosition()); assertEquals(46, annotations.get(0).getEndPosition()); assertEquals("Cleveland", annotations.get(3).getValue()); assertEquals("Bill Ruckelshaus", annotations.get(33).getValue()); }
@Test public void testEntityPreprocessor_shortPhrase_issue294() throws IOException { String text = "New York City"; List<Annotation> annotations = tagger.getAnnotations(text); assertEquals(1, annotations.size()); assertEquals("New York City", annotations.get(0).getValue()); }