People extends BaleenAnnotator { private void nationalityPeople(JCas jCas) { List<Nationality> toRemove = new ArrayList<>(); for (Nationality nat : JCasUtil.select(jCas, Nationality.class)) { String followingText = jCas.getDocumentText().substring(nat.getEnd()).toLowerCase(); if (followingText.startsWith(" people")) { Organisation o = new Organisation(jCas, nat.getBegin(), nat.getEnd() + 7); addToJCasIndex(o); if (removeOriginal) toRemove.add(nat); } } removeFromJCasIndex(toRemove); }  @Override AnalysisEngineAction getAction(); static final String PARAM_REMOVE_ORIGINAL; }
@Test public void testNationalityPeople() throws Exception { jCas.setDocumentText("The Scottish people voted in an independence referendum"); Nationality n = new Nationality(jCas, 4, 12); n.addToIndexes(); processJCas(); assertEquals(0, JCasUtil.select(jCas, Nationality.class).size()); assertEquals(1, JCasUtil.select(jCas, Organisation.class).size()); assertEquals( "Scottish people", JCasUtil.selectByIndex(jCas, Organisation.class, 0).getCoveredText()); }